Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to delete a partition in Linux

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces the relevant knowledge of how to delete partitions in Linux, the content is detailed and easy to understand, the operation is simple and fast, and has a certain reference value, I believe you will gain something after reading this Linux article on how to delete partitions, let's take a look at it.

Delete disk partitions using GParted (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, one or more of these tools have been 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 the software center of your distribution.

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

Sudo apt install gparted

After the installation is complete, let's open GParted. Since you are dealing with disk partitions, you need to have root permissions. It will require authentication, and when you open it, you should see a window like this:

In the upper right corner, you can select the disk and select the partition you want to delete below. Next, select the Delete option from the partition menu:

This process is not complete until you rewrite the partition table. This is a security measure that gives you the option to review changes before confirming. To do this, simply click the "apply all actions" button located in the toolbar, and then click "apply" when asked for confirmation.

After clicking "apply", you will see a progress bar and a result message saying that all operations have been successful. You can close the message and the main window and assume that your partition has been completely deleted from the disk. Now that you know how to use GUI, let's continue using the command line.

Delete a partition using the fdisk command (CLI method)

Almost every Linux distribution comes with fdisk by default, and we'll use this tool today. The first thing you need to know is to which device the partition you want to delete is assigned. To do this, enter the following at the terminal:

Sudo fdisk-list

This will print out all the drives and partitions in our system, as well as the assigned devices. You need to have root permission to make it work. In this example, I will use a USB drive with two partitions, as shown in the following figure:

The device allocated in the system is / sdb, which has two partitions: sdb1 and sdb2. Now that you have determined which device contains these partitions, you can start by using fdisk and the path to the device:

Sudo fdisk / dev/sdb

This starts fdisk in command mode. You can press m at any time to see the list of options. Next, type p, then press enter to view the partition information and make sure you are using the correct device. If you use the wrong device, you can use the Q command to exit fdisk and start over. Now type d to delete a partition, which immediately asks for the partition number, which corresponds to the number listed in the "Device" column, which in this case is 1 and 2 (as you can see in the screenshot below), but can and will vary depending on the current partition table.

Let's delete the second partition by typing 2 and pressing enter. You should see a message: "Partition 2 has been deleted", but in fact, it has not been deleted. Fdisk also needs a step to rewrite the partition table and apply these changes. You see, this is the complete net. You need to type w and press enter to make these changes permanent. No more confirmation was requested. After that, you should see the following feedback:

Now, use the

Sudo fdisk-list / dev/sdb

Looking at the device's current partition table, you can see that the second partition has completely disappeared. You have finished using the terminal and fdisk commands to delete your partition.

This is the end of the article on "how to delete partitions in Linux". Thank you for reading! I believe that everyone has a certain understanding of the knowledge of "how to delete partition in Linux". If you want to learn more, you are welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report