⇐ table of contents | previous section | next section ⇒
One of the biggest questions while installing Linux is: How should we partion our hard disk? One one hand, the more separate (read-only) partitions we have, the better we can protect the system. On the other hand, more separate partitions mean that we have to estimate our needs beforehand, i.e. now. Making use of Logical Volume Management simplifies matters greatly, since LVM allows us to resize partitions later.
Based on years of experience, wild guesses, trial and error we decide on the following approximate sizes for the primary partitions.
Partition: Purpose: Intended: Actual: Type: /dev/hda1 /boot 8MB 15.49MB 83 Linux /dev/hda2 swap 512MB 541.91MB 82 Linux Swap /dev/hda3 hibernation 590MB 619.32MB A0 IBM Thinkpad Hibernation /dev/hda4 extended rest 05 Extended /dev/hda5 / 64MB 69.68MB 83 Linux /dev/hda6 LVM rest 58765.28MB 8e Linux LVM |
Volume: Purpose: Size: /dev/disk/usr /usr 3072MB /dev/disk/tmp /tmp 128MB /dev/disk/var /var 1024MB /dev/disk/cdr /cdr 1400MB /dev/disk/home /home 10240MB |
Note: The hibernation partition must be a primary partition. Furthermore, making the root partition part of LVM can be dangerous. Also note: Although we ask fdisk for the intended sizes, the actual sizes are slightly larger due to geometric constraints of the drive. Lastly note: It may be a good idea to reserve a large enough partition for the preparation of CD-R images.
To create the hibernation partition, we need to run phdisk.exe from a DOS partition. To this end, we boot into FreeDOS and use fdisk to create the two DOS partitions c: (/dev/hda1) and d: (/dev/hda2) and then format c: and format d:
Partition: Purpose: Intended: Actual: Type: /dev/hda1 DOS 8MB 15.49MB 06 FAT12 /dev/hda2 DOS 512MB 541.91MB 06 FAT16 |
Now we boot the Debian installation system with the bf24 kernel by pressing <F3> at the boot prompt and then follow instuctions to add a preliminary linux partition and install a base system.
Partition: Purpose: Intended: Actual: Type: /dev/hda1 DOS 8MB 15.49MB 06 FAT12 /dev/hda2 DOS 512MB 541.91MB 06 FAT16 /dev/hda3 preliminary any any 83 Linux |
Then we boot into this preliminary system and go through the absolute minimum of configuration and make sure that the scp package is installed. Unfortunately, this leaves us without network configuration. We have to do this by hand.
First we have to edit the file /etc/network/interfaces to configure the ethernet device eth0. We have the static IP address www.xxx.yyy.zzz and our gateway is www.xxx.yyy.ggg.
auto lo eth0 iface lo inet loopback iface eth0 inet static address www.xxx.yyy.zzz netmask 255.255.255.0 broadcast www.xxx.yyy.255 network www.xxx.yyy.0 gateway www.xxx.yyy.ggg |
Now we can start the network by loading the kernel module for the ethernet card and starting the interface.
#> modprobe eepro100 #> ifup eth0 |
Then we mount the first DOS partition c: (/dev/hda1) and download the archive of the hibernation tools from the machine, where we have stored them.
#> mount /dev/hda1 /mnt #> cd /mnt #> scp "user@ip-nr-of-machine:ibm/*" . |
Note: We actually have to use the IP number as we have not configured the resolver for machine names.
Now we reboot into FreeDOS and use fdisk to remove the preliminary linux partition /dev/hda3. Reboot into FreeDOS. At last we are ready to launch phdisk.exe and create the hibernation partition.
Having sucessfully created our hibernation partition, we reboot anew into the Debian installation system and continue partitioning the hard disk. The current partition layout is:
Partition: Purpose: Intended: Actual: Type: /dev/hda1 DOS 8MB 15.49MB 06 FAT12 /dev/hda2 DOS 512MB 541.91MB 06 FAT16 /dev/hda4 hibernation 577MB 619.32MB A0 IBM Thinkpad Hibernation |
We use fdisk and repartition into:
Partition: Purpose: Intended: Actual: Type: /dev/hda1 /boot 8MB 15.49MB 83 Linux /dev/hda2 preliminary 512MB 541.91MB 83 Linux /dev/hda3 hibernation 577MB 619.32MB A0 IBM Thinkpad Hibernation /dev/hda4 extended rest 05 Extended /dev/hda5 / 64MB 69.68MB 83 Linux /dev/hda6 LVM rest 58765.28MB 8e Linux LVM |
Note: To move the hibernation partition, we use the “extra functionality (experts only)” mode of fdisk and then “fix partition order” — preferably before we create any other partition.
We create the filesystems by hand, since we don't need no reserved blocks for /boot and the root filesystem /.
#> mke2fs -m 0 /dev/hda1 #> mke2fs /dev/hda2 #> mke2fs -m 0 /dev/hda5 |
Now we have another problem. We should now define the LVM volume group and create the physical/logical volumes for /usr, /var, /tmp and /home. Unfortunately however, the Debian installation system does not support LVM. For this reason, we use the intended swap partition /dev/hda2 to install a preliminary Debian system without swap partition. As soon as possible, we will compile our custom kernel, setup LVM and then proceed rearranging things into their final layout.
⇐ table of contents | top ⇒
After having partitioned the hard disk and having formatted the partitions, we install a preliminary kernel as well as the base system and reboot, we make use of the good old tasksel and dselect install the following tasks and packages,
Task Development C kernel-source-2.4.18 bzip2 linbz2-1.0 kernel-package libncurses5-dev lvm-common lvm10 ext2resize |
⇐ table of contents | top ⇒
We want put the <Control> in the Right Place™ where God has intended it to be, namely left to the <A> key. The old <Control> should take over as <Compose>. We don't need no <CapsLock>. To achieve this, we copy all the relevant kernel keymaps into /etc/console and modify them accordingly.
#> cd /etc/console #> cp /usr/share/keymaps/i386/qwerty/uk.kmap.gz . #> cp /usr/share/keymaps/i386/include/qwerty-layout.inc.gz . #> cp /usr/share/keymaps/i386/include/linux-keys-bare.inc.gz . #> cp /usr/share/keymaps/i386/include/linux-with-alt-and-altgr.inc.gz . #> cp /usr/share/keymaps/i386/include/euro.inc.gz . #> mv uk.kmap.gz uk-mod.kmap.gz #> gunzip uk-mod.kmap.gz |
Then we modify uk-mod.kmap and set:
keycode 29 = Compose keycode 58 = Control |
Finally we gzip things together again, update the symlink and load the new keymap:
#> gzip uk-mod.kmap.gz #> mv boottime.kmap.gz boottime.kmap.gz.ORI #> ln -s uk-mod.kmap.gz boottime.kmap.gz #> loadkeys boottime.kmap.gz |
Note: We actually have to copy the included maps from /usr/share/keymaps/i386/include since the /usr partition is not yet mounted when the keymaps are loaded at boot time.
⇐ table of contents | top ⇒
We don't want those stupid symlinks /vmlinuz (and later /vmlinuz.old) cluttering our root directory. We remove them and install similar links in /boot. While updating /etc/lilo.conf we activate the compact option to speed up the loading of the kernel image.
#> rm /vmlinuz* #> cd /boot #> ln -s vmlinuz-2.4.18-bf2.4 vmlinuz.old |
compact image=/boot/vmlinuz label=linux read-only vga=normal image=/boot/vmlinuz.old label=backup read-only vga=normal optional |
Now we inform Debian about our changes and create a file describing the kernel image configuration in /etc/kernel-img.conf:
image_in_boot = yes do_bootfloppy = no |
⇐ table of contents | top ⇒
We then proceed to configure and build our own custom kernel using make menuconfig and make-kpkg. Almost any kernel configuration will do as long LVM is supported.
—— Multi-Device Support (RAID and LVM) —— yes Multiple devices driver support (RAID and LVM) yes Logical volume manager (LVM) support |
#> cd /usr/src #> tar xjf kernel-source-2.4.18.tar.bz2 #> cd kernel-source-2.4.18 #> make menuconfig #> make-kpkg clean #> make-kpkg -rev Custom.1 kernel_image #> cd .. #> dpkg -i kernel-image_2.4.18 |
When the new kernel has been installed and lilo been updated sucessfully, we reboot.
Now we are ready to create the physical volume on /dev/hda6, add it to our volume group /dev/disk, create our logical volumes /dev/disk/usr, /dev/disk/tmp, /dev/disk/var and /dev/disk/home and the filesystems in them.
#> pvcreate /dev/hda6 #> vgcreate disk /dev/hda6 #> #> lvcreate -L 3072M -n usr disk #> lvcreate -L 128M -n tmp disk #> lvcreate -L 1024M -n var disk #> lvcreate -L 1536M -n cdr disk #> lvcreate -L 10G -n home disk #> #> mke2fs -j -m 0 /dev/disk/usr #> mke2fs /dev/disk/tmp #> mke2fs -j /dev/disk/var #> mke2fs -j -m 0 /dev/disk/cdr #> mke2fs -j /dev/disk/home |
Now we mount these new partitions consecutively to /mnt and transfer the contents of the respective directories currently residing on /dev/hda2.
#> mount /dev/disk/var /mnt #> cd /var; tar cf - . | (cd /mnt; tar xf -) #> umount /mnt #> #> mount /dev/disk/usr /mnt #> cd /usr; tar cf - . | (cd /mnt; tar xf -) #> umount /mnt #> #> mount /dev/hda5 /mnt #> mkdir /mnt/dev /mnt/cdrom /mnt/cdr /mnt/usr /mnt/var /mnt/tmp /mnt/home /mnt/proc #> mkdir -p /mnt/mnt/cdrom #> chmod 1777 /mnt/tmp /mnt/cdr #> #> cd /; tar cf - bin boot dev etc lib opt root sbin | (cd /mnt; tar xf -) |
Note: Creating the new device directory /dev manually before any other directory might save the day, when some idiot goes for rm -rf * in the root directory. As rm descends the directory tree not alphabetically but in order of creation, /dev will be first to go. But if /dev/hda is gone, rm can't access the disk any more.
After this step, we update the filesystem layout in /mnt/etc/fstab.
/dev/hda1 /boot ext2 defaults,ro 0 2 /dev/hda5 / ext2 defaults,errors=remount-ro 0 1 /dev/disk/usr /usr ext3 defaults,ro 0 2 /dev/disk/var /var ext3 defaults,errors=remount-ro 0 2 /dev/disk/tmp /tmp ext2 defaults,errors=remount-ro 0 2 /dev/disk/cdr /cdr ext3 defaults,errors=remount-ro 0 2 /dev/disk/home /home ext3 defaults,errors=remount-ro 0 2 /dev/hdc /mnt/cdrom iso9660 user,ro,nosuid,nodev,exec,noauto 0 0 /dev/hdc /cdrom iso9660 defaults 0 0 proc /proc proc defaults 0 0 none /dev/pts devpts gid=5,mode=620 0 0 |
Finally we need to update the root device in /mnt/etc/lilo.conf to /dev/hda5, set the new symlinks for the kernel images and rerun lilo.
# /etc/lilo.conf root=/dev/hda5 |
#> cd /mnt #> vi etc/lilo.conf #> cd boot #> ln -sf vmlinuz-2.4.18 vmlinuz #> ln -sf vmlinuz-2.4.18-bf2.4 vmlinuz.old #> chroot /mnt lilo |
After rebooting to switch to the new hard-disk layout we can finally use fdisk to remove our preliminary linux partition /dev/hda2 and replace it with a swap partition. And again we have to reboot to switch to the new hard-disk layout. At last we can activate the swap partition and add it to /etc/fstab.
/dev/hda1 /boot ext2 defaults,ro 0 2 /dev/hda2 none swap sw 0 0 /dev/hda5 / ext2 defaults,errors=remount-ro 0 1 /dev/disk/usr /usr ext3 defaults,ro 0 2 /dev/disk/var /var ext3 defaults,errors=remount-ro 0 2 /dev/disk/tmp /tmp ext2 defaults,errors=remount-ro 0 2 /dev/disk/cdr /cdr ext3 defaults,errors=remount-ro 0 2 /dev/disk/home /home ext3 defaults,errors=remount-ro 0 2 /dev/hdc /mnt/cdrom iso9660 user,ro,nosuid,nodev,exec,noauto 0 0 /dev/hdc /cdrom iso9660 defaults 0 0 proc /proc proc defaults 0 0 none /dev/pts devpts gid=5,mode=620 0 0 |
#> mkswap /dev/hda2 #> swapon -a |
Note: We dont like to have our mount points in the root directory, we want them in /mnt. Unfortunately, Debian insists on /cdrom as the mount point for the installation. We will remove /cdrom and the respective entry in /etc/fstab when we reconfigure apt for network installs and updates.
⇐ table of contents | previous section | next section | top ⇒