Contents

Make a Slackware bootable USB-stick

Notice:

the procedures described in this tutorial are to be considered "as is", without any warranty. There is no relationship between the original distro Slackware (great distro!) and the ideas contained in this article.

Preamble

I think that the usbboot.img idea, as system to make a bootable USB-stick, has to be overcome, It is slow as boot time and uses a proprietary FAT filesystem. The only reason whereby Slackware team mantains this system in use is, perhaps, because the windows users cannot run bash scripts in their own system.

But to run a simple bash script is sufficient any Linux system, also the mini-system inside the Slackware DVD, so, also windows users that have at least a PC with DVD reader can run an external script.

The script

This is a simple script that can make a bootable USB-stick (or USD-HD) similar at Slackware installation DVD, that may contains also the packages to perform Slackware installation in computers without DVD reader. Download the script File:UsbslackDVDboot.sh

usbslackDVDboot.sh this is the code:

#!/bin/sh
# usbslackDVD.sh - Make a bootable USB-stick (or USB-HD) from Slackware
# copyleft Fabio Zorba 2012
# rev.02 - 2012-10-10
 
SLACK_INSTALL_PATH="SlackDVD"
USB_TEMP_MOUNTPOINT="../USB_SLACK_TEMP_MOUNTPOINT"
 
if [ $# -eq 2 ] ; then
 
 ROOT_DEV=/dev/$1
 
 echo "
---------------------------------------------------
You selected $BOOT_DEVICE device to install SLACK filesystem.
 
Warning ! All data in selected device may be LOST
 
"
 echo -n "type 'okay' to proceed : "
 
 read NNN
 
 if [ "a$NNN" = "aokay" ] ; then
 
  #-------- check device ---------
  case "$1" in
 
   sda) BOOT_DEVICE="/dev/sda$2" ;;
   sdb) BOOT_DEVICE="/dev/sdb$2" ;;
   sdc) BOOT_DEVICE="/dev/sdc$2" ;;
   sdd) BOOT_DEVICE="/dev/sdd$2" ;;
   sde) BOOT_DEVICE="/dev/sde$2" ;;
   sdf) BOOT_DEVICE="/dev/sdf$2" ;;
   sdg) BOOT_DEVICE="/dev/sdg$2" ;;
   sdh) BOOT_DEVICE="/dev/sdh$2" ;;
 
   *) BOOT_DEVICE="not_in_list" ;;
 
  esac
 
  if [ "a$BOOT_DEVICE" = "anot_in_list" ] ; then
   echo "Error device $ROOT_DEV, valid names are: sda,sdb,sdc,sdd,sde,sdf,sdh ... exit"
   exit
  fi
 
  EXIST_DEVICE=`ls $BOOT_DEVICE`
  if [ "a$EXIST_DEVICE" == "a" ] ; then
   echo "Error device $BOOT_DEVICE not exists ... exit"
   exit
  fi
 
  #Check if Slackware DVD is present in system
 
  DVD_MOUNTPOINT=`mount | grep iso9660 | cut -d" " -f3`
 
  if [ ! -d $DVD_MOUNTPOINT/slackware ] ; then
   echo "Error Slackware DVD not found or not mounted ... exit"
   exit
  fi
 
  USB_MOUNTPOINT=`mount | grep $BOOT_DEVICE | cut -d" " -f3`
 
  if [ "a$USB_MOUNTPOINT" == "a" ] || [ ! -d $USB_MOUNTPOINT ] ; then
 
   echo "Format the partition $BOOT_DEVICE ? [ENTER=no]"
   echo -n "... or type 'okay' to proceed with formatting: "
 
   read NNN
 
   if [ "a$NNN" = "aokay" ] ; then
    mkfs.ext2 $BOOT_DEVICE
   fi
 
   mkdir $USB_TEMP_MOUNTPOINT
 
   mount $BOOT_DEVICE $USB_TEMP_MOUNTPOINT
 
   IS_USB_MOUNTED=`mount | grep $USB_TEMP_MOUNTPOINT`
 
   if [ "a$IS_USB_MOUNTED" = "a" ] ; then
    echo "Error: $ROOT_DEV device not mounted in $USB_TEMP_MOUNTPOINT ... exit"
    exit
   fi
 
  else
    echo "$BOOT_DEVICE already mounted in $USB_MOUNTPOINT, I will install inside this one ..."
    USB_TEMP_MOUNTPOINT=$USB_MOUNTPOINT
  fi
 
  echo "Make usb-disk devices"
 
  mkdir -p $USB_TEMP_MOUNTPOINT/$SLACK_INSTALL_PATH
  mkdir -p $USB_TEMP_MOUNTPOINT/$SLACK_INSTALL_PATH/boot
  mkdir -p $USB_TEMP_MOUNTPOINT/$SLACK_INSTALL_PATH/dev
  mkdir -p $USB_TEMP_MOUNTPOINT/$SLACK_INSTALL_PATH/etc
 
  echo "Copying files ..."
 
  cp -f $DVD_MOUNTPOINT/kernels/hugesmp.s/bzImage  $USB_TEMP_MOUNTPOINT/$SLACK_INSTALL_PATH/boot
  cp -f $DVD_MOUNTPOINT/isolinux/initrd.img        $USB_TEMP_MOUNTPOINT/$SLACK_INSTALL_PATH/boot
 
  #Add Slackware packages to root of partition
  echo "Copy Slackware packages to $BOOT_DEVICE ? [ENTER=no]"
  echo -n "type 'yes' to begin copying files: "
 
  read NNN
 
  if [ "a$NNN" = "ayes" ] ; then
    echo "Copying Slackware packages ..."
    cp -Rf $DVD_MOUNTPOINT/slackware  $USB_TEMP_MOUNTPOINT/
  fi
 
  #Make usb devices in /dev because Lilo needs them
  START=0
  MINOR=0
 
  for DISK in "a" "b" "c" "d" "e" "f" "g" "h" 
  do
   MINOR=$START
 
   for i in 0 1 2 3 4 5 6
   do
    if [ $i -eq 0 ] ; then
     mknod $USB_TEMP_MOUNTPOINT/$SLACK_INSTALL_PATH/dev/sd$DISK   b 8 $MINOR
    else
     mknod $USB_TEMP_MOUNTPOINT/$SLACK_INSTALL_PATH/dev/sd$DISK$i b 8 $MINOR
    fi
 
    let MINOR=$MINOR+1
   done
 
    let START=$START+16
  done
 
  echo    "LILO will be installed to $ROOT_DEV by default ..."
  echo
  echo -n "You may select another device [enter=default] : "
 
  read ELSE_ROOT_DEV
 
  if [ "a$ELSE_ROOT_DEV" != "a" ] ; then
   ROOT_DEV=$ELSE_ROOT_DEV
  fi
 
  echo
  echo    "flushing disk cache before install Lilo ... please wait ..."
 
  echo "
# LILO configuration file
# generated by Zoros
#
# Start LILO global section
# Append any additional kernel parameters:
 
boot = $ROOT_DEV
 
prompt
compact
lba32
vga = normal
timeout = 50
 
# Linux bootable partition config begins
 
image =  /boot/bzImage
  initrd=/boot/initrd.img
  label = SlackDVD
  read-write
 
# Linux bootable partition config ends
 
" > $USB_TEMP_MOUNTPOINT/$SLACK_INSTALL_PATH/etc/lilo.conf
 
  lilo -P ignore -r $USB_TEMP_MOUNTPOINT/$SLACK_INSTALL_PATH
 
  if [ "a$USB_MOUNTPOINT" == "a" ] ; then
    umount $USB_TEMP_MOUNTPOINT
    rmdir  $USB_TEMP_MOUNTPOINT
  fi
 
 fi
 
else
 
 echo "
This script make a bootable USB-Stick (or HD) from Slackware DVD ...
Pay attention: all data in selected device may be lost.
 
Usage: $0 device [sdb,sdb,sdc...] n.partition [1,2,3...]
"
 
fi

Note: the script is not wide scale tested, but so far it has worked well on several PCs

How to use

To make a bootable USB-stick, you must mount Slackware DVD in your system before run the script. You must be sure that you known exactly the name of USB disk connected to your PC: the script can format the disk, so all data in target device will be lost.

However, you can make the bootable USB-stick without formatting, infact the script will install entire system in a folder named "SlackDVD". The script will not format the USB device if this is already mounted, but, in every case, the script will copy the right files and will install the boot manager Lilo.

Operating procedure

$su -
# fsisk -l
 
Disk /dev/sda: 251.0 GB, 251000193024 bytes
255 heads, 63 sectors/track, 30515 cylinders, total 490234752 sectors
...
Disk /dev/sdb: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders, total 976773168 sectors
...
Disk /dev/sdc: 4022 MB, 4022337024 bytes
255 heads, 63 sectors/track, 489 cylinders, total 7856127 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x516cb889
 
   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1              63     7438094     3719016   83  Linux
/dev/sdc2   *     7438095     7855784      208845    b  W95 FAT32
#

in this example the usb device is /dev/sdc1, already formatted with ext2 ... in this case you can also mount also the device, or to be sure that is umounted, so the script will begin formatting it.

# ./usbslackDVDboot.sh sdc 1

then follow the program instructions, have fun!

Zoros 00:45, 10 October 2012 (CEST)

Retrieved from "http://www.zoros.org/wiki/index.php?title=How_to_make_a_Slackware_bootable_usb-stick_starting_from_Slackware_installation_DVD,_or_any_Linux_system"