search
HomeOperation and MaintenanceLinux Operation and MaintenanceWhat impact does deleting a partition have on data in Linux?

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

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

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

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

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

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

sudo fdisk /dev/sdb

这将在命令模式下启动 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

查看该设备的当前分区表,你可以看到第二个分区已经完全消失。你已经完成了使用终端和 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
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
The 5 Core Components of the Linux Operating SystemThe 5 Core Components of the Linux Operating SystemMay 08, 2025 am 12:08 AM

The five core components of the Linux operating system are: 1. Kernel, 2. System libraries, 3. System tools, 4. System services, 5. File system. These components work together to ensure the stable and efficient operation of the system, and together form a powerful and flexible operating system.

The 5 Essential Elements of Linux: ExplainedThe 5 Essential Elements of Linux: ExplainedMay 07, 2025 am 12:14 AM

The five core elements of Linux are: 1. Kernel, 2. Command line interface, 3. File system, 4. Package management, 5. Community and open source. Together, these elements define the nature and functionality of Linux.

Linux Operations: Security and User ManagementLinux Operations: Security and User ManagementMay 06, 2025 am 12:04 AM

Linux user management and security can be achieved through the following steps: 1. Create users and groups, using commands such as sudouseradd-m-gdevelopers-s/bin/bashjohn. 2. Bulkly create users and set password policies, using the for loop and chpasswd commands. 3. Check and fix common errors, home directory and shell settings. 4. Implement best practices such as strong cryptographic policies, regular audits and the principle of minimum authority. 5. Optimize performance, use sudo and adjust PAM module configuration. Through these methods, users can be effectively managed and system security can be improved.

Linux Operations: File System, Processes, and MoreLinux Operations: File System, Processes, and MoreMay 05, 2025 am 12:16 AM

The core operations of Linux file system and process management include file system management and process control. 1) File system operations include creating, deleting, copying and moving files or directories, using commands such as mkdir, rmdir, cp and mv. 2) Process management involves starting, monitoring and killing processes, using commands such as ./my_script.sh&, top and kill.

Linux Operations: Shell Scripting and AutomationLinux Operations: Shell Scripting and AutomationMay 04, 2025 am 12:15 AM

Shell scripts are powerful tools for automated execution of commands in Linux systems. 1) The shell script executes commands line by line through the interpreter to process variable substitution and conditional judgment. 2) The basic usage includes backup operations, such as using the tar command to back up the directory. 3) Advanced usage involves the use of functions and case statements to manage services. 4) Debugging skills include using set-x to enable debugging mode and set-e to exit when the command fails. 5) Performance optimization is recommended to avoid subshells, use arrays and optimization loops.

Linux Operations: Understanding the Core FunctionalityLinux Operations: Understanding the Core FunctionalityMay 03, 2025 am 12:09 AM

Linux is a Unix-based multi-user, multi-tasking operating system that emphasizes simplicity, modularity and openness. Its core functions include: file system: organized in a tree structure, supports multiple file systems such as ext4, XFS, Btrfs, and use df-T to view file system types. Process management: View the process through the ps command, manage the process using PID, involving priority settings and signal processing. Network configuration: Flexible setting of IP addresses and managing network services, and use sudoipaddradd to configure IP. These features are applied in real-life operations through basic commands and advanced script automation, improving efficiency and reducing errors.

Linux: Entering and Exiting Maintenance ModeLinux: Entering and Exiting Maintenance ModeMay 02, 2025 am 12:01 AM

The methods to enter Linux maintenance mode include: 1. Edit the GRUB configuration file, add "single" or "1" parameters and update the GRUB configuration; 2. Edit the startup parameters in the GRUB menu, add "single" or "1". Exit maintenance mode only requires restarting the system. With these steps, you can quickly enter maintenance mode when needed and exit safely, ensuring system stability and security.

Understanding Linux: The Core Components DefinedUnderstanding Linux: The Core Components DefinedMay 01, 2025 am 12:19 AM

The core components of Linux include kernel, shell, file system, process management and memory management. 1) Kernel management system resources, 2) shell provides user interaction interface, 3) file system supports multiple formats, 4) Process management is implemented through system calls such as fork, and 5) memory management uses virtual memory technology.

See all articles

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

Hot Tools

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment