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.

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:

Читайте также:  Linux fdisk to ntfs

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.

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. Составьте список схемы разделов

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

Читайте также:  Переустановить пакет astra linux

В нашем случае терминал распечатывает информацию о двух дисках: /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

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

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.

Источник

How to Delete Partition in Linux

Linux users create partitions to organize their data in an efficient manner. As easy as they are created, Linux partitions can be deleted to reformat a storage device and regain storage space.

In this step-by-step tutorial, you will learn how to delete a partition on a Linux system.

How to Delete Partition in Linux

  • A system running Linux
  • A user account with sudo or root privileges
  • Access to a terminal window / command line (Activities >Search >Terminal)
  • The fdisk command-line utility

Delete a Partition in Linux

Deleting a partition in Linux requires selecting the disk containing the partition and using the fdisk command-line utility to delete it.

Читайте также:  Права linux запуск файла

Follow the steps outlined in the sections below to delete partitions in Linux.

Note: The fdisk command-line utility is a text-based partition table manipulator. It is used for partitioning and repartitioning storage devices.

Step 1: List Partition Scheme

Before deleting a partition, run the following command to list the partition scheme.

In our case, the terminal prints out information about two disks: /dev/sda and /dev/sdb . Disk /dev/sda contains the operating system, therefore its partitions should not be deleted.

Listing the partition scheme

On the /dev/sdb disk, there is a /dev/sdb1 partition which we are about to delete.

Note: The number 1 in /dev/sdb1 indicates the partition number. Make a note of the number of the partition you intend to delete.

Step 2: Select the Disk

Select the disk that contains the partition you intend to delete.

Common disk names on Linux include:

Type of disk Disk names Commonly used disk names
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

To select a disk, run the following command:

Selecting storage disk with fdisk command.

Step 3: Delete Partitions

Before deleting a partition, back up your data. All data is automatically deleted when a partition is deleted.

To delete partition, run the d command in the fdisk command-line utility.

The partition is automatically selected if there are no other partitions on the disk. If the disk contains multiple partitions, select a partition by typing its number.

The terminal prints out a message confirming that the partition is deleted.

Deleting partition.

Note: If you wish to delete multiple partitions, repeat this step as many times as necessary.

Step 4: Verify Partition Deletion

Reload the partition table to verify that the partition has been deleted. To do so, run the p command.

The terminal prints out the partition structure of the disk selected in Step 2.

Partition table reload.

Step 5: Save Changes and Quit

Run the w command to write and save changes made to the disk.

Quitting fdisk command-line utility and saving changes to the disk.

After following the instructions in this tutorial, you should have learned how to delete a partition in Linux.

If you want to learn more about partition manipulation, we recommend reading our tutorial on creating partitions in Linux or if you are running NTFS partitions, check out our article on how to mount NTFS partitions in Linux.

Dejan is the Head of Content at phoenixNAP with over 8 years of experience in Web publishing and technical writing. Prior to joining PNAP, he was Chief Editor of several websites striving to advocate for emerging technologies. He is dedicated to simplifying complex notions and providing meaningful insight into data center and cloud technology.

In Linux systems, in order to use storage devices such as Hard Drives and USB drives, you need to understand.

sudo stands for SuperUser DO, and it’s used to temporarily elevate privileges in Linux. This guide will show.

The ls command (short for list) lists information about directories and any type of files in the working.

A list of all the important Linux commands in one place. Find the command you need, whenever you need it or.

Источник

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