Hits since 2023-11-25 00:44:41:
40




Joe's Life






How to Install Slackware to a USB Device :

I sometimes see questions on Usenet or forums about how to install Linux to a USB device in such way that it can be booted and used.  Just today (February 24, 2017) I read such a post on the Usenet group alt.os.linux.slackware.  Because I know how to do it (I currently run Slackware 14.2 from a USB SSD), I decided to post this HOW TO.

To boot a USB device, you need an initrd.gz.  I used mkinitrd_command_generator.sh to to make a mkinitrd command, and then used that command to make the initrd.gz.  Here is a list of steps re-written from my notes:

    1.  Obtain a set of Slackware install CDs or CD images.  I will refer to these below as "disks".

    2.  Boot from the first Slackware disk, and install Slackware in the usual way to a partition on a USB device, but do not run Lilo.  You will setup a boot loader, such as Lilo, in step 10 below.

    When the Slackware installation is completed, do not exit the booted shell. Rather, stay in it at least until you have made the initrd.gz file in step 7.

    3.  Use chroot to change to the root of the new Slackware installation on a USB device.

    4.  While in the chroot shell, use /usr/share/mkinitrd/mkinitrd_command_generator.sh command to make a mkinitrd command.  Then exit from the chroot shell.

    5.  Put the result of the above into a a bash script and give the file execute permission.

    6.  Change the above by adding "-w 30".  This causes a 30 second wait for the Slackware root to be recognized before proceeding.

    7.  Run the above script to make an initrd.gz file.

    You may exit the booted shell at this time.  However, it is OK to stay in it to perform the remaining steps.

    8.  Use e2label to give a label to the new Slackware root partition, and change fstab of the new Slackware to use that label when mounting root.

    9.  Re-make the swap partition on the new Slackware specifying a label, and change fstab of the new Slackware to use that label when adding the swap partition.

    10.  Setup a boot loader to use the initrd.gz made above.  Lilo is suitable. Some other choices are Syslinux, Extlinux and Grub 2.

    11.  Boot.

You now have a bootable USB device.  In the process you also acquired an initrd.gz.  It was needed to make the USB device bootable, but it can be useful in other ways.  You can enter "rescue" on the boot line to get an ash shell.  This can be used for rescue or other purposes.  You will get this ash shell automatically if root cannot be mounted.

You can include this initrd.gz when making a flash drive or CD bootable.  When done properly such a flash drive or CD can be used to boot the Slackware system that you installed to the USB device.  Such a flash drive is commonly called a "boot stick", and the CD is known as a "boot disk".

You can also make use of the script that you made in step (6).  It contains an invocation of mkinitrd.  That invocation can be modified to make other, different initrd.gz files.  In particular, you may want to make an initrd.gz file that includes additional commands.  These commands will then be available for your use when you are in the ash rescue shell.

To do this (in the above paragraph), you will need to study the mkinitrd command, and you may want to use a Rosevear Software product called "Joe's Boot Disk".  You can get a kit to make Joe's Boot Disk (JBD) from https://sourceforge.net/projects/joesbootdisk.

© Joseph Rosevear
  |   Source touched: 2024-04-06 20:19:26