Create bootable USB HD/Stick, only tested on Slackware 12.1, 12.2 and 13.0

Update 2010-02-08, Fixed typos...

Update 2009-11-06, New version for Slackware 13.0

Slackware 13.0

Note: Read the guide below for 12.1/12.2 before this one..

cd  /boot
mkinitrd
cd initrd-tree

rm bin/awk
rm bin/cut

oot@localhost:/boot/initrd-tree# cp /lib/libblkid.so.1 lib/
root@localhost:/boot/initrd-tree# cp /lib/libext2fs.so.2 lib/
root@localhost:/boot/initrd-tree# cp /lib/libc.so.6 lib/
root@localhost:/boot/initrd-tree# cp /lib/libuuid.so.1 lib/
root@localhost:/boot/initrd-tree# cp /lib/libcom_err.so.2 lib/
root@localhost:/boot/initrd-tree# cp /lib/ld-linux.so.2 lib/
root@localhost:/boot/initrd-tree# cp /lib/libpthread.so.0 lib/
root@localhost:/boot/initrd-tree# cp /lib/libdl.so.2 lib/
root@localhost:/boot/initrd-tree# cp /lib/libm.so.6 lib/

cp /usr/bin/awk bin/
cp /sbin/blkid bin/
cp /bin/cut bin/

cd ..

Install device files from the Slackware DVD:
mount /dev/dvd /mnt/dvd
installpkg -root /boot/initrd-tree /mnt/dvd/slackware/a/devs-2.3.1-noarch-25.t?z 

Replace init with modified version

cp init_13.0.txt /boot/initrd-tree/init

mkinitrd

Continue with the same procedure as for 12.1/12.2..

init_13.0.txt

initrd_13.0.gz

Slackware 12.1 and 12.2

uname -a

Linux darkstar 2.6.21.5 #2 PREEMPT Thu Nov 8 08:52:54 CET 2007 i686 Intel(R) Pentium(R) M processor 1.20GHz GenuineIntel GNU/Linux

cd /boot

Create a basic initrd with any modules needed:

mkinitrd -c -k 2.6.21.5 -m reiserfs

Label the root partition:

reiser:

reiserfstune --label USB-ROOT /dev/sda2

ext2/ext3:

e2label /dev/sda2 USB-ROOT

or use gparted to change the label..

Replace init with modified version

cp newinit.txt /boot/initrd-tree/init

Copy binaries (awk, blkid and cut) to bin:

rm /boot/initrd-tree/bin/awk

cp /usr/bin/awk /boot/initrd-tree/bin
cp /sbin/blkid /boot/initrd-tree/bin
cp /bin/cut /boot/initrd-tree/bin

Copy libraries to lib
ld-linux.so.2  libblkid.so.1  libc.so.6  libdl.so.2  libm.so.6  libuuid.so.1

cp /lib/ld-linux.so.2 /boot/initrd-tree/lib/
cp /lib/libblkid.so.1 /boot/initrd-tree/lib/
cp /lib/libc.so.6 /boot/initrd-tree/lib/
cp /lib/libdl.so.2 /boot/initrd-tree/lib/
cp /lib/libm.so.6 /boot/initrd-tree/lib/
cp /lib/libuuid.so.1 /boot/initrd-tree/lib/

#Additional libs needed for Slackware 12.2
cp /lib/libext2fs.so.2 /boot/initrd-tree/lib/
cp /lib/libcom_err.so.2 /boot/initrd-tree/lib/
cp /lib/libpthread.so.0 /boot/initrd-tree/lib/

root@localhost:/boot/initrd-tree# ll lib/
totalt 2206
drwxr-xr-x  3 root root     360 2009-09-10 21:25 .
drwxr-xr-x 11 root root     488 2009-09-10 21:25 ..
-rwxr-xr-x  1 root root  131468 2009-09-10 21:25 ld-linux.so.2
-rwxr-xr-x  1 root root   37136 2009-09-10 21:25 libblkid.so.1
-rwxr-xr-x  1 root root 1570593 2009-09-10 21:25 libc.so.6
-rwxr-xr-x  1 root root    8472 2009-09-10 21:25 libcom_err.so.2
-rwxr-xr-x  1 root root   13474 2009-09-10 21:25 libdl.so.2
-rwxr-xr-x  1 root root  165044 2009-09-10 21:25 libext2fs.so.2
-rwxr-xr-x  1 root root  180649 2009-09-10 21:25 libm.so.6
-rwxr-xr-x  1 root root  110684 2009-09-10 21:25 libpthread.so.0
-rwxr-xr-x  1 root root   11552 2009-09-10 21:25 libuuid.so.1

Install device files from the Slackware DVD:
mount /dev/dvd /mnt/dvd
installpkg -root /boot/initrd-tree /mnt/dvd/slackware/a/devs-2.3.1-noarch-25.tgz 

Create a new initrd which contains the modifications

mkinitrd

Copy the initrd to the USB disk and update Lilo/Grub:

mount /dev/sda2 /mnt/tmp

cp /boot/initrd.gz /mnt/tmp/boot

kedit /mnt/tmp/etc/lilo.conf

Test first:
lilo -t -v -r /mnt/tmp

If OK:
lilo -v -r /mnt/tmp

lilo.conf

# LILO configuration file
# generated by 'liloconfig'
#
# Start LILO global section
boot = /dev/sda
compact        # faster, but won't work on all systems.
prompt
timeout = 50
# Normal VGA console
vga = normal
# VESA framebuffer console @ 1024x768x64k
# vga=791
# VESA framebuffer console @ 1024x768x32k
# vga=790
# VESA framebuffer console @ 1024x768x256
# vga=773
# VESA framebuffer console @ 800x600x64k
# vga=788
# VESA framebuffer console @ 800x600x32k
# vga=787
# VESA framebuffer console @ 800x600x256
# vga=771
# VESA framebuffer console @ 640x480x64k
# vga=785
# VESA framebuffer console @ 640x480x32k
# vga=784
# VESA framebuffer console @ 640x480x256
# vga=769
# ramdisk = 0     # paranoia setting
# End LILO global section
# Linux bootable partition config begins

image = /boot/vmlinuz
initrd = /boot/initrd.gz
  append = "3 label="USB-ROOT"
  label = SW12.1-USB
  read-only  # Partitions should be mounted read-only for checking

# Linux bootable partition config ends

Replace Lilo with Syslinux:

Create a syslinux USB stick on sdc1 (FAT) for booting another partition by label.

mount /dev/sdc1 /mnt/zip
mount /dev/sdc2 /mnt/tmp

mkdir /mnt/zip/syslinux

cp /mnt/tmp/boot/vmlinuz /mnt/zip/syslinux/vmlinuz
cp /boot/initrd.gz /mnt/zip/syslinux/initrd.gz

kedit /mnt/tmp/syslinux/syslinux.cfg

default vmlinuz initrd=initrd.gz

Or more complex..

default BOOT_SW_CURRENT
prompt 1
timeout 1200
display message.txt
label BOOT_SW_CURRENT
#2.6.24.4-xxx
          kernel vmlinuz1
          append initrd=initrd.gz label=BOOT_SW_CURRENT 
label USB-ROOT
#2.6.27.7
          kernel vmlinuz2
          append initrd=initrd.gz label=USB-ROOT


Create a file named message.txt:

kedit /mnt/tmp/syslinux/message.txt

Rescue Boot USB-HD
---------------------
Use BOOT_SW_CURRENT for kernel 2.6.24.4-xxx (Slackware 12.1)
Use USB-ROOT for kernel 2.6.27.7 (Slackware 12.2)

Default is BOOT_SW_CURRENT

Override label for root partition with e.g. BOOT_SW_CURRENT append label=XXXXX

Make rescue CD/DVD

mkdir -p isoimage/isolinux
mkdir -p isoimage/kernels

cp /usr/lib/syslinux/isolinux.bin isoimage/isolinux

Use the initrd and kernels from the USB resuce stick..
mount /dev/sdc /mnt/tmp 

cp /mnt/tmp/syslinux/initrd.gz isoimage/isolinux/
cp /mnt/tmp/syslinux/vmlinuz1 isoimage/kernels
cp /mnt/tmp/syslinux/vmlinuz2 isoimage/kernels
cp /mnt/tmp/syslinux/message.txt isoimage/isolinux

kedit isoimage/isolinux/isolinux.cfg

default BOOT_SW_CURRENT
prompt 1
timeout 1200
display message.txt
label BOOT_SW_CURRENT
#2.6.24.4-xxx
          kernel /kernels/vmlinuz1
          append initrd=initrd.gz label=BOOT_SW_CURRENT
label USB-ROOT
#2.6.27.7
          kernel /kernels/vmlinuz2
          append initrd=initrd.gz label=USB-ROOT

mkisofs -o boot.iso -A "Rescue USB-HD" -iso-level 4 -v -N -no-emul-boot -boot-load-size 4 -boot-info-table -b isolinux/isolinux.bin -c isolinux/isolinux.boot -V "Rescue USB-HD" isoimage

Burn it! Use k3b or whatever..

New version 2009-09-10. Bugfix, tested on Slackware 12.2.

newinit.txt

initrd.gz

Same as above but without any modules (smaller initrd)

Various stuff needs to be in the kernel and not as modules.

Working kernel configuration:

uname -a Linux darkstar 2.6.22.6 #6 PREEMPT Thu Nov 15 13:54:27 CET 2007 i686 Intel(R) Pentium(R) M processor 1.20GHz GenuineIntel GNU/Linux

.config

LazyLinuxWiki/Boot/Initrd with LABEL/UUID support (last edited 2010-02-08 14:19:41 by linuxfunkar)