Installing Slackware with LVM/LUKS

24 October 2022

Slackware 15 got released this year. It has been a very long time since I last messed around with it. Lets install it on our primary machine :)

LUKS - Linux Unified Key Setup is a disk encryption spec and LVM - Logical Volume Manager is a software abstraction layer on top of partitions/disks that make them easier to manage. I'm going to install slackware on my laptop and encrypting our disk makes sense as there's a good chance the machine could get stolen.

I'll be using an unencrypted /boot partition, as the default bootloader in slackware - LILO does not support booting a LUKS container. There are plenty of tutorials on setting up grub2 for this purpose. SlackerNET UK has an amazing video guide on this.

Booting the live media

Booting the live media will bring us to this familiar screen where we are asked which kernel we want to boot. Hit Enter!

We are then asked to choose our keyboard layout. We may choose, but we'll hit Enter!

Now we login as the user root. Type in root and hit Enter!

After which we are greeted by the shell

Setting up our disk

My machine's disk is /dev/sda. To find yours, try running

# fdisk -l
# or
# lsblk

Assuming my disk is 40 GB, our plan is to allocate the first 1 GB to the boot partition and then use the rest for the main linux partition.

# cfdisk /dev/sda

Confirm just once again to see if our disks are correct with

# fdisk -l

Setting up disk encryption

In our case, /dev/sda2 is our main linux partition. Technically, we wont be using it as a partition, rather like another disk/volume.

# cryptsetup -s 256 -y luksFormat /dev/sda2

Type YES, in all caps and give it a password. Do not forget this password!

Now, on to partioning our disk. Here, we're going to give 2GB to swap and the rest to the root partition.

# cryptsetup luksOpen /dev/sda2 sda2crypt

Input the password that we previously set. This will make our encrypted disk available on /dev/mapper/sda2crypt.

Now onto creating volumes.

# pvcreate /dev/mapper/sda2crypt
# vgcreate lc230vg /dev/mapper/sda2crypt
# lvcreate -L 2G -n swap lc230vg
# lvcreate -l 100%FREE -n root lc230vg

Now we let lvm know about our volumes

# vgscan --mknodes
# vgchange -ay

Setup our swap volume with

# mkswap /dev/lc230vg/swap

Starting the installation

Run setup from the shell and we'd see this

Please take a moment to read how to navigate the program.

Adding swap

Choose ADDSWAP and then let the installer find our swap partition. In our case, /dev/lc230vg/swap. Ignore the screenshot stating t430vg.

It'll then ask us if we want it to scan the partition for bad blocks. Feel free to say YES

After thats done, we'll see our swap space configured.

Adding the root partition

Select /dev/lc230vg/root as the partition we want to use for root (/)

Choose ext4 as the filesystem.

Adding the boot partition

Select /dev/sda1 as the next partition we want to use

Format with ext4 and set its mount point as /boot

Choose done adding partitions, continue with setup in the next step

And now all our partitions are ready!

Selecting software sets

Please take a moment to read the screen.

I usually skip KDE. If you're a KDE fan, have it selected. Hit Enter and you'd be asked to choose a prompting mode. Choose either terse or full here and start the package sets installation.


Skip making a USB boot stick

Now we are asked to install LILO, the linux loader. This is the boot-loader that slackware uses instead of GRUB by default.

Choose expert mode.

We'd see the LILO installation screen.

Choose Begin

You can enter nothing in the optional lilo append parameters screen

For the framebuffer console config, I usually leave it at standard

Set the lilo target to MBR

Check if lilo found our disk. /dev/sda in our case.

Choose lilo timeout.

Choose to show a boot screen logo. Highly recommended!

We'll be then brought back to the initial LILO installation screen.

Choose Linux - Add a linux partition to the LILO config

and then choose /dev/lc230vg/root

Set a name like Linux for the entry

After that LILO setup should be done.

Now, it'll ask us if we want GPM. This would allow us to use a mouse cursor from the tty.


The next step is configuring our network

Choose YES

Set a hostname(lc230) and then a domain name(localdomain would do fine.)

Next we are asked to configure VLAN. Choose NO

Then select NetworkManager to manage our network.

and voila we have our network configured. Choose YES to have NetworkManager manage our network by default in the next screen.

Startup services

I usually unselect sshd here as this is a desktop and not a server.

System clock

Set it to your local timezone

Now we are asked to select an editor. Go with the default nvi

Window manager

I choose fluxbox here. Feel free to choose whatever you like. If you have KDE installed, that should come up here.

Root password

Set one up in this screen

Setup complete?

We'll be brought back to the first screen of setup. Choose Exit

and then drop to a Shell

Now we're going to go back into our installation.

# chroot /mnt

We need to generate a generic kernel. To do that run,

# /usr/share/mkinitrd/

This will return us a command that we can run to generate the GENERIC kernel specific to our machine. For me it was something like,

# mkinitrd -c -k 5.15.19 -f ext4 -r /dev/lc230vg/root \
    -m jbd2:mbcache:crc32c_intel:crc32c_generic:ext4 \
    -C /dev/sda2 -L -u -o /boot/initrd.gz \
    -h /dev/lc230vg/swap

The -h /dev/lc230vg/swap notes the swap partition to enable hiberation.

The format is usually something like this

mkinitrd -c -k *insert kernel number* -m *insert ROOT file system type
here* -f *insert root file system type here* -r /dev/cryptvg/root -C
/dev/sdx2  -h /dev/cryptvg/swap -L

Edit lilo's config to make it use this new generic kernel

# vim /etc/lilo.conf

Edit the corresponding parts to look like this

image = /boot/vmlinuz-generic-5.15.19
 initrd = /boot/initrd.gz
 root = /dev/lc230vg/root
 label = Linux
 read-only  # Partitions should be mounted read-only for checking

Above that, there's an "append" line. Edit it to look something like this,

append = " resume=/dev/lc230vg/swap"

Now we update lilo with

# lilo

Ctrl + D out of our chroot shell and then reboot

First boot

We'd be greeted by lilo

Hit Enter.

After our boot process starts we are asked to unlock our disk. Enter the password that we chose for encrypting our disk.

And then we are put at the login prompt. Enter root and the password we chose for root.

Type startx and behold

In the next post we'll look into post installation steps for our brand new slackware install.

Troubleshoot booting problems

Boot the slackware DVD or any modern linux distro live-cd. system-rescue is a fantastic choice!

# cryptsetup luksOpen /dev/sda2 sda2crypt
# vgscan --mknodes
# vgchange -ay
# lvscan
# mount /dev/lc230vg/root /mnt
# mount /dev/sda1 /mnt/boot
# mount -o bind /proc /mnt/proc
# mount -o bind /sys /mnt/sys
# mount -o bind /dev /mnt/dev
# chroot /mnt

After fixing our issues, exit the chroot with Ctrl+D and

# umount -R /mnt

Then reboot!

Thanks and credits

Happy Slacking & have a great day!