Home Operation and Maintenance Linux Operation and Maintenance What impact does deleting a partition have on data in Linux?

What impact does deleting a partition have on data in Linux?

Mar 13, 2023 pm 06:51 PM
linux delete partition

In Linux, deleting a partition will also delete the data in the partition, resulting in data loss. How to delete a partition: 1. Install the GParted tool, select the partition you want to delete in the GParted interface, and select the "Delete" option from the partition menu; 2. Use the fdisk command to delete, with the syntax "sudo fdisk --list partition name".

What impact does deleting a partition have on data in Linux?

#The operating environment of this tutorial: linux7.3 system, Dell G3 computer.

Each partition in the Linux system is a file system and has its own directory hierarchy.

linux What impact does deleting a partition have on data?

Deleting a partition will also delete the data in the partition, resulting in data loss.

So whenever you are working on a partition, be sure to back up your data. A slight typo or slippage can be costly. Don't say we didn't warn you!

Linux disk partition

1. Primary partition, extended partition and logical partition

Linux There are three types of hard disk partitions: primary partition, extended partition and logical partition.

The partitions of the hard disk are mainly divided into two types: primary partition (Primary Partion) and extended partition (Extension Partion). The sum of the number of primary partitions and extended partitions cannot be greater than four.

  • Primary Partion: It can be used immediately but cannot be partitioned again.

  • Extension Partion: It must be partitioned before it can be used, which means it must be partitioned twice.

  • Logical partition ((Logical Partion)): A partition established by an extended partition. There is no limit on the number of logical partitions.

The extended partition is just a "container" for the logical partition. In fact, only the primary partition and the logical partition are used for data storage.

2. The identification of hard disk partition under Linux

The identification of hard disk partition is generally /dev/hd[a-z]X or /dev/sd[a-z]X. Identification, where [a-z] represents the hard disk number, and X represents the partition number in the hard disk.

The block number identification of the entire hard disk partition: under Linux, hda, hdb, sda, sdb, etc. are used to identify different hard disks;

Among them:

  • IDE interface hard disk: represented as /dev/hda1, /dev/hdb...;

  • SCSI interface hard disk and SATA interface hard disk are represented as /dev/sda, /dev/ sdb... ... ;

Partitions in the hard disk: If the value of For example, /dev/hda5 must be a logical partition;

For example:

Use hda1, hda2, hda5, and hda6 to identify different partitions. Among them, the letter a represents the first hard disk, b represents the second hard disk, and so on. The number 1 represents the first partition of a hard disk, 2 represents the second partition, and so on. 1 to 4 correspond to the primary partition (Primary Partition) or extended partition (Extension Partition). Starting from 5, they all correspond to the logical partition of the hard disk (Logical Partition). Even if a hard disk has only one primary partition, the logical partitions are numbered starting from 5, so special attention should be paid to this.

What impact does deleting a partition have on data in Linux?

How to delete a partition in Linux

1. Use GParted to delete a disk partition (GUI Method)

As a desktop Linux user, you may feel more comfortable, and perhaps more secure, with GUI-based tools. There are several tools that let you manage partitions on Linux. Depending on your distribution, you may have one or more of these tools installed on your system. In this tutorial, I will use GParted. It is a popular open source tool that is very simple and intuitive to use.

The first step is to install GParted if it is not already on your system. You should be able to find it in your distribution's Software Center.

What impact does deleting a partition have on data in Linux?

Alternatively, you can install it using your distribution’s package manager. In Debian and Ubuntu-based Linux distributions, you can use the apt install command:

sudo apt install gparted
Copy after login

After the installation is complete, let us open GParted. Since you are dealing with disk partitions, you need root access. It will ask for authentication and once it opens, you should see a window similar to this:

What impact does deleting a partition have on data in Linux?

In the upper right corner you can select the disk and below select the one you want to delete Partition.

Next, select the “Delete” option from the partition menu:

What impact does deleting a partition have on data in Linux?

这个过程是没有完整完成的,直到你重写分区表。这是一项安全措施,它让你在确认之前可以选择审查更改。
要完成它,只需点击位于工具栏中的 “应用所有操作” 按钮,然后在要求确认时点击 “应用”。

What impact does deleting a partition have on data in Linux?

点击 “应用” 后,你会看到一个进度条和一个结果消息说所有的操作都成功了。你可以关闭该信息和主窗口,并认为你的分区已从磁盘中完全删除。

现在你已经知道了 GUI 的方法,让我们继续使用命令行。

2、使用 fdisk 命令删除分区(CLI 方法)

几乎每个 Linux 发行版都默认带有 fdisk,我们今天就来使用这个工具。你需要知道的第一件事是,你想删除的分区被分配到哪个设备上了。为此,在终端输入以下内容:

sudo fdisk --list
Copy after login

这将打印出我们系统中所有的驱动器和分区,以及分配的设备。你 需要有 root 权限,以便让它发挥作用。

在本例中,我将使用一个包含两个分区的 USB 驱动器,如下图所示:

What impact does deleting a partition have on data in Linux?

系统中分配的设备是 /sdb,它有两个分区:sdb1 和 sdb2。现在你已经确定了哪个设备包含这些分区,你可以通过使用 fdisk 和设备的路径开始操作:

sudo fdisk /dev/sdb
Copy after login

这将在命令模式下启动 fdisk。你可以随时按 m 来查看选项列表。

接下来,输入 p,然后按回车查看分区信息,并确认你正在使用正确的设备。如果使用了错误的设备,你可以使用 q 命令退出 fdisk 并重新开始。

现在输入 d 来删除一个分区,它将立即询问分区编号,这与 “Device” 列中列出的编号相对应,在这个例子中是 1 和 2(在下面的截图中可以看到),但是可以也会根据当前的分区表而有所不同。

What impact does deleting a partition have on data in Linux?

让我们通过输入 2 并按下回车来删除第二个分区。你应该看到一条信息:“Partition 2 has been deleted”,但实际上,它还没有被删除。fdisk 还需要一个步骤来重写分区表并应用这些变化。你看,这就是完全网。

你需要输入 w,然后按回车来使这些改变成为永久性的。没有再要求确认。

在这之后,你应该看到下面这样的反馈:

What impact does deleting a partition have on data in Linux?

现在,使用

sudo fdisk --list /dev/sdb
Copy after login

查看该设备的当前分区表,你可以看到第二个分区已经完全消失。你已经完成了使用终端和 fdisk 命令来删除你的分区。成功了!

相关推荐:《Linux视频教程

The above is the detailed content of What impact does deleting a partition have on data in Linux?. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Roblox: Bubble Gum Simulator Infinity - How To Get And Use Royal Keys
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Mandragora: Whispers Of The Witch Tree - How To Unlock The Grappling Hook
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Nordhold: Fusion System, Explained
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1669
14
PHP Tutorial
1273
29
C# Tutorial
1256
24
Linux Architecture: Unveiling the 5 Basic Components Linux Architecture: Unveiling the 5 Basic Components Apr 20, 2025 am 12:04 AM

The five basic components of the Linux system are: 1. Kernel, 2. System library, 3. System utilities, 4. Graphical user interface, 5. Applications. The kernel manages hardware resources, the system library provides precompiled functions, system utilities are used for system management, the GUI provides visual interaction, and applications use these components to implement functions.

vscode Previous Next Shortcut Key vscode Previous Next Shortcut Key Apr 15, 2025 pm 10:51 PM

VS Code One-step/Next step shortcut key usage: One-step (backward): Windows/Linux: Ctrl ←; macOS: Cmd ←Next step (forward): Windows/Linux: Ctrl →; macOS: Cmd →

How to check the warehouse address of git How to check the warehouse address of git Apr 17, 2025 pm 01:54 PM

To view the Git repository address, perform the following steps: 1. Open the command line and navigate to the repository directory; 2. Run the "git remote -v" command; 3. View the repository name in the output and its corresponding address.

How to run java code in notepad How to run java code in notepad Apr 16, 2025 pm 07:39 PM

Although Notepad cannot run Java code directly, it can be achieved by using other tools: using the command line compiler (javac) to generate a bytecode file (filename.class). Use the Java interpreter (java) to interpret bytecode, execute the code, and output the result.

How to run sublime after writing the code How to run sublime after writing the code Apr 16, 2025 am 08:51 AM

There are six ways to run code in Sublime: through hotkeys, menus, build systems, command lines, set default build systems, and custom build commands, and run individual files/projects by right-clicking on projects/files. The build system availability depends on the installation of Sublime Text.

What is the main purpose of Linux? What is the main purpose of Linux? Apr 16, 2025 am 12:19 AM

The main uses of Linux include: 1. Server operating system, 2. Embedded system, 3. Desktop operating system, 4. Development and testing environment. Linux excels in these areas, providing stability, security and efficient development tools.

laravel installation code laravel installation code Apr 18, 2025 pm 12:30 PM

To install Laravel, follow these steps in sequence: Install Composer (for macOS/Linux and Windows) Install Laravel Installer Create a new project Start Service Access Application (URL: http://127.0.0.1:8000) Set up the database connection (if required)

git software installation git software installation Apr 17, 2025 am 11:57 AM

Installing Git software includes the following steps: Download the installation package and run the installation package to verify the installation configuration Git installation Git Bash (Windows only)

See all articles