Bios-legacy + UEFI Slackware64-current installation to USB drive using Bootstrap
The following guide is a practical, step by step example on how to create a Hybrid UEFI/Bios legacy Slackware64-current USB system using a bootstrap/network installation.
This will not generate a system that's bootable in a secure boot manner. Set secure boot to "Disabled/Other OS" to make this system start up. If someone with the skill and knowledge on how to sign the bootloader and kernel pieces wants to chip in, please do so by all means in a reply. I'm not looking for a MOK (Machine Owner Key) signed solution, because the whole goal here is to have a portable system that you can boot on a wide variety of machines. Make sure that you use a USB 3.x device for this installation. Slackware is quick on slower hardware, but you'll be wasting so much time and the system will be sluggish once it's installed. Without further ado, let's get started shall we? Commands listed below should be run as root. Create a directory for the slackware bootstrap: mkdir slackware; cd slackwareGrab Slackware's latest initrd image to acquire the minimal system: wget https://mirrors.slackware.com/slackw...nux/initrd.imgExtract the image: xz -dc < initrd.img | cpio -idmvSet up the destination device (/dev/sdc in this case, adjust accordingly) correctly for all further intends and purposes: echo "export DUSB=/dev/sdc" > ./root/.bashrc; source ./root/.bashrcMake sure the destination drive is not mounted at all: umount ${DUSB}*Wipe the destination drive (sdc in this instance, adjust this for your disk). Be mindful and careful that you've entered the proper disk, don't wipe your system disk by mistake!: sgdisk -Z $DUSBCreate the proper GPT partition table: sgdisk --clear \Reload the drive and check the disk's partition layout: partprobe $DUSBFormat the EFI and Root partition: mkfs.fat -F32 ${DUSB}2Prepare for chroot: for d in dev sys proc; do mount --bind /$d ./$d; doneAnd chroot into the minimal Slackware system: chroot ./ /bin/bashStart the Slackware setup: setup- Skip setting up swap - Pick partition 3 of the destination drive as the root partition, no need to format it - Choose install from FTP/HTTP server Pick your favorite local mirror, I used: https://ftp.nluug.nl Fill out the proper source directory (check the url to see if it matches first): /os/Linux/distr/slackware/slackware64-current/slackware64/ Alternatively you can just copy the "packages" directory into the root installation folder and point the installer to these packages. You will have to download everything first of course, but it will be quicker. Install Slackware as you see fit. Do make sure that Grub gets installed. You can safely ignore the TLS warnings that wget returns. Complete the setup without installing the (E)LILO bootloader. Upon exit select to *not* reboot and drop back to the root shell. Exit the initial chroot environment and chroot to the new installation: exitLet's set up a swapfile: fallocate -l 4G ./swapfileAdd the swap space to fstab by adding the following line to the end of /etc/fstab file: "/swapfile none swap sw 0 0" or just run: echo '/swapfile none swap sw 0 0' >> /etc/fstabGrab the UUID needed for the root fs: blkid -s UUID -o value ${DUSB}3Change /etc/fstab to use this UUID (swap out /dev/sdc3 for UUID=....): UUID=dcebz44f-7fbd-4623-ac19-7e0d073be06b / ext4 defaults 1 1 Acquire a solid base command for generating an initrd file by running: /usr/share/mkinitrd/mkinitrd_command_generator.shThis should output something like: mkinitrd -c -k 5.4.44 -f ext4 -r /dev/sdc3 -m usb-storage:xhci-hcd:xhci-pci:ohci-pci:ehci-pci:uhci-hcd:ehci-hcd:hid:usbhid:i2c-hid:hid_generic:hid-asus:hid-cherry:hid-logitech:hid-logitech-dj:hid-logitech-hidpp:hid-lenovo:hid-microsoft:hid_multitouch:jbd2:mbcache:crc32c_intel:crc32c_generic:ext4 -u -o /boot/initrd.gz A few crucial modifications are in order: Change the '-r /dev/sdc3' to: '-r "UUID=dcebz44f-7fbd-4623-ac19-7e0d073be06b"' This will ensure that the root fs will be found upon booting, being on an USB drive, the device name will not be static, so making sure that the root FS is bound to the static UUID is a must. Add: '-w 10' and '-h /swapfile' This will cause the booting process to wait 10 seconds, allowing the root partition to be loaded through the modules properly and not result in kernel panic/boot failure. -h /swapfile is useful for enabling hibernating using the swapfile we've created. The final command should look similar to this (adjust to suit your system): mkinitrd -c -k 5.4.44 -f ext4 -r "UUID=dcebz44f-7fbd-4623-ac19-7e0d073be06b" -h /swapfile -m usb-storage:xhci-hcd:xhci-pci:ohci-pci:ehci-pci:uhci-hcd:ehci-hcd:hid:usbhid:i2c-hid:hid_generic:hid-asus:hid-cherry:hid-logitech:hid-logitech-dj:hid-logitech-hidpp:hid-lenovo:hid-microsoft:hid_multitouch:jbd2:mbcache:crc32c_intel:crc32c_generic:ext4 -w 10 -u -o /boot/initrd.gz[Sidenote] I find it convenient to have the command above in a file like initrd.sh and making it executable: chmod +x initrd.shRun that command manually or through that file. You should have a properly set up initial ramdisk now. After a kernel upgrade on the system you only have to adjust the kernel version in that file and run it (possibly with grub updating). This is an example, don't run the grub command just yet!: ./initrd.sh; grub-mkconfig -o /boot/grub/grub.cfg[/Sidenote] So let's get grub installed on the bios boot partition. Since this installation is going to be portable, consider adding the following line to /etc/default/grub to make sure that only Slackware is listed in the bootloader: echo "GRUB_DISABLE_OS_PROBER=true" >> /etc/default/grubInstall grub onto the device: grub-install --target=i386-pc --modules="ext2 part_gpt" --no-nvram $DUSBThis should've created a system that is bootable on a legacy bios system. The final piece of this installation is getting a grub efi image set on the efi partition. Let's start by mounting the efi partition: mkdir /boot/efiCreate the necessary subdirectories: mkdir -p /boot/efi/EFI/BOOTCreate the grub-efi boot image file (bootx64.efi): /usr/bin/grub-mkimage --format=x86_64-efi -p /efi/boot --output=bootx64.efi --compression=xz part_gpt part_msdos fat f2fs ext2 hfs hfsplus iso9660 udf ufs1 ufs2 zfs chain linux boot appleldr configfile normal regexp minicmd reboot halt search search_fs_file search_fs_uuid search_label efi_gop efi_uga all_video loadbios gzio echo true probe loadenv bitmap_scale font cat help ls png jpeg tga test at_keyboard usb_keyboard zstdAdd a simple grub.cfg config file that hooks onto the main grub.cfg file: printf "search.fs_uuid $(blkid -s UUID -o value ${DUSB}3) root\nconfigfile (\$root)/boot/grub/grub.cfg\n" > grub.cfgExit the chroot and start cleaning up: exitRepeat the unmount command if one or more devices are busy. If they stay busy, you can check what's keeping them occupied: fuser <device>If you want to force their release, run: fuser -k <device> or fuser -k -9 <device>Final bits after that: rm -f ./mnt/root/.bashrcTo be on the safe side, reboot first and give your new USB Slackware installation a whirl, after that (as root and after cd'ing to the proper directerory) run: rm -rf slackwareAfter all of this you should have a robust hybrid BIOS/Legacy and UEFI Slackware installation up and going on this USB drive. Reboot your system and enjoy. This guide wouldn't have been possible without this amazing blogpost: https://blog.heckel.io/2017/05/28/cr...e-linux-system Further references: https://www.linuxquestions.org/quest...sb-4175663008/ https://www.gnu.org/software/grub/ma...iguration.html |
If you want to fetch and extract Slackware's initial ramdisk in one go, you can run this:
wget https://mirrors.slackware.com/slackw...nux/initrd.img -O - | xz -dc | cpio -idmvThis you don't have to download the file itself first, it gets extracted on the fly. |
All times are GMT -5. The time now is 12:18 AM. |