Viewing and Planning Partitions

If you are dual-booting Windows and Linux, you may wish to be able to access your Windows filesystem from Linux. For the most part, this is fairly trivial. Basically, it involves ensuring that kernel support is present for the filesystem type that you wish to be able to mount.

How Can I See My Windows Partitions From Linux?

If you are dual-booting Windows and Linux, you may wish to be able to access your Windows filesystem from Linux. For the most part, this is fairly trivial. Basically, it involves ensuring that kernel support is present for the filesystem type that you wish to be able to mount.

For example, to be able to mount a Windows filesystem, you may need to have any of NTFS, MSDOS, or VFAT support built into your system, depending on which version of Windows you have. If your system is running Windows 3.1, then MSDOS is probably what you’re after. If you are running Windows 9x or ME, go for VFAT. (VFAT is pretty much MSDOS with the capacity to support long filenames. In an emergency, you can mount a VFAT drive as though it were an MSDOS drive.) For Windows NT, XP, or 2000, use NTFS.

If all else fails, you can use fdisk to check. This is done, as root, by typing the following:

# fdisk /dev/device

where device represents the drive holding the partition you’re after. This would be hda for a primary IDE drive. Alternatively, if you mean the secondary IDE drive (on the primary controller), then it would be:

# fdisk /dev/hdb

or the primary IDE drive on the secondary controller:

# fdisk /dev/hdc

and so on. If you’re using SCSI, then a similar regime of naming would apply, starting at /dev/sda.

Within fdisk, you will get a prompt that says something like:

Command (m for help):

Simply type p and press enter:

Command (m for help): p

This will display something like what you see in Listing One. Armed with this information, quit fdisk by typing q and pressing enter:

Listing One: List of Partitions

/dev/hda1*15224192933+7Win95 FAT32 (LBA)
/dev/hda396999924897682Linux swap

Command (m for help): q

Note that although fdisk prints out “Win95 FAT32″, this is actually a VFAT partition. Next, check to see if your Linux system has support for the Windows filesystem you need:

# cat /proc/filesystems

You’ll see output like this:


This is a list of all the filesystem types that your current kernel is able to access. If you see the filesystem you need, skip ahead to the discussion of mounting the filesystem.

Let’s say you want to look at a VFAT filesystem. You may have the correct vfat.o kernel module on your disk but not loaded into memory.

To check if it is loaded, type the following command:

# modprobe vfat

If this succeeds, you’re ready to mount the filesystem. Otherwise, you’ll have to compile the correct module or recompile your kernel to provide built-in support.

This is done by adding VFAT, NTFS, or MSDOS support (as appropriate) under “File systems” in the kernel configuration options. Recompiling the kernel or its modules is beyond the scope of this column. If you need further information on how to do this, you can take a look at the Kernel HOWTO (http://www.linux.org/docs/ldp/howto/Kernel-HOWTO.html).

Now it’s time to mount the filesystem. Let’s say you want to mount it under the /windows directory and it’s a VFAT partition:

# mkdir /windows
# mount -t vfat /dev/hda1/windows

Now all of your files should be available via /windows. There are a few quick caveats:

  • If you mount a VFAT filesystem using the -t msdos option, you won’t be able to use anything outside of the 8.3 file naming convention (i.e., long filenames are mangled into 8.3 format).

  • NTFS partitions will be read-only. (There are some experimental drivers to let you write to it, but this is extremely hazardous.)

How Do You Recommend I Partition My Hard Drive?

Partitioning is really a question of choice. If you’re a new user, you might want to stick to having two simple partitions — one partition for your data/operating system and one partition for the swap space.

This configuration has a number of advantages and drawbacks. One advantage is that you’ll always have a single lump that includes all of your spare disk space. If you’re planning on moving large files around, this means you’ll always be covered. This may also be very important if you’re running on a smaller system, such as a laptop or an older machine with little disk space.

However, there are a number of good reasons that users might want to branch out to multiple partitions, and multiple drives especially. Performance and security are at the forefront of these considerations.

First, let’s talk about performance. This will mainly apply to multiple drives but has very practical implications on partitioning decisions also. If you have the benefit of, say, two hard drives, it would be a much better idea to have your swap space on a disk completely separate from your operating system. With a separate drive, using swap memory won’t thrash the drive that you’re currently trying to access. When talking about filesystem performance, it’s often best to think of it in purely physical terms.

For those who are unsure of hard drive design, follow this simple exercise: Grab a pen and a CD. Put your finger in the middle of the CD, such that you can spin it with your other fingers. (If you can get it to spin more than a few inches, congratulations; please bear with us.) Now, hold the pen halfway between the center and the edge of the CD. The pen is constrained to move either toward the center or the edge of the disc.

Now, think of the tip of the pen as the drive head and the CD itself as the drive platter. Data is stored in concentric circles around the center of the platter, so the further that the head (or pen, in this case) has to move to get to an outer cylinder, the longer it will take to access data.

So, thinking in physical terms, your aim is to minimize the number of movements the drive heads have to make. This is the major reason for defragmenting a drive. It moves all data into consecutive blocks so it’s faster to read.

From this, you can determine that it’s better to have the Linux swap partition and the operating system partitions closer together if you’re making a dual boot system. (For example, Partition 1: Swap; Partition 2: Linux; Partition 3: Windows, instead of Partition 1: Swap; Partition 2: Windows; Partition 3: Linux).

It is best to split the operating system and the data into separate drives, but this is not always an option. From a security perspective, there are a number of options that you’re able to pass to the kernel for handling separate partitions at mount time. A few of these include:

  • No one may execute software on this partition.

  • No software that changes its user ID to the superuser may run on this partition.

  • The partition is read-only.

For example, you might like to separate /tmp and /var/tmp, making them noexec, nosuid, making it impossible to run compiled applications on them. However, this would not stop someone running /usr/bin/perl on their script.pl file. Or, you might like to protect /sbin with the ro option to make it read-only. To try these, when mounting a partition, type:

# mount /dev/hda5 /tmp -onoexec,nosuid

Alternatively, these options can be added to /etc/fstab.

A final circumstance that might lead you to partition your drive is if you are not using disk quotas. In this case, it might be a good idea to ensure that users are confined to a single partition so they cannot cause the whole system to run out of space.

If possible, split partitions and split drives. Mix and match, there is no set formula. Feel free to find your own preferred method.

Quentin Cregan is a tech and security consultant and sometime student hailing from Australia. He can be reached at qc@sensed.com.

Comments are closed.