2. Partitioning
2.1. Swap
Use /dev/hda2 for the Linux swap partition. It is
usually recommended to have a swap partition 2x the size of physical RAM.
So, if you have 1GB RAM, make a 2GB swap partition.
2.2. Root Partitions
You'll want at least two root
partitions so you can install a new version of the distribution, a different
distribution, or a new build (or example, the next beta) without losing the
Linux system you currently use. This way you can always instantly rollback
to the previous system without loosing any data. Depending on the size of
your hard disk, you'll probably want to make these partitions 5 to 10 GB
each.
2.3. Data Partition
Create one more Linux partition
consuming the remainder of the hard disk. This is where data will be
stored so that it will not be lost when the OS is reinstalled onto one or the
root partitions, and so that multiple systems can share the same data.
2.4. Variations
You can have other partitions if you
like. Perhaps you want to have a separate partition for VMWare
images. This isn't really necessary though since everything can be lumped
under the Data partition, and symbolic links can be used if you want things to
appear to be somewhere else. If you want to share data between Linux and
Windows, you may need an extra FAT32 partition. Linux can read from NTFS
volumes, but not write to them (last time the author checked). By having
an extra FAT32 partition (drive D: on Windows), you can put data on this
partition and access it from either Windows or Linux.
2.5. Partition Table Summary
Once finished
partitioning, your partition table might look like this (output of fdisk -l
/dev/hda):
Device Start End Blocks Id System
/dev/hda1 1 xxxxx 18000000 7 HPFS/NTFS
/dev/hda2 xxxxx xxxxx 2000000 82 Linux swap
/dev/hda3 xxxxx xxxxx 10000000 83 Linux <-- root 1
/dev/hda4 xxxxx xxxxx 50000000 5 Extended
/dev/hda5 xxxxx xxxxx 2000000 c W95 FAT32 (LBA)
/dev/hda6 xxxxx xxxxx 10000000 83 Linux <-- root 2
/dev/hda7 xxxxx xxxxx 10000000 83 Linux <-- root 3
/dev/hda8 xxxxx xxxxx 28000000 83 Linux <-- data
If you don't have Windows installed, it might look like this:
Device Start End Blocks Id System
/dev/hda1 1 xxxxx 2000000 82 Linux swap
/dev/hda2 xxxxx xxxxx 10000000 83 Linux <-- root 1
/dev/hda3 xxxxx xxxxx 10000000 83 Linux <-- root 2
/dev/hda4 xxxxx xxxxx 68000000 5 Extended
/dev/hda5 xxxxx xxxxx 10000000 83 Linux <-- root 3
/dev/hda6 xxxxx xxxxx 58000000 83 Linux <-- data
4. Fixing the Bootloader
You need to move the bootloader files to the
data partition, since this partition won't be formatted again, but our Linux
root partition will eventually be reformatted and reinstalled. The MBR
needs to point to GRUB files that won't be destroyed during future reinstalls.
4.1. Move Bootloader Files
Create a directory
/data/boot. Copy the files stage1, stage2, and
menu.lst from /boot/grub to /data/boot:
cp /boot/grub/{stage1,stage2,menu.lst} /data/boot/
Now launch the GRUB shell (type grub) and enter the
following command:
install (hd0,7)/boot/stage1 d (hd0) (hd0,7)/boot/stage2 (hd0,7)/boot/menu.lst
You may have to adjust this command based on which partition is
/data. Note that GRUB partitions are zero indexed, so /dev/hda6 is (hd0,5), and
/dev/hda8 is (hd0,7). Within the GRUB shell, type help install
for more information.
4.2. Install GRUB in the Boot Sector of the Root
Partition
Now, assuming the root partition is /dev/hda3, type:
grub-install /dev/hda3
You may be confused why you
installed GRUB into both the MBR, and the boot sector of the root
partition. In the next step, you'll configure the bootloader in the MBR to
"chain" to the various Linux systems.
4.3. Edit the Boot Menu
Edit
/data/boot/menu.lst. The only menu items should be a series of
"chainloader" directives, and possibly an item to launch future network installs
without a CD. For example:
title Windows XP
chainloader (hd0,0)+1
title Linux on hda3
chainloader (hd0,2)+1
title Linux on hda6
chainloader (hd0,5)+1
title Linux on hda7
chainloader (hd0,6)+1
title Install
root (hd0,7)
kernel /boot/linux.inst install=ftp://<your_net_install_path> vga=791
initrd /boot/initrd.inst
4.4. Booting the Linux OS
Now when you boot the system
you will see a menu containing Windows (possibly), several Linux systems, and
possibly an install option. When you select a Linux system, you are faced
with another GRUB menu. This is the only drawback of this system -- there
is an extra delay in the boot process because the first GRUB menu leads to
another GRUB menu. This problem can be minimized by decreasing the delay
in the second GRUB menu (the GRUB menu for each Linux system).
5. Home Directory Maintenance
One might ask, "Why not just make /home a
separate partition, instead of making a separate /data partition?" The answer is
simple, though unfortunate. There are user-specific configuration items
stored in "dotfiles" (filenames starting with '.') in each user's home
directory. For example, all KDE preferences are stored under the directory
$HOME/.kde/. These files are often not backward compatible
between versions of applications. The preference files in
$HOME/.kde/ for KDE 3.2 are probably not compatible with KDE 3.3.
This is even more true for Desktop preference files between different Linux
distributions.
5.1. Setup the Data Partition
While logged in as root,
create a directory under /data for each user, and chown the directory to that
user.
mkdir /data/djones
chown djones /data/djones
You may also want to chmod the directory to mode 700 to give it
greater protection. Now log in as the non-root user, and create a
directory /data/djones/.etc. Move selected dotfiles from $HOME to
this directory. For example, .ssh, .vmware, and .vslick.
mv $HOME/{.ssh,.vmware,.vslick} /data/djones/.etc/
If these dotfiles don't exist yet, create empty directories in
/data/djones/.etc/ instead of moving existing directories there. The idea is to
select dotfiles which are known to maintain the same format and syntax between
versions of the application, and which are painful to lose (such as .ssh).
Through experience you will learn which dotfiles can safely be used across
multiple versions of multiple distributions.
5.2. Symlinking to the Data Partition
As the non-root
user, create a symbolic link from $HOME to the data partition, and then symlink
the dotfiles back to $HOME:
ln -s /data/djones $HOME/data
cd $HOME
ln -s data/.etc/.[a-z]* .
You may need to remove the corresponding existing dotfiles from
$HOME before doing this.
5.3. Using the Customized Home Directory
Put files
that you want to be persistent across reinstalls under $HOME/data.