Sunday 13 April 2014

Using fdisk in Linux





fdisk is a very powerful tool. And as a system administrator you should know how to
use this tool effectively and efficiently without causing harm to data. This tool will
save you a lot of time during installation and during normal system operation, both.

To check the partition list, use fdisk -l:

[root@mainserver /]# fdisk -l


Disk /dev/hda: 255 heads, 63 sectors, 4867 cylinders
Units = cylinders of 16065 * 512 bytes
 




The * in Boot column shows the active or boot partition, in this case it is
/dev/hda2 or 2nd primary partition on FAT32. The Id column contains the
partition file system type in hexadecimal format. Also the command will list all the
hard disks attached to the system and will display all the partitions in each hard disk.
While creating partitions, it should be noted that at one time there can be a maximum
of four primary (with no extended) partitions on one hard drive, numbered 1 to 4.
Also there can be only one extended (with max three primary) partition on one hard
disk. You can create as many partitions in extended as you want, numbered 5 and
above. So in the above example output of the command, fdisk -l, you can see
three primary partitions, numbered /dev/hda1 to /dev/hda3 and an extended
partition (considered a special type of primary partition) /dev/hda4, defined in
hard disk /dev/hda, which is the primary master hard disk on this system. This
extended partition contains four logical partitions(as many windows users call /
identify them), numbered /dev/hda5 to /dev/hda8.
The IDE devices are numbered using the following scheme :
Primary master/dev/hda
Primary slave/dev/hdb
Secondary master/dev/hdc
Secondary slave/dev/hdd

Disk /dev/hda: 255 heads, 63 sectors, 4867 cylinders
Units = cylinders of 16065 * 512 bytes

To modify partitions use fdisk in interactive mode. You have to type in the hard
disk device id as a parameter. Type the following command and press m to get a list
of available commands.
[root@mainserver /]# fdisk /dev/hdc
The number of cylinders for this disk is set to 4867.
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): m
Command action
   atoggle a bootable flag
   bedit bsd disklabel
   ctoggle the dos compatibility flag
   ddelete a partition
   llist known partition types
   mprint this menu
   nadd a new partition
   ocreate a new empty DOS partition table
   pprint the partition table
   qquit without saving changes
   screate a new empty Sun disklabel
   tchange a partition's system id
   uchange display/entry units
   vverify the partition table
   wwrite table to disk and exit
   xextra functionality (experts only)
Command (m for help):

 

  

No comments:

Post a Comment