Installing Slackware with LVM-partitions

From LQWiki
Jump to navigation Jump to search

Installing Slackware with LVM-partitions

Here's a quick guide on how to install slackware 10.2 with a lvm-partitions. Although this is written to 10.2 it should work with 11.0 with small modifications, mainly on package versions.

This guide doesn't include on how to move the root to lvm-partition as that requires a special initrd image to allow it to boot but I'm working on it with the Nemonico.


1) Boot from Slackware CD. I use the test26.s but you can use the 2.4 kernel too but that part isn't ready yet.

2) After boot you need to create the partitions as normal. You need to create the LVM-partition with the fdisk (type 8e)

3) Create and mount a temporary RAM-disk and move some of the largest folders in there

mkdir /ram
mount -t tmpfs none /ram
mv /sbin /ram
mv /bin /ram
mv /lib/modules /ram
/ram/bin/ln -s /ram/sbin /
/ram/bin/ln -s /ram/bin /
/ram/bin/ln -s /ram/modules /lib

4) Install device-mapper, lvm2, kernel-modules-2.6 and module-init-tools packages.

5) Create the necessary files so you can load the correct modules

echo "/lib/modules/2.6.13/kernel/drivers/md/dm-mod.ko" >> /lib/modules/2.6.13/modules.dep

6) Load the dm-mod module

insmod /lib/modules/2.6.13/kernel/drivers/md/dm-mod.ko

7) Start setup and follow it until you see the filesystem summary window and then switch to another console (ALT-F2).

  The setup program should have created your /boot / and swap partitions now and mounted them under /mnt by this point
  It's necessary to switch to another console at this point as after pressing ok on the summary window the setup utility
  installs some files to /mnt/var which can make creation of new LVM /var partition slightly harder.

8) Create the LVM-partitions (The commands could give some error messages but you can ignore them)

vgscan
pvcreate /dev/sda3
vgcreate /dev/sda3 vg
lvcreate -L1G -nusr vg
lvcreate -L1G -nhome vg
mkreiserfs /dev/vg/usr
mkreiserfs /dev/vg/home

9) Mount the LVM-partitions under /mnt

cd /mnt
mkdir home usr
mount /dev/vg/usr usr
mount /dev/vg/home home

10) Switch back to setup program (ALT-F1) and continue normal installation process until the end but don't reboot yet


11) Chroot to new slack installation

mount --bind /dev /mnt/dev
mount -t proc proc /mnt/proc
chroot /mnt
source /etc/profile

12) Mount the cdrom and install following packages: device-mapper, lvm2 and kernel-modules-2.6

13) Run 'vgscan' as it will create the lvm.conf file to /etc if I remember correctly

14) Configure fstab to include the lvm-partitions

/dev/vg/usr   /usr   reiserfs   defaults 0 0

15) Install / Configure Grub / LILO if necessary

Note that if you use lvm on your root partition you need to have initrd to enable lvm during boot.

Hope this helps you in installing Slackware with LVM:s. I usually install it so that I have /usr, /var, /tmp, /opt and /home in a LVM-partition.

LVM's are also handy with the DM-Crypt encryption as you can have separate partitions but only a one passphrase to open them. Example the above setting would require a 6 passphrases if all partitions were normal encrypted ones.

If you're looking to use the Cryptsetup with LUKS, check out the Nemonico.