Reading Partitions

Reading Partitions

If you’ve been a bit intimidated by Linux’s rather cryptic command set, you’re not alone. However, if
you’ve used DOS commands in Windows, you might be surprised to find a few commands in Linux that are
similar to those in DOS. One of those commands is fdisk.

Like the DOS version, fdisk in Linux is, fundamentally, a partitioning tool. Rich with command options,
fdisk allows the root user (remember – prudence) to view, modify, create, and delete partitions on a
hard drive with relative ease and complete control.

That said, most Linux distributions handle partitioning in a much easier fashion. There are several fine
graphical partitioning tools built into the install process of RedHat, Mandrake, Suse, and Caldera. With
such strong programs utilized during install, partition changes are seldom necessary for a normal Linux
user.

Fdisk does have some value as an addition to a process I wrote about last week – mounting Windows
partitions in Linux. When used as root (with prudence!) with the -l option, fdisk will list every
partition on every hard drive, along with the partition types and sizes. This is incredibly useful when
attempting to mount a Windows partition other than C:. By way of example, here’s the output on my
machine from the /bin/fdisk -l command:

Device Boot Start End Blocks Id System
/dev/hda1 * 1 821 6594651 b Win95
FAT32
/dev/hda2   1015 4865 30933157+ f Win95
Ext’d (LBA)
/dev/hda3   822 949 1028160 83 Linux
/dev/hda4   950 1014 522112+ 82 Linux
swap
/dev/hda5   1015 2311 10418121 83 Linux
/dev/hda6   2312 4865 20514973+ b Win95
FAT32

As you can see, Linux fdisk displays the device name in the left column, boot, geometry and system id
information in columns 2-6, and the system type in column 7. You’ll notice that Win32 partitions are
referred to as Win95 FAT32. You’ll also notice that the extended Windows partition is listed as
/dev/hda2 ([h]ard [d]rive [a], [2]nd partition). This numbering convention has been known to confuse new
Linux users – myself included! My D: partition is actually listed as /dev/hda6, because it’s located
behind the C:, Win Extended, Linux /boot, Linux Swap, and Linux / partitions. So, if I wanted to mount
my D: partition, I’d issue the following command (assuming I’ve already created a mount point called
/mnt/wind):

    mount -t vfat /dev/hda6 /mnt/wind

And there you have it – a new tool with an old name to help you read your Windows partitions in Linux.

And, by the way – using root to fdisk with the -l option is pretty safe. The option actually tells
fdisk to print the partition information to the screen and exit!

Article Written by