How To: Delete a partition using Fdisk utility in Linux
Q. My System have got two partition which i would like to delete and create one big partition. Now how would i delete the partition and create a one big partition ?
A. Fdisk is the utility which we will be using for this example. Though there are other options also like parted/gparted and use of them depends totally on personal preference. For Fdisk, you need to provide the device name as an argument. For that the possible options could be:
/dev/hda
/dev/hdb
/dev/sda
/dev/sdb
Where
/dev/hd[a-h] stands for IDE disks
/dev/sd[a-p] stands for SCSI disks
/dev/ed[a-d] stands for ESDI disks
/dev/xd[ab] stands for XT disks.
Hard disks can be divided into one or more logical disks called partitions. The partition info is stored in the partition table which is present in the first 512 bytes of the disk.
Before starting this procedure, it advised to backup all your important data, because a small mistake and all your data will be gone. Now let’s see how many partitions you have got.
Output:
255 heads, 63 sectors/track, 19457 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x7c97a33b
Device Boot Start End Blocks Id System
/dev/sda1 * 1 2550 20480000 83 Linux
/dev/sda2 2551 12526 80132220 5 Extended
/dev/sda5 2551 2799 2000061 82 Linux swap / Solaris
/dev/sda6 2800 10094 58597056 83 Linux
/dev/sda7 10095 12526 19535008+ 83 Linux
The about output shows that we have one hard drive of 160GB which have five partitions out of which there is one primary and three logical partitions. Out of this we are going to delete last two partitions and going to create one big partition out of it.
Deleting the partition:
The number of cylinders for this disk is set to 19457.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)
Command (m for help): p
Disk /dev/sda: 160.0 GB, 160041885696 bytes
255 heads, 63 sectors/track, 19457 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x7c97a33b</p>
Device Boot Start End Blocks Id System
/dev/sda1 * 1 2550 20480000 83 Linux
/dev/sda2 2551 12526 80132220 5 Extended
/dev/sda5 2551 2799 2000061 82 Linux swap / Solaris
/dev/sda6 2800 10094 58597056 83 Linux
/dev/sda7 10095 12526 19535008+ 83 Linux
Command (m for help): d
Partition number (1-7): 7
Delete the partition 7
Command (m for help): d
Partition number (1-6): 6
Delete the partition 6
Command (m for help): p
Disk /dev/sda: 160.0 GB, 160041885696 bytes
255 heads, 63 sectors/track, 19457 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x7c97a33b
Device Boot Start End Blocks Id System
/dev/sda1 * 1 2550 20480000 83 Linux
/dev/sda2 2551 12526 80132220 5 Extended
/dev/sda5 2551 2799 2000061 82 Linux swap / Solaris
That’s it. The first part of deleting the old partitions is done. Now we have to create one new big partition.
Command action
l logical (5 or over)
p primary partition (1-4)
l
First cylinder (2800-12526, default 2800):
Using default value 2800
Last cylinder, +cylinders or +size{K,M,G} (2800-12526, default 12526):
Using default value 12526
Command (m for help): p
Disk /dev/sda: 160.0 GB, 160041885696 bytes
255 heads, 63 sectors/track, 19457 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x7c97a33b
Device Boot Start End Blocks Id System
/dev/sda1 * 1 2550 20480000 83 Linux
/dev/sda2 2551 12526 80132220 5 Extended
/dev/sda5 2551 2799 2000061 82 Linux swap / Solaris
/dev/sda6 2800 12526 78132096 83 Linux
Command (m for help):
As you can see, your last two old partitions are deleted and one big partition is there. Now you just need to update the kernel for the changes in the partitioning table which you have done. This can be done it two ways.
- Either you reboot the system.
- Or use the Partprobe command
OR
# partprobe
Please refer to this post Partitioning Hard Drive using FDisk utility in Linux for more details.
If you enjoyed this post, make sure you subscribe to my RSS feed!!!!