LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware > Slackware - Installation
User Name
Password
Slackware - Installation This forum is for the discussion of installation issues with Slackware.

Notices


Reply
  Search this Thread
Old 06-06-2020, 07:06 AM   #1
LBuhler
LQ Newbie
 
Registered: Apr 2020
Location: The Netherlands
Distribution: Ubuntu
Posts: 11

Rep: Reputation: Disabled
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 slackware
Grab Slackware's latest initrd image to acquire the minimal system:
wget https://mirrors.slackware.com/slackw...nux/initrd.img
Extract the image:
xz -dc < initrd.img | cpio -idmv
Set 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/.bashrc
Make 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 $DUSB
Create the proper GPT partition table:
sgdisk --clear \
--new 1::+1M --typecode=1:ef02 --change-name=1:'BIOS boot partition' \
--new 2::+100M --typecode=2:ef00 --change-name=2:'EFI System' \
--new 3::-0 --typecode=3:8300 --change-name=3:'Slackware root fs' \
$DUSB
Reload the drive and check the disk's partition layout:
partprobe $DUSB
gdisk -l $DUSB
Format the EFI and Root partition:
mkfs.fat -F32 ${DUSB}2
mkfs.ext4 -F -L "slackroot" ${DUSB}3
Prepare for chroot:
for d in dev sys proc; do mount --bind /$d ./$d; done
cp -L /etc/resolv.conf ./etc/resolv.conf
And chroot into the minimal Slackware system:
chroot ./ /bin/bash
source /etc/profile
Start 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:
exit
cp -L ./root/.bashrc ./mnt/root/
chroot ./mnt /bin/bash
source /etc/profile
Let's set up a swapfile:
fallocate -l 4G ./swapfile
chmod 600 ./swapfile
mkswap ./swapfile
Add 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/fstab
Grab the UUID needed for the root fs:
blkid -s UUID -o value ${DUSB}3
Change /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.sh
This 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.sh
Run 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/grub
Install grub onto the device:
grub-install --target=i386-pc --modules="ext2 part_gpt" --no-nvram $DUSB
grub-mkconfig -o /boot/grub/grub.cfg
This 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/efi
mount ${DUSB}2 /boot/efi
Create the necessary subdirectories:
mkdir -p /boot/efi/EFI/BOOT
cd /boot/efi/EFI/BOOT
Create 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 zstd
Add 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.cfg
Exit the chroot and start cleaning up:
exit
umount ./dev ./mnt/dev ./sys ./mnt/sys ./proc ./mnt/proc
Repeat 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/.bashrc
umount ${DUSB}2 ${DUSB}3
To 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 slackware
After 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

Last edited by LBuhler; 06-06-2020 at 01:18 PM.
 
Old 06-28-2020, 01:35 PM   #2
LBuhler
LQ Newbie
 
Registered: Apr 2020
Location: The Netherlands
Distribution: Ubuntu
Posts: 11

Original Poster
Rep: Reputation: Disabled
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 -idmv
This you don't have to download the file itself first, it gets extracted on the fly.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Detecting Linux-based bootable USB flash drive: Legacy BIOS or UEFI? pstein Linux - Newbie 3 07-08-2019 12:11 PM
Slackware64-current(>14.2): bug with UEFI install onto DELL Inspiron 14-3452 laptop ( eMMC 32GB drive ) from usb-stick image ckrzen Slackware - Installation 4 11-27-2016 08:24 AM
American Megatrends: LEGACY boot not found at all in bios menu (only UEFI) Xeratul Linux - Hardware 12 08-08-2015 11:30 AM
GPT, UEFI and BIOS Legacy slaka Linux - Laptop and Netbook 8 04-17-2013 07:28 AM
LXer: Weekend Project: Bootstrap Your Site with Bootstrap LXer Syndicated Linux News 0 09-02-2011 11:30 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware > Slackware - Installation

All times are GMT -5. The time now is 08:03 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration