Be Inquisitive ! Be Curious !! Explore !!! Enjoy !!!!

Linux fdisk command

| Monday, August 15


About fdisk
Partition table manipulator for Linux.
Syntax
fdisk [-u] [-b sectorsize] [-C cyls] [-H heads] [-S sects] device

fdisk -l [-u] [device ...]

fdisk -s partition ...

fdisk -v
-b sectorsizeSpecify the sector size of the disk. Valid values are 512, 1024, or 2048. (Recent kernels know the sector size. Use this only on old kernels or to override the kernelâs
ideas.)
-C cylsSpecify the number of cylinders of the disk. I have no idea why anybody would want to do so.
-H headsSpecify the number of heads of the disk. (Not the physical number, of course, but the number used for partition tables.) Reasonable values are 255 and 16.
-S sectsSpecify the number of sectors per track of the disk. (Not the physical number, of course, but the number used for partition tables.) A reasonable value is 63.
-lList the partition tables for the specified devices and then exit. If no devices are given, those mentioned in /proc/partitions (if that exists) are used.
-uWhen listing partition tables, give sizes in sectors instead of cylinders.
-s partitionThe size of the partition (in blocks) is printed on the standard output.
-vPrint version number of fdisk program and exit.
Examples
Tip You most have root access for this command to work.
fdisk -l
List the partition information of the computer you're logged into. Below is an example of what this output may look like.
Disk /dev/sda: 250.0 GB, 250059350016 bytes
255 heads, 63 sectors/track, 30401 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sda1 * 1 191 1534176 83 Linux
/dev/sda2 192 2231 16386300 83 Linux
/dev/sda3 2232 3506 10241437+ 83 Linux
/dev/sda4 3507 30401 216034087+ 5 Extended
/dev/sda5 3507 3767 2096451 82 Linux swap / Solaris
/dev/sda6 3768 3832 522081 83 Linux
/dev/sda7 3833 30401 213415461 83 Linux

Disk /dev/sdb: 250.0 GB, 250059350016 bytes
255 heads, 63 sectors/track, 30401 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sdb1 * 1 30401 244196001 83 Linux
Warning The DOS 6.x FORMAT command looks for some information in the first sector of the data area of the partition, and treats this information as more reliable than the information in
the partition table. DOS FORMAT expects DOS FDISK to clear the first 512 bytes of the data area of a partition whenever a size change occurs. DOS FORMAT will look at this extra
information even if the /U flag is given -- we consider this a bug in DOS FORMAT and DOS FDISK.

The bottom line is that if you use fdisk to change the size of a DOS partition table entry, then you must also use dd to zero the first 512 bytes of that partition before using
DOS FORMAT to format the partition. For example, if you were using disk to make a DOS partition table entry for /dev/sda1, then (after exiting fdisk and rebooting Linux so that
the partition table information is valid) you would use the command "dd if=/dev/zero of=/dev/sda1 bs=512 count=1" to zero the first 512 bytes of the partition.

BE EXTREMELY CAREFUL if you use the dd command, since a small typo can make all of the data on your disk useless.

For best results, you should always use an OS-specific partition table program. For example, you should make DOS partitions with the DOS FDISK program and Linux partitions with
the Linux fdisk program.

0 comments:

Post a Comment