Author Topic: How to remove partition in CentOS  (Read 657 times)

arjun.datasoft

  • Blue Belt
  • ****
  • Posts: 180
  • Karma: +0/-0
How to remove partition in CentOS
« on: August 26, 2013, 09:13:38 AM »
Hi,

First, get a listing of your current partition scheme, type the following command:
# fdisk -l.

Output:

Device Boot      Start         End      Blocks   Id  System
/dev/hdb1   *           1        2432    19535008+  83  Linux
/dev/hdb2            2433        2554      979965   82  Linux swap / Solaris
/dev/hdb3            2555        6202    29302560   83  Linux
/dev/hdb4            6203        9733    28362757+   5  Extended
/dev/hdb5            6203        9733    28362726   83  Linux
From above output I have two hard disks:
=> /dev/hda - 20 GB
=> /dev/hdb - 80 GB


Let us assume that you want to remove a partition from /dev/hdb disk. Type the following command:

# fdisk /dev/hdb

Output:

The number of cylinders for this disk is set to 9733.
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)
[/color]
Command (m for help):
Now type p command to list partition:

Command (m for help): p

Output:

Disk /dev/hdb: 80.0 GB, 80060424192 bytes
255 heads, 63 sectors/track, 9733 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
   Device Boot      Start         End      Blocks   Id  System
/dev/hdb1   *           1        2432    19535008+  83  Linux
/dev/hdb2            2433        2554      979965   82  Linux swap / Solaris
/dev/hdb3            2555        6202    29302560   83  Linux
/dev/hdb4            6203        9733    28362757+   5  Extended
/dev/hdb5            6203        9733    28362726   83  Linux


Now let us say you want to delete /dev/hdb3 (3rd partition). Type the d command to delete a partition:

Command (m for help): d

Partition number (1-4): 3

It will prompt you for the partition number. Type 3:

Verify that partition deleted:
Command (m for help): p

Now save the changes and exit to shell prompt. Type the w command:
Command (m for help): w

Reboot the system.

Thanks