Installing Slackware on Logical volumes ======================================= Introduction ------------ For a long time, it has been common for other distros to support installation to Logical Volumes. In Slackware, the installer has never supported this, but the gurus usually would find a way to create logical volumes and install or migrate their Slackware onto those. Having your Slackware installed fully on LVM was near impossible until now. Slackware 12.0 has improved support for LVM built into the installer. Preparing Logical Volumes (LV) ------------------------------ * Existing LV The Slackware installer will recognize and activate any pre-existing Logical Volumes on your hard drive(s). These Logical Volumes will be selectable targets for the creation of the filesystems (like /, /usr, /home, /var) * New LV When you need to create the LV, you need to do this before starting the 'setup' program. You may have to run (c)fdisk first to create the partition you want to use for setting up the logical volumes. For any partition you create and that you want to use for LVM, you should set the partition type to '8e' (Linux LVM). In the next example, I will assume we use a single 10 GB partition '/dev/sda1' for our Volume Group (VG). With LVM, it is possible to use multiple physical volumes (i.e. partitions, whole disks) for a VG, but that is left as an exercise for the reader. You can always add extra physical volumes to your VG later. We will create a VG called 'myvg' and on that VG create two LV's called 'root' and 'usr'. The first is going to contain the root partition ('/') and the second will become our '/usr' partition. After booting your computer from the Slackware CD/DVD/USB, and logging in as root, you run the following sequence of commands to create the Physical Volume (PV), the Volume Group (VG) within that PV and two LV's of size 5GB (root) and 3GB (usr) inside the VG: # pvcreate /dev/sda1 # vgcreate myvg /dev/sda1 # lvcreate -L 5G -n root myvg # lvcreate -L 3G -n usr myvg Next, we create the device nodes needed before activating the volumes, and finally we activate the volumes (the last command is not really needed because 'setup' will run it anyway): # vgscan --mknodes # vgchange -ay This is all we need to do before running 'setup'. Using LVM during setup ---------------------- In setup, when you choose "TARGET" in the main menu, you will notice that the LV's are available in the Linux partition selection. Our two LV's "root" and "usr" are visible as "/dev/myvg/root" and "/dev/myvg/usr". Select the first for your root ('/') filesystem, and the other for your /usr filesystem. Create any filesystem you like on them. My favorite fstype still is ext3, but you can choose xfs or jfs for stability and speed. Setup will proceed as usual, but when you get to the point where you are presented with the lilo configuration dialog, it is almost time to perform one final manual tweak. Proceed with configuring your lilo as usual, and select '/dev/myvg/root' as your root filesystem to boot. However, do *not* install lilo just yet. If you try, it will fail and liloconfig will complain that it could not install and that you are required to install lilo manually. Instead, open a second console by pressing and . We are going to 'chroot' into our fresh installation and setup the LVM device nodes which lilo needs in order to install successfully. While we are chrooted anyway, we will use the opportunity to create a initial ramdisk image (initrd) which is required for a root filesystem which is created on LVM. Run the following commands to "bind" mount the proc and sys filesystems in the chroot, do the actual chroot and finally create the LVM device nodes: # mount -o bind /proc /mnt/proc # mount -o bind /sys /mnt/sys # chroot /mnt # vgscan --mknodes Next, while we are in the chroot, create the initrd with LVM support - in the example command line I assume that the root filesystem is 'ext3', we used the LV '/dev/myvg/root' as the root device, and are running the Slackware 12.0 default SMP kernel '2.6.21.5-smp': # mkinitrd -c -k 2.6.21.5-smp -m ext3 -f ext3 -r /dev/myvg/root -L The resulting initrd image will be written to the file '/boot/initrd.gz' by default. We still need to tell lilo about this initrd, so open the configuration file '/etc/lilo.conf' in an editor such as vi or pico - it should already have been generated by the 'liloconfig' part of setup. Look for the "Linux bootable partition config" and add a line for the initrd - it should look somewhat like this: image = /boot/vmlinuz initrd = /boot/initrd.gz root = /dev/myvg/root label = linux read-only If so, write the changes, exit the editor and (re-) run lilo while in the chroot. Lilo will issue a coupe of warnings concerning a difference in what /proc/partitions reports and what lilo thinks are available partitions, but it is safe to ignore these. You're done in the chroot now. Exit the chroot by running the command 'exit' and return to the setup program awaiting you on the first console. You can now proceed with the remainder of the configuration until 'setup' tells you that it is time to exit and reboot. This is exactly what you are going to do now. Good luck with your Slackware with a root filesystem-on-LVM ! ======================================================== Author: Eric Hameleers 14-jun-2007 Wiki URLs: http://www.slackware.com/~alien/dokuwiki/doku.php?id=slackware:setup Documentation: /usr/doc/Linux-HOWTOs/LVM-HOWTO