If you a looking for a tool to modify Partitions of a drive that is already in use (and you don't want to lose the data on the partitions), you could use the proprietary (but very good) PartitionMagic, the Free tool parted(8) or GParted which is available as a live CD which reduces the risks from running an OperatingSystem at the same time as partitioning.

If you want to reduce the size of a Windows partition, it is worthwhile running scandisk and defrag from within Windows, and backing up all your data, before resizing the Partition.

A modern distro with a fairly full desktop install will take around 2 to 3 GB of disk space. Allow some room for your /home files, and you will need to free up at least 5GB for the Linux partition.

For a thorough explanation of partitioning, read the Linux Partition HOWTO.

A modern Linux distribution such as Ubuntu Hoary or Mandriva should let you do partition resizing in the installer.

You may also want to read a mini howto on swap someone wrote.

Simplest Setup

You can set up Partitions as complicated or as simple as you like. The simplest setup is a swap partition (size as twice your RAM up to about 1GB) and the rest of the drive as a single partition mounted on / .

Dual Boot Suggestions

When trying out Linux, most people run dual boot so they can continue to use their Windows system. A basic partitioning scheme for a 40GB hard disk might look like this.

 Partition   Type   Size   Linux Mount Point 
 hda1   ntfs   30GB   /mnt/Windows 
 hda5   ext3   7GB   / 
 hda6   swap   500MB   swap 

If you are using dual boot, you may want to move files between Linux and Windows. However, Linux cannot write to ntfs and Windows cannot read or write to the Linux partitions. A solution is a FAT partition, which both systems can read and write to. This example is for a 60GB hard disk. Windows will see the FAT partition as drive e: or f: or similar.

 Partition   Type   Size   Linux Mount Point 
 hda1   ntfs   40GB   /mnt/Windows 
 hda5   ext3   10GB   / 
 hda6   swap   500MB   swap 
 hda7   fat   6GB   /mnt/fat 

Multiple Partition Example

Setting up additional partitions can provide worthwhile benefits in some cases.

hda1: /boot (32-64MB)

Historically LILO could not read past 1024 cylinders, so people created their first or second partition as /boot. While this limitation has been lifted, a separate /boot is still a good idea. It lets you to mount your /boot as read-only, which protects your all-important Kernel from being accidentally blown away by careless fingers. It also lets you stick to using Ext2 for /boot while using Ext3 or some other more advanced FileSystem on your root partition.

hda2: swap (128-256MB)

Older Linux Kernels could not use more than 128MB of swap in a single partition. New kernels do not have this limitation, but you shouldn't have more than about 256MB of swap (128MB is probably enough really). If you find yourself running into swap a lot you should buy more RAM. Swap is not a substitute for RAM, it is a safety zone so that your system doesn't run out of RAM and trigger the dreaded OomKiller. It is also used as a place to swap out rarely used chunks of RAM (ie all those getty(8)s you still have running while you're in X).

hda3: / (1-4GB)

The root partition, which is where everything gets chucked on a workstation. The biggest area of your root partition will be /usr or /opt. How big you make this partition all depends on what apps and packages you will be installing.


The PC BIOS only supports 4 primary partions, so your 4th primary becomes an extended partion which covers the entire remaining portion of your disk.

hda5: /usr/local (1-2GB)

This is where you can build and install Packages from source TarBalls. Everything outside of /usr/local should be managed by PackageManagement.

hda6: /home (the rest of the drive)

All your user accounts, warez, pr0n, mp3s etc. :)

This is a good layout for a personal workstation as it ensures that all your user data is on another partition safe from OperatingSystem upgades.

Servers on the other hand should have a slightly different layout. Generally they also have the following partitions:

/tmp, /var/tmp (256-512MB, maybe more)

Make sure these partitions are large enough, but don't waste too much space on them. Having a separate partition for them is good, because the turnover of files is very fast, which leads to fragmentation. It also helps, because they are problematic since everyone can write there. A separate partition ensures that people cannot overflow important partitions by filling the temp space with crud. It also allows using separate mount(8) options such as noexec and nosuid which prevent people from creating executable files. Be careful.

/var (512MB-1GB)

This is the variable data area is where logs and other files important for system auditing and monitoring are stored. Make sure this partition is large enough so there is always enough space on /var for your log files to continue being written to. Take as many steps as possible to protect these files: areas like /var/spool or /var/imap should have their modes/attributes changed to try and ensure there is no data lost on server failures. Investigate the sync mount option and the chattr(1) command.

/usr (whatever your feel is adaquate/sufficient for your situation)

To add additional protection to your applications from system crackers you can mount your /usr partition readonly.

Mounting partitions

There are a number of ways you can address partitions within linux. You can either use the raw device name, eg /dev/sda1, or you have the option of setting a label on the partition, or using the partition's UUID.

In most cases the raw device name will do, but there are some situations in which this is less than optimal. The SCSI/SATA layer, for example, creates devices in the order they are detected, with an incrementing device name /dev/sda, /dev/sdb etc. If devices are reordered they will get a different device name. Devices might be reordered due to controller changes or scan order changes - IDE will suffer the same problem here - or they might change due to a device disappearing (for example, if you remove a faulty disk from a RAID set).

Another situation in which this can occur is if you use external storage devices, such as flash disks, external harddrives or digital cameras. If you don't plug them in in the right order, they'll end up with different device names. This is ok if you do all your mounts manually, but if you want to use fstab to remember things then this just won't work.

Disk labels provide one way of abstracting the partitions away, however they cannot be guaranteed to be unique for a system. Consider what might happen if you have a system installed using labels, with labels like ROOT, VAR, USR etc, and then you put another disk into your machine with the same labels. Which ones get mounted? This isn't such a contrived example - some linux distributions will label partitions for you, eg RedHat.

The partition UUID is guaranteed to be universally unique, and will always point to the same partition. UUIDs are supported on all (AddToMe: check this) filesystems linux supports, including swap and vfat.

To find out the UUID of an existing partition, use the blkid program that comes with e2fsprogs.

To specify a UUID or a label in your /etc/fstab, replace the device name (eg, /dev/sda1) with UUID=..... or LABEL=....

Another option for persistent mount points is to use udev to match on some other criteria, eg a USB serial ID for a particular external enclosure. This makes sense if you change the physical drive in the enclosure but still want it to mount to the same place