Running Slackware Linux on Hyper-V: Pro Tip
Over the past few weeks I've been working on a Linux project. My project isn’t complex just a new application server that will be running within a Hyper-V VM. Slackware is my distro of choice and I was happy to see that the latest versions supported Hyper-V.
As part of my testing I installed Slackware 14.0 on my server and installed and ran like a champ. Of course when Heartbleed got fixed I figured it was time to upgrade my project to Slackware-current (14.1) and that is when things got interesting.
I spent the better part of 8 hours trying to figure out why Slackware 14.1 would install on my Hyper-V machine but would not run after the initial install (eg first reboot) . The log showed a kernel panic and basically froze. As it would turn out the Hyper-V modules were not loading in the correct order and when the Kernel tried mounting /dev/sda2 (my root partition) saying it couldn't find it.

Turns out the fix is pretty simple and I'm here to pass along some information.
Some background on my setup:
Windows Server 2008 R2 running Hyper-V
Slackware 14.1
VM using two cores and 24GB virtual drive
I'm using XFS as my filesystem and have swap space at /dev/sda1
The error I was getting was somewhat cryptic"kernel panic - not syncing : VFS: unable to mount root FS on unknown-block"
Basically the error is saying that the system cannot mount the root filesystem as indicated in Lilo. You could have a similar situation had this been a RAID or a new disk using a different filesystem. To resolve this issue I needed to create and load an Init Ramdisk (initrd.gz) that contained the driver modules needed to load the root FS.
Here is the process to follow:
- Boot the system using the install disk and login as root.
- Mount the target partition "mount -t xfs /dev/sda2 /mnt"
- Set /mnt to root "chroot /mnt"
- Change directory to "/boot"
- Make the initrd, There is a helper script to get you started but for Hyper-V it doesn't apply since you need to load the Hyper-V system bus and storage service (hv_vmbus hv_storvsc) to load the drive, use the following command "mkinitrd -c -f xfs -r /dev/sda2 -m hv_vmbus:hv_storvsc:mbcache:xfs -u -o /boot/initrd.gz"
- If your kernel version is different from your boot media add -k [kernel version] (ex '-k 5.4.38') to the build string.
- Add this to lilo.conf by adding "initrd = /boot/initrd.gz" right after the boot image line
- Run "lilo" to set the configuration
- Reboot
- Update (5/3/20): I was testing out Slackware64-Current (Slackware 15) and kept getting an memory allocation error when mounting the drives on boot. The fix was to change vmlinuz (symlink to -huge) to vmlinuz-generic in lilo.conf.
They say you can recompile the Kernel to include Hyper-V support however, considering that both vmlinuz-generic and vmlinuz-huge kernels include support as modules you shouldn't need to. The difference is that "huge" loads all of the drivers and is why I could install the OS on my VM. When the system rebooted it switched over to "generic" and just didn't load the modules in time.
Overall I'm just happy that I got it working and am still confused as to why Slackware 14.0 worked out of the box and why Slackware 14.1 failed.