Delete partition table linux

How to Delete Partitions in Linux [Beginner’s Guide]

Managing partitions is serious business, especially when you have to remove them. I find myself doing this frequently, especially after using thumb drives as live disks and Linux installers because they create several partitions that I won’t need afterwards.

In this tutorial, I will show you how to remove partitions in Linux using both command line and GUI tools.

You delete the partition, you lose your data. Whenever you are playing with partitions, make sure backup your data. A slight typo or slip of finger could prove costly. Don’t say we didn’t warn you!

Remove disk partition using GParted [GUI Method]

As a desktop Linux user, you probably will be more comfortable and perhaps safer with a GUI-based tool.

There are several tools that let you manage partitions on Linux. Depending on your distribution you will have one or even more such tool already installed on your system.

For this tutorial, I am going to use GParted. It is a popular open source tool and it’s very easy and intuitive to use.

The first step is installing GParted if it isn’t already in your system. You should be able to find it in the software center of your distribution.

gparted ubuntu software center

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

Once installed, let’s open GParted. Since you are dealing with disk partitions, you’ll be required to have root access. It will ask for authentication and once it opens you should see a window like this one:

removing partitions linux 004

On the right-upper corner you can select the disk and in the lower screen the partition you want to remove.

Читайте также:  При установке linux mint выдает ошибку

Next, select the option Delete from the Partition menu:

Removing partitions in Linux with GParted

The process is incomplete until you rewrite the partition table. This is a safety measure and it gives you the option to review the changes before confirming it.

To do this just click on the Apply All Operations button located in the toolbar and then Apply when asked for confirmation.

Confirm changes to partitions in GParted

After hitting Apply, you will see a progress bar and a results message saying that all the operations were successful. You can close the message and the main window and consider your partition completely deleted from our disk.

Now that you are aware of the GUI method, let’s move on to the command line.

Delete partitions using fdisk command

Almost every Linux distribution comes with fdisk by default and we are going to use this tool today. The first thing you need to know is what device is assigned to the disk with the partitions you want to remove. To do that, type the following in the terminal:

This will print all the drives and partitions in our system as well as the assigned devices. You need to have root access in order for it work.

In this example, I will work with a USB drive that contains two partitions as shown below:

Using fdisk for partitions in Linux

The device assigned in the system is /sdb and it has two partitions, sdb1 and sdb2. Now that you identified which device contains the partitions, you can start working on it by using fdisk and the path to the device:

This will start fdisk in command mode. You can always press m to see a list of options.

Next, type p and press Enter to view the partition information and confirm that you are using the right device. If the wrong device is in use you can use the q command to exit fdisk and start the procedure again.

Now enter d to delete a partition and it will immediately ask for the partition number, that corresponds to the number listed in the Device column, which in this case are numbers 1 and 2 (as can be seen in the screen capture below) but can and will vary according to the current partition table.

Читайте также:  Kali linux вай фай адаптер

Remove partitions in Linux using fdisk

Let’s remove the second partition by typing 2 and pressing Enter . You should see a message saying “Partition 2 has been deleted“, but actually, it hasn’t been removed yet. fdisk needs one more step to rewrite the partition table and apply the changes. Safety net, you see.

You need to type w and press Enter to make the changes permanent. No confirmation is asked.

After this, you should receive some feedback like the one here:

Delete partition in Linux with fdisk

Now, use sudo fdisk —list /dev/sdb to view the current partition table of the device and you can see that the second partition is completely gone. You are done removing your partition using the terminal and fdisk command. Success!

Wrapping up

And so I end this tutorial on how to remove partitions in Linux using both the terminal and GUI tools. Remember, stay always on the safe side, backup your files before manipulating your partitions and double check that you are using the right device. Deleting a partition will delete everything in it with little to no chance of recovering it.

Источник

Как удалить раздел диска в Linux

img

Пользователи Linux создают разделы для эффективной организации своих данных. Разделы Linux могут быть удалены так же просто, как и созданы, чтобы переформатировать устройство хранения и освободить место для хранения.

Как удалить раздел диска в Linux

Удалить раздел в Linux

Для удаления раздела в Linux необходимо выбрать диск, содержащий раздел, и использовать утилиту командной строки fdisk для его удаления.

Примечание. Утилита командной строки fdisk — это текстовый манипулятор таблицы разделов. Она используется для разделения и перераспределения устройств хранения.

Шаг 1. Составьте список схемы разделов

Перед удалением раздела выполните следующую команду, чтобы просмотреть схему разделов.

В нашем случае терминал распечатывает информацию о двух дисках: /dev/sda и /dev/sdb . Диск /dev/sda содержит операционную систему, поэтому его разделы удалять не следует.

fdisk -l

На диске /dev/sdb есть раздел /dev/sdb1 , который мы собираемся удалить.

Примечание. Число 1 в /dev/sdb1 указывает номер раздела. Запишите номер раздела, который вы собираетесь удалить.

Шаг 2: Выберите диск

Выберите диск, содержащий раздел, который вы собираетесь удалить.

Общие имена дисков в Linux включают:

Тип диска Имена дисков Обычно используемые имена дисков
IDE /dev/hd[a-h] /dev/hda, /dev/hdb
SCSI /dev/sd[a-p] /dev/sda, /dev/sdb
ESDI /dev/ed[a-d] /dev/eda
XT /dev/xd[ab] /dev/xda
Читайте также:  Network security toolkit linux

Чтобы выбрать диск, выполните следующую команду:

sudo fdisk /dev/sdb

Шаг 3: удалить разделы

Перед удалением раздела сделайте резервную копию своих данных. Все данные автоматически удаляются при удалении раздела.

Чтобы удалить раздел, выполните команду d в утилите командной строки fdisk .

Раздел выбирается автоматически, если на диске нет других разделов. Если диск содержит несколько разделов, выберите раздел, введя его номер.

Терминал распечатает сообщение, подтверждающее, что раздел удален.

d

Примечание. Если вы хотите удалить несколько разделов, повторите этот шаг столько раз, сколько необходимо.

Шаг 4: проверьте удаление раздела

Перезагрузите таблицу разделов, чтобы убедиться, что раздел был удален. Для этого запустите команду p .

Терминал выведет структуру разделов диска, выбранного на шаге 2.

p

Шаг 5. Сохраните изменения и выйдите

Запустите команду w , чтобы записать и сохранить изменения, внесенные на диск.

Источник

How to clear/delete all the partition table from a disk or partition in Linux

Disk /dev/sdb: 17.2 GB, 17179869184 bytes, 33554432 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x1410600c

Device Boot Start End Blocks Id System
/dev/sdb1 2048 4196351 2097152 83 Linux
/dev/sdb2 4196352 10487807 3145728 83 Linux

Now I would like to clear the partition table from this disk
To do so below commands can be used

Check the partition table

Here I have a dos partition table

Clear the partition table

Using the below command you can wipe » dos » partition table

# wipefs -a -t dos -f /dev/sdb
/dev/sdb: 2 bytes were erased at offset 0x000001fe (dos): 55 aa
/dev/sdb: calling ioclt to re-read partition table: Success

If I had a GPT partition table then to clear the same

To clear all the partition tables

You can also delete a partition table using the offset value as shown above

Once the above command returns success, check the partition table using fdisk

Disk /dev/sdb: 17.2 GB, 17179869184 bytes, 33554432 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

As you both my partitions are cleared/deleted.

Источник

Оцените статью
Adblock
detector