🌐 🇵🇱 Polski · 🇬🇧 EN
In the previous parts, we covered partition creation; now it is time to show how to delete them. This will be useful before moving on to the next topic, which is LVM - Logical Volume Manager. Deleting partitions is easier than creating them because you only need to know the number of the partition you want to delete.
Step 1 - Launching the "fdisk" utility and selecting the disk
# fdisk /dev/hbd
Step 2 - Displaying the partition table for the selected disk
# Command (m for help) : p
Disk /dev/hdb: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0004b72d
Device Boot Start End Blocks Id System
/dev/hdb1 1 548 4401778+ 83 Linux
/dev/hdb2 549 1044 3984120 83 Linux
We can see the two partitions we created earlier.
Step 3 - Deleting the first partition
Command (m for help): d
Partition number (1-4): 1
Step 4 - Deleting the second partition
Command (m for help): d
Selected partition 2
Step 5 - Saving changes to the disk
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
Step 6 - Refreshing the partition table
# partprobe /dev/hdb
Of course, deleting partitions can also be performed using the "parted" utility.
Step 1 - Launching the parted utility and selecting the disk.
# parted /dev/hdc
Step 2 - Displaying available partitions
# (parted) print
Model: VBOX HARDDISK (ide)
Disk /dev/hdc: 8590MB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Number Start End Size Type File system Flags
1 512B 4294MB 4294MB primary
2 4295MB 8590MB 4295MB primary
Step 3 - Deleting partitions
# (parted) rm 1
# (parted) rm 2
Step 4 - Exiting the utility and saving changes
# (parted) quit
# partprobe /dev/hdc
Comments