The Basics of fdisk

First, you need to know the device file of the drive to be configured. The easiest way to determine this is with the following command, which lists all connected drives—if they’re detected:

$ sudo fdisk -l


You’ll see drive sizes, listed in order, as well as partitions configured on each drive. A sample output is shown in Figure 5-1. Note the partitions configured on the first two drives. The actual drive order varies by hardware; portable drives such as those connected by USB and IEEE1394 devices appear after internal devices. The following code shows how fdisk is used to open the second SCSI or SATA drive, /dev/sdb, to access an fdisk-based command line prompt. From this  prompt, the m command lists basic fdisk commands.

$ sudo fdisk /dev/sdb
Command (m for help): m
Command action

a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition
l list known partition types
m print this menu
n add a new partition
o create a new empty DOS partition table
p print the partition table
q quit without saving changes
β create a new empty Sun disklabel
t change a partition's system id
u change display/entry units
v verify the partition table
w write table to disk and exit
x extra functionality (experts only)

Command (m for help): q

There’s a lot that you can do with the fdisk utility. If you’re interested in fdisk in depth, run the x command to review associated extra functionality.

Posted on: 22/12/2009








0 Comments
If you want to leave a comment please Login or Register
How to backup your data using rsync......
Understanding autoconf......
The Basics of fdisk......
Accessing Memory Using DMA......
The fd Directory......