My thoughts on Slackware, life and everything

Installing Slackware using USB thumb drive

There are several ways to install Slackware to your computer. You have network installation options available (where the packages are on a remote NFS/FTP/HTTP/Samba server) and local options (where the packages are on a DVD/CDROM or a local directory).

In all these cases you need to boot your computer with Slackware’s installer. Traditionally you can boot from a DVD or CDROM of course, or even from a floppy if you are creative. If your computer does not have a DVD/CD drive then there is still the network boot (aka PXE boot) or using a USB thumb drive to boot from.

It is the USB thumb drive I want to talk about in this blog post.

Slackware ships with a USB image file “usbboot.img” since the 12.0 release (see http://slackware.osuosl.org/slackware-13.0/usb-and-pxe-installers/usbboot.img for instance). Using “dd” this image can be transfered to a USB thumb drive which transforms the USB drive to a bootable Slackware installer. The packages will still have to be available on a local or network medium, because the “usbboot.img” image only contains kernels and setup files… no packages.

If you do not want to “sacrifice” a USB thumb drive for this (note that dumping the image file on the USB stick will destroy all data already present on the stick), there is a solution: Slackware also ships with a script “usbimg2disk.sh” since the 13.0 release (see http://slackware.osuosl.org/slackware-13.0/usb-and-pxe-installers/usbimg2disk.sh for instance). This script extracts the content from the “usbboot.img” image file and uses this to transform a regular USB thumb drive into a bootable Slackware installer  non-destructively (i.e. any existing files on the stick will not be touched), as long as there is some 30 MB of available free space on the stick.

The “usbimg2disk.sh” script is also convenient if your computer refuses to boot from a USB stick loaded with the “usbboot.img” file. The BIOS of some computers will not understand the format of the default Slackware USB image. Using the “usbimg2disk.sh” script, you create an alternative bootable USB stick that will be recognized by your computer’s BIOS.

All nice, but there is still a problem that remains to be solved.

If you have a netbook for instance.

The average netbook computer (like my own Asus EeePC 1000H) comes without DVD drive. If you are mobile and without access to wired network, it will not be easy to install Slackware packages after booting from the USB stick.

In such circumstances you need to copy the complete Slackware package tree to a disk partition of your netbook before you start the Slackware installation. This is not always efficient, or even feasible.

Now, I have been creating “multi-partition USB images” for several Slackware releases in the past (more accurately, I have written the scripts that let you create the image and then transfer it to a big enough USB stick using the ” dd” command). You can find those scripts here: http://slackware.com/~alien/tools/usbinstall/ . This is an elegant way to create a USB Slackware installer that has all packages “on board” but I wanted something that was more basic, and thus potentially easier to use for a Slackware newbie.

The “old” scripts at http://slackware.com/~alien/tools/usbinstall/ create a secoind, EXT2-formatted partition to store the Slackware packages. This makes it harder to add more files if you are on a Windows computer for instance. I wanted to have a USB stick with a single large FAT partition – and fortunately the bootloader I am using (syslinux) allows this.

So I took Slackware’s “usbimg2disk.sh” script (which I incidentally wrote too) and expanded its functionality. What is new? The script can now copy the Slackware setup files, kernels and packages all to a regular USB thumb drive, if that has a minimum of 2GB free space available.And it still retains its original functionality (to create a bootable installer as long as there is 30 MB of available free space on the stick).

The USB stick does not even have to be formatted! So, if you already have data on the stick, it will not be destroyed.

There is one advantage to formatting though: if you allow the script to format the USB stick, it will make your future Slackware installation easier. The formatting step assigns a label “USBSLACKINS” to the fat partition. This enables Slackware’s setup to recognize and mount the USB partition automatically after boot, and pre-fill the SOURCE setup dialog “Install from a pre-mounted directory” with the correct directory path. Just hit ENTER a few times to start the installation!

If you did not format the USB stick but used an existing VFAT-formatted stick, you have two options:

  1. either you assign  the label “USBSLACKINS” to the stick’s fat partition manually,
  2. or else you do the following after booting from the USB stick but before running setup: mount the USB partition yourself using the following commands (for this eaxmple I am assuming that the installer recognized the drive as “/dev/sdX“):
mkdir /usbinstall
mount -t vfat -o ro,shortname=mixed /dev/sdX /usbinstall/

And then after you’ve started “setup” and have come to the “SOURCE selection” dialog, you use the directory “/usbinstall/slackware-<version>/slackware” as the source location where setup should look for Slackware packages.

This is how the help text for the script looks:

./usbimg2disk.sh -h
#
# Purpose #1: to use the content of Slackware's usbboot.img and
#   transform a standard USB thumb drive with a single vfat partition
#   into a bootable medium containing the Slackware Linux installer.
#
# Purpose #2: to use the contents of a Slackware directory tree
#   and transform a standard USB thumb drive with
#   a single vfat partition and 2GB of free space into
#   a self-contained USB installation medium for Slackware Linux.
#
#
# Your USB thumb drive may contain data!
# This data will *not* be overwritten, unless you have
#   explicitly chosen to format the drive by using the '-f' parameter.
#
# usbimg2disk.sh accepts the following parameters:
#   -h|--help                  This help
#   -f|--format                Format the USB drive before use
#   -i|--infile <filename>     Full path to the usbboot.img file
#   -l|--logfile <filename>    Optional logfile to catch fdisk output
#   -o|--outdev <filename>     The device name of your USB drive
#   -s|--slackdir <dir>        Use 'dir' as the root of Slackware tree
#   -u|--unattended            Do not ask any questions
#
# Examples:
#
# usbimg2disk.sh -i ~/download/usbboot.img -o /dev/sdX
# usbimg2disk.sh -f -s /home/ftp/pub/slackware-13.0 -o /dev/sdX
#
# The second example shows how to create a fully functional Slackware
# installer on a USB stick (it needs a Slackware tree as the source).

The enhanced script is here: http://connie.slackware.com/~alien/tools/usbimg2disk.sh …get itwhile it’s hot!

I hope it will get added to the Slackware tree soon. Tell me if you liked it! Any questions or remarks, you can leave them below this post.

Cheers, Eric

68 Comments

  1. Grissiom

    Although I don’t have enough time to try it out soon, I like this version of script! Thanks a lot. Hope it will be merged into the main tree soon.

  2. alienbob

    Hi Grissiom

    I hope it will be useful to people, having a “USB version” of the Slackware install DVD is in high demand.
    By the way, I made two small changes after I originally uploaded the script. It now additionally checks if you have “mtools” installed. The syslinux tool which makes your USB stick bootable depends on it. And the “syslinux-nomtools” binary seems to work (the script shows no errors) but the resulting USB stick is not bootable.

    The script version which I uploaded just now, works.

    Cheers, Eric

  3. JokerBoy

    hi Eric. i wonder if in this new release for 13.0 exist the possibility to install via usb using a PPPoE connection. and if not, can you add rp-pppoe to it? 🙂

    thank you.

  4. Luan Mai

    Hi Eric,

    I follow your instruction but i got boot error message. In my flash disk, i have 2 folders, one is syslinux, the other is slackware13

    Many Thanks, Eric

  5. Luan Mai

    Please ignore my previous comment. It ‘s just my BIOS setting.

    Thanks very much for your instruction.

  6. Eduard

    Great script, I’m using it right now to create a USB stick with all the slackware13 64 packages and looking forward to many future DVD-less installs!

  7. alienbob

    FYI – the usbimg2disk.sh script I am talking about has been updated in Slackware-current.
    The http://slackware.osuosl.org/slackware-current/usb-and-pxe-installers/usbimg2disk.sh is now the same version as the script discussed in this post (same for the script in the 64-bit tree).

    Eric

  8. Antman

    I’m glad to see this script but I always get a:
    trap: 37: ERR: bad trap
    Whenever i try to run it. I have tried-
    # sh usbimg2disk.sh -f -s /home/antman/data/ -o /dev/sdb
    # ./usbimg2disk.sh -f -s /home/antman/data/slackware -o /dev/sdb

    I can’t even run:
    # sh usbimg2disk.sh -h
    to see the help without the trap: 37: ERR: bad trap

    I’m running this script from a debian machine (I tried it on Linux Mint also). Does it only work on a slackware machine?

  9. Antman

    Oh… i forgot to mention that I copied the slackware 13.1 dvd to /home/antman/data/

  10. Antman

    Ok, I figured it out. On my debian system I had to precede my command with command “bash”
    So my full command was:
    # bash ./usbimg2disk.sh -f -s /home/antman/data/ -o /dev/sdb

    The usb is building as I type this…. 😉

  11. Azmi

    if i give parameters -f , i got some error like this :
    “*** usbimg2disk.sh FAILED at line 37 ***
    — Cleaning up the staging area…
    rmdir: missing operand
    Try rmdir –help’ for more information. ”

    How to solve it?

  12. Azmi

    i got some error too if i wrote
    “sudo bash usbimg2disk.sh -i usbboot.img -o /dev/sdb1″
    Error:
    # We are going to use this device – ‘/dev/sdb1’:
    #
    # Disk /dev/sdb1: 8029 MB, 8029930496 bytes
    # 248 heads, 62 sectors/track, 1019 cylinders
    # Units = cylinders of 15376 * 512 = 7872512 bytes
    # Disk identifier: 0x00000000
    #
    # Device Boot Start End Blocks Id System

    *** ***
    *** If this is the wrong drive, then press CONTROL-C now! ***
    *** ***
    Or press ENTER to continue:
    — Available free space on the the USB drive is 7826420 KB
    — Required free space for installer: 28160 KB
    — Copying boot files to the USB drive…
    — Cleaning up the staging area…
    — Making the USB drive ‘/dev/sdb1′ bootable…
    *** usbimg2disk.sh FAILED at line 37 ***
    — Cleaning up the staging area…
    rmdir: failed to remove /mnt/img.an3S2a’: No such file or directory
    rmdir: failed to remove /mnt/usb.vqQDWF’: No such file or directory”

    can you help me?

  13. alienbob

    You are using the parameter “-o /dev/sdb1” which is the partition on the device. But the “-o” parameter expects the device itself, not the partition. Try “-o /dev/sdb” instead.

    Eric

  14. thecat

    the script seemed to work ok just like the previous versions
    this time however it will not boot entirely on my netbook

    i get to:
    Triggering udev events: /sbin/udevadm trigger –action=add

    and then it just sits there.
    ive checked the iso md5 its fine, tried multiple usb sticks and ports and it just wont get past that point.

    any suggestions?

  15. thecat

    the “noudev” option worked like a charm.
    thanks very much! 🙂

  16. Azmi

    Yes it’s work, thanks alienbob

  17. Pietro

    Hey Bob.

    I bought a Netbook as a cheap replacement for my recently departed (and only) machine. It came loaded with win7starter, which was a no-go for me. Your post helped me convert it into a happy Slack 13.1 machine, so I just dropped by to congratulate and thank you for your help.

    If you ever come around to Porto Alegre, I’ll buy you a beer or something.

    Cheers!

  18. bogodes

    Very helpful and simple to use. Also the comments are great on clarifying the whole purpose and each part of the code. Thanks for this great script!

  19. steve

    can not format my usb using mkdosfs in slackware,but parted works great instead

  20. ole

    For those who encounter the “line 37” failure,
    Install these packages:
    cpio
    rsync

    DONE

  21. ole

    Also modify line ~#414 to:

    /usr/bin/syslinux -a -d /syslinux $TARGETPART 1>>$LOGFILE 2>&1
    (the “-s” in the normal config is replaced by “-a”, seems to be a typo)

    you may also need to change the line @ ~122 to reflect the true cylinder size of your usb drive

    for example, mine is:

    /sbin/sfdisk $USBDRV -N1 <<EOF
    0,1018,,*

  22. alienbob

    @ole –

    What script are you using that contains “syslinux -a” ? That is not in any of the scripts that I have distributed as far as I can see.

    Eric

  23. alienbob

    There is an updated version of usbimg2disk.sh here: http://connie.slackware.com/~alien/tools/usbimg2disk.sh

    It fixes the issues people have seen when trying to make the USB stick bootable. The script has already been added to thenon-public Slackware-current tree and you will see that one appear with the next batch of public updates.

    Eric

  24. spc

    Thanks for the update. Much appreciated.

  25. aryr100

    — Available free space on the the USB drive is 7881092 KB
    — Required free space for installer: 1935432 KB
    — Copying boot files to the USB drive…
    cp: cannot create symbolic link /mnt/usb.PUR1Ee/syslinux/extra/flashplayer-plugin’: Operation not permitted
    cp: cannot create symbolic link /mnt/usb.PUR1Ee/syslinux/isolinux/sbootmgr/RAWRITE13.EXE’: Operation not permitted
    sudo bash ./usbimg2disk.sh -i slackware64-1-27-2010.iso -o /dev/sdd
    cp: cannot create symbolic link /mnt/usb.PUR1Ee/syslinux/slackware64/PACKAGES.TXT’: Operation not permitted
    *** ./usbimg2disk.sh FAILED at line 41 ***
    — Cleaning up the staging area…

  26. aryr100

    Worked great using my slack64 box
    thanks alienBOB

  27. harish

    Hello bob,
    I’ve been trying to make an usb bootable drive from a slackware64-13.37-install-dvd.iso image. First i’ve mounted the iso at “/tmp/slackware13” . Also I’ve my-sys installed. Then executed this command

    “ARCH=x86_64 SLACKROOT=/tmp/slack64-13 ./create_multipartboot.sh 4000”

    But it fails showing that it is unable to delete /dev/loop1. The output is as below.

    mkdosfs 3.0.9 (31 Jan 2010)
    Warning: block count mismatch: found 3999712 but assuming 15592.
    Loop device does not match a floppy size, using default hd params
    loop: can’t delete device /dev/loop1: Device or resource busy
    *** ./create_multipartboot.sh FAILED at line 145 ***

    I am stuck and I’ve tried it many times. What should I do?

    ThankYou,
    Harish

  28. neo

    well, i used fedora usb creator to write slack iso on usb. it did boot, however when tried to install, just says installation over in 2 sec ! will figure it soon…meanwhile let me try this script and get back with any comment

  29. Mark

    I have read the how-to to install Slackware on my Netbook (eeePC 1005HA). I’m a new user to Slackware and taking the challenge from the get-go! I want to learn Unix/Linux and what better way to do it than with Slackware I have been told. Anyway, the tutorial i think assumes that I have Linux running on another machine to create a boot USB thumb drive? My netbook has XP installed but it’s corrupted. How can I create the boot image from within windows? I have copied the images and also the script created by Eric and changed the boot order in BIOS but it doesn’t work. I appreciate your help.

    Marco

  30. Mark

    Let me clarify, I copied the boot images into my thumb drive and reboot my machine and it doesn’t work.

  31. alienbob

    Mark,

    I have another blog post for Windows users who want to create a bootable installer for Slackware:
    http://alien.slackbook.org/blog/welcome-windows-user/

    Eric

  32. Mark

    Thanks AlienBob! I have read it and doing the task of installing Slackware today. Best regards.

    Marco

  33. big tuna

    You should take a look at Expect, it would make your life a lot easier. Thanks for the write up, I have been unable to boot Slackware off a usb stick, but I am about to try your script. Appreciate you.

  34. sathish

    Or press ENTER to continue:
    — Formatting /dev/sdb with VFAT partition label ‘USBSLACKINS’…
    — Last chance! Press CTRL-C to abort!
    Or press ENTER to continue:
    — Available free space on the the USB drive is 7800420 KB
    — Required free space for installer: 23828 KB
    — Copying boot files to the USB drive…
    — Extracting Slackware initrd.img…
    — Modifying installer files…
    *** ./usbimg2disk.sh FAILED at line 41 ***
    — Cleaning up the staging area…

    i got the following error. i am trying to install slackware.12.0 to my labtop which doesnt have CD/DVD ROM. In my using ubuntu-12.04 on my desktop to run the following script. and i did mounted the slackware-12.iso

    These are the step i gone through
    #mount -o loop /tmp/slackware.iso /mnt/slack
    #./usbimg2disk.sh -f -s /tmp/slack -o /dev/sdb

    and got the above error as mentioned

  35. ajay

    me to got the same error while trying in ubuntu…
    These are my steps
    #mount -o loop slack/slackware-12.0-install-dvd.iso /mnt/
    #./usbimg2disk.sh -f -s /mnt/ -o /dev/sdb

    # We are going to format and use this device – ‘/dev/sdb’:
    # Vendor : SanDisk
    # Model : Cruzer Blade
    # Size : 7633 MB
    #
    # FDISK OUTPUT:
    #
    # Disk /dev/sdb: 8004 MB, 8004304896 bytes
    # 212 heads, 46 sectors/track, 1603 cylinders, total 15633408 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: 0x21cc8419
    #
    # Device Boot Start End Blocks Id System
    # /dev/sdb1 2048 15633407 7815680 b W95 FAT32

    *** ***
    *** If this is the wrong drive, then press CONTROL-C now! ***
    *** ***
    Or press ENTER to continue:
    — Formatting /dev/sdb with VFAT partition label ‘USBSLACKINS’…
    — Last chance! Press CTRL-C to abort!
    Or press ENTER to continue:
    — Available free space on the the USB drive is 7800420 KB
    — Required free space for installer: 23828 KB
    — Copying boot files to the USB drive…
    — Extracting Slackware initrd.img…
    — Modifying installer files…
    *** ./usbimg2disk.sh FAILED at line 41 ***
    — Cleaning up the staging area…

  36. alienbob

    Try adding “–l /tmp/usbimg2disk.log” and post the content of that logfile here. I do no run Ubuntu so I do not know what it expects. The script is only tested on Slackware.

    Eric

  37. alienbob

    Also, sathish and ajay, could you please try running this script instead? I made a change to a single line which should hopefully show you the actual line in the script where the error occurs (the number “41” is wrong):

    http://www.slackware.com/~alien/tools/usbimg2disk.sh

    Thanks, Eric

  38. J

    Or press ENTER to continue:
    — Setting FAT partition label to ‘USBSLACKINS’
    Total number of sectors not a multiple of sectors per track!
    Add mtools_skip_check=1 to your .mtoolsrc file to skip this test
    *** ./usbimg2disk.sh FAILED at line 355 ***
    — Cleaning up the staging area…

  39. alienbob

    Perhaps you have to follow the advice given in the error output…:

    “Add mtools_skip_check=1 to your .mtoolsrc file to skip this test”

    Eric

  40. alienbob

    … or alternatively, try the updated http://www.slackware.com/~alien/tools/usbimg2disk.sh script, where I added that configuration parameter “mtools_skip_check=1” to the script itself. No need for your own .toolsrc file.

    Eric

  41. J

    It’s working now, thanks!

  42. Juan

    Works fine on a thinkpad X201 without DVD, is perfect. Thank you very much.
    I created the USB key into an old thinkpad T30.

  43. Kamen

    Thank you for the tool. It really helped me.

  44. Blanko

    I simply cannot stress enough how useful this script is. Thank you very much.

  45. Kristian

    Thanks for the script Eric.
    I had to lower the MININSFREE value, as my 2GB usb stick appearantly to small for the 1.3 GB installation..

  46. Nihlaeth

    I’m trying to make an all-in-one usb stick with slackware14 for my new workstation. I’m currently running os x 10.6.8 so I’m doing everything from an arch linux virtual(box) machine.

    Making the usb stick works fine:
    sh usbimg2disk.sh -f -s /mnt/cdrom -o /dev/sdb
    (/mnt/cdrom is the slack14 dvd)

    Only when I insert the usb stick into my workstation it doesn’t recognize it as bootable. I set usb boot as highest priority in the bios and checked if the boot flag was set on the usb partition. Everything like it’s supposed to be.

    I’ve tried dd’ing a modified iso first, it did recognize that as bootable but the image didn’t work. So I don’t think it’s the usb stick.

    Do you have any idea as to what I’m doing wrong?

    p.s. the script does not check if rsync is installed. The error (rsync: command not found) is pretty self explanatory though. I’ve also had to make symlinks for cpio and mkdosfs because the script was looking in the wrong directories under arch linux.

    Thanks in advance!

  47. maitri

    hai !
    I’m newbie I use puppy linux precise pagolin
    I’ve tried your script and it almost 3 hours and it’s not done yet …
    how long does it take to make a slackware usb installer with your script ?
    and how can i tell if your script is still make a slackware usb installer or it just freeze ?
    thanks

  48. verdinand

    I feel like I’m missing something obvious here; I’m trying to figure out how to use this script to create a fully functional USB installer for the 64-bit version of Slackware 14.1, but my main problem is the source code (or lack thereof).

    I obtained the install dvd .iso via torrent, but I had to download the .iso with the source code separately as it was not included on the 64-bit version of 14.1.

    As mentioned in the help file for the script, a Slackware file tree is necessary to create a fully functional usb installer. I’m not sure if/how I’m supposed to get both the 64-bit .iso AND the source code onto the same usb stick for a successful installer, or whether I should be doing something else entirely.

  49. alienbob

    The source code is not required at all. Slackware is a “binary diostribution”, the source code and scripts which produced all the package is available in order to be compliant with the licenses. Having the Slackware DVD ISO should be enough.
    Even better, the official ISO images have been created in such a way (with the help of the ‘isohybrid’ program) that you can write them directly to a USB stick to create a bootable installer. This “usbimg2disk.sh” script may have been obsoleted by the new way of producing the ISOs.

    Eric

  50. aikiwav

    I’m looking for some help using this usb installer on an intel iMac. I’ve created the usb installer using your second example (using my own directories, of course):
    usbimg2disk.sh -f -s /home/ftp/pub/slackware-13.0 -o /dev/sdX

    But the iMac doesn’t recognize the thumb drive as a possible option for booting. Any idea what I might need to do?

  51. alienbob

    Hi aikiwav

    Try removing the “-s” parameter from the “syslinux” call which you can find almost at the end of the usbimg2disk.sh script.

    Alternatively you could try writing the Slackware 14.1 DVD ISO image directly to a USB stick. The new ISOs have been made compatible with USB booting and support UEFI.

    Eric

  52. Dave Brooke

    I’ve been trying to setup a usb bootable memory for doing an install of slackware64 from a slackware-14.1 system but get an error when running usbimg2disk.

    mktemp: invalid option — ‘p’
    Usage: mktemp [-q] [-u] template
    *** ./usbimg2disk.sh FAILED at line 353 ***
    — Cleaning up the staging area…

    As far as I know the packages on the source system are up to date, I’ve moved the script and the img to simplify the paths but keep getting the same error. I did look at the script and thought maybe p should be a q but then I get a failure at the same line with t as the invalid option.

    Dave

  53. alienbob

    Your mktemp is not the one used on a Slackware computer. The “-p” parameter should be recognized as valid.

    $ mktemp -h
    mktemp: invalid option — ‘h’
    Usage: mktemp [-V] | [-dqtu] [-p prefix] [template]

    Eric

  54. Dave Brooke

    Eric,

    I’ll look into that but seems odd since the system has been running slackware for the last ten years and should be running 14.1 at the moment.
    Maybe I’ve not done an upgrade correctly or the mirror I used for source is not up to date.

    Thanks for posting the mktemp options – I can check that easily.

    Dave

  55. Ivelin

    Hi Eric,

    i have this error when trying to install 14.1:
    *** usbimg2disk.sh FAILED at line 375 ***
    which is strange because it “fi” function only…

    Do you have any suggestions.
    Thanks!

  56. alienbob

    Hi Ivelin, I can not comment on that, because the amount of information you supply is simply not enough.
    That the reported line is 375 (with just “fi” in it) will probably mean that the actual error occurred onside the “if” statement for which that “fi’ is the end keyword.

  57. Ivelin

    Hi Eric,

    Sorry for that – I’m using your script usbimg2disk.sh
    I have downloaded the 14.1 slackware iso and then used it to get the slackware directory tree. After running the script downloaded from the last link in this post a get the mentioned error:
    sh usbimg2disk.sh -f -s /home/user/progz/slack14.1/ -o /dev/sdb

    # We are going to format and use this device – ‘/dev/sdb’:
    # Vendor : Kingston
    # Model : DataTraveler 2.0
    # Size : 0 MB
    #
    # FDISK OUTPUT:

    *** ***
    *** If this is the wrong drive, then press CONTROL-C now! ***
    *** ***
    Or press ENTER to continue:
    — Formatting /dev/sdb with VFAT partition label ‘USBSLACKINS’…
    — Last chance! Press CTRL-C to abort!
    Or press ENTER to continue:
    *** usbimg2disk.sh FAILED at line 375 ***
    — Cleaning up the staging area…
    I’m executing it with elevated privileges – su

  58. alienbob

    Ivelin, try what happens if you use the modified version of this script which is shipped with Slackware 14.1: usb-and-pxe-installers/usbimg2disk.sh.

    But first, try running the original script with logging enabled: it needs the additional parameter “-l /tmp/LOGFILE”.
    Afterwards, read that logfile and report what you find there. I think the only possible place where the script is failing, is inside the “reformat” routine. The logfile will reveal that.

  59. Richard Laponte

    I tried using the usbimg2disk.sh from the current repo and had two problems. The first was self inflicted, but I will mention it since Ivelin had the same problem.

    I also got the “…FAILED at line 375.” error. Using the “-l /tmp/LOGFILE, as suggested the log said:

    “dd: failed to open ‘/dev/sdb’: No medium found”
    Acting on an earlier message that said I needed to unmount /dev/sdb1, I mistakenly “ejected” the usb device instead of unmounting the partition, hence the error.

    The second problem is that the script does not make a UEFI bootable USB drive. This is because the EFI/BOOT directory is in the syslinux directory.
    /run/media/rich/USBSLACKINS/
    `– syslinux
    |– EFI
    | `– BOOT
    | |– BOOTX64.EFI
    | |– elilo.conf
    | `– message.txt
    |– f2.txt
    |– huge.s
    |– initrd.img
    |– ldlinux.sys
    |– memtest
    |– message.txt
    |– setpkg
    `– syslinux.cfg

    It needs to be brought up one level to the root of the USB device :
    /run/media/rich/USBSLACKINS/
    |– EFI
    | `– BOOT
    | |– BOOTX64.EFI
    | |– elilo.conf
    | `– message.txt
    `– syslinux
    |– f2.txt
    |– huge.s
    |– initrd.img
    |– ldlinux.sys
    |– memtest
    |– message.txt
    |– setpkg
    `– syslinux.cfg
    With the EFI/ directory at the root of the USB device, it will successfully UEFI boot.

  60. Robinspi

    Well, I am back again. XD

    I built a PC, and I am trying to use the usbimg2disk.sh script to make a usb drive to install slackware to the computer.

    So, I have the same Lexar P20 USB3.0 32GB flashdrive, and I have slackware 64 14.1 downloaded onto a partition of my harddrive (/dev/sda16, I think it is..)

    So, I mounted /dev/sda16 onto /mnt/ and I then I ran the usbimg2disk.sh like so:

    usbimg2disk.sh -f -s /mnt/slackware64-14.1 -o /dev/sdb

    I was so happy that everything ran well… until the very last part of the installation.

    It then gave me an error saying it failed on line 497 which appears to be the very last thing in the script.

    bash-4.2# sh usbimg2disk.sh -f -s /project/9/slackware64-14.1 -o /dev/sdb

    # We are going to format and use this device – ‘/dev/sdb’:
    # Vendor : Lexar
    # Model : USB Flash Drive
    # Size : 30560 MB
    #
    # FDISK OUTPUT:

    WARNING: GPT (GUID Partition Table) detected on ‘/dev/sdb’! The util fdisk doesn’t support GPT. Use GNU Parted.

    #
    # Disk /dev/sdb: 32.0 GB, 32044482560 bytes
    # 64 heads, 32 sectors/track, 30560 cylinders, total 62586880 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: 0x6e023b97
    #
    # Device Boot Start End Blocks Id System
    # /dev/sdb1 2048 62586879 31292416 b W95 FAT32

    *** ***
    *** If this is the wrong drive, then press CONTROL-C now! ***
    *** ***
    Or press ENTER to continue:
    — Formatting /dev/sdb with VFAT partition label ‘USBSLACKINS’…
    — Last chance! Press CTRL-C to abort!
    Or press ENTER to continue:
    — Available free space on the the USB drive is 31277104 KB
    — Required free space for installer: 37040 KB
    — Copying boot files to the USB drive…
    — Extracting Slackware initrd.img…
    — Modifying installer files…
    — Gzipping the initrd image again:
    — Copying Slackware package tree to the USB drive…
    — Cleaning up the staging area…
    — Making the USB drive ‘/dev/sdb’ bootable…
    *** usbimg2disk.sh FAILED at line 497 ***
    — Cleaning up the staging area…
    umount2: No such file or directory
    umount: /mnt/img.qXEk6I: not found
    bash-4.2#

    Here are lines 495-End:

    # Run syslinux and write a good MBR:
    echo “— Making the USB drive ‘$TARGET’ bootable…”
    ( makebootable $TARGET ) 1>>$LOGFILE 2>&1
    /usr/bin/syslinux -s -d /syslinux $TARGETPART 1>>$LOGFILE 2>&1
    dd if=$MBRBIN of=$TARGET 1>>$LOGFILE 2>&1

    # THE END

    What exactly does that mean, and what can I do to solve it?

  61. alienbob

    Robinspi, the official Slackware 14.1 ISO images are “hybrid” which means you do not have to use the usbimg2disk.sh script in order to create a bootable USB stick.
    Just use “cp” or “dd” to copy the Slackware ISO to your USB drive; something like “cp slackware64-14.1-install-dvd.iso /dev/sdb” will work.

    You can still troubleshoot the issue with the script if you want, by adding the parameter “-l output.log” and after the script aborts, you inspect the content of the log file “output.log”.

  62. Robinspi

    Oh… I just… well never mind.

  63. Kivanc KARANIS

    I have an Atom based PC which have a BIOS that can not boot in legacy mode / requires UEFI, and the bios can not execute/load 64-bit EFI (BOOTX64.EFI).
    I`ve tested and aprooved that it can load a 32-bits EFI img.
    Any way to boot a Slackware 32-bits EFI installer ?

  64. kkorhonen

    Used usbimg2disk.sh today to create live-usb for slackware64. Encountered problem with script version:
    # $Id: usbimg2disk.sh,v 1.24 2014/06/08 14:34:46 eha Exp eha $

    — Extracting Slackware initrd.img…
    *** usbimg2disk.sh FAILED at line 437 ***
    — Cleaning up the staging area..

    from log file found:
    gzip: /mnt/usb.6V0aiG/syslinux/initrd.img: not in gzip format
    cpio: premature end of file

    also:
    file -bi slackware64-current/isolinux/initrd.img
    application/x-xz; charset=binary

    Solution was to change gunzip to xz from line 463:
    # gunzip -cd ${MNTDIR2}/syslinux/initrd.img | cpio -i -d -H newc –no-absolute-filenames
    xz -cd ${MNTDIR2}/syslinux/initrd.img | cpio -i -d -H newc –no-absolute-filenames

    • alienbob

      The version of usbimg2disk.sh that you used seems to come from the “source/installer” directory. However, Patrick removed some of its functionality and added that to “usb-and-pxe-installers”. The script in “source/installer” is not maintained.
      Why did you use this script to attempt and create a USB Live disk? It’s not meant for that – its goal is to create a USB version of the Slackware installer.
      The liveslak project has a “iso2usb.sh” script to transfer a Slackware Live ISO to a USB stick.

  65. kkorhonen

    I meant usb installer, called live-usb just out of habit. Needed usb installer to install without network.

    I checked the usb-and-pxe-installers from the source dir today, it has usbimg2disk.sh which version info says
    # $Id: usbimg2disk.sh,v 1.23 2012/09/03 20:52:31 eha Exp eha $
    I tested it and it works. So the version that is in the slackware64-current source tree works out of the box.

    The version I downloaded from http://www.slackware.com/~alien/tools/usbimg2disk.sh has version info
    # $Id: usbimg2disk.sh,v 1.24 2014/06/08 14:34:46 eha Exp eha $ so I used that version initially.

    But for my needs its probably easiest to stick to the version found from the usb-and-pxe-installers dir. The version string just threw me off.

  66. I ran into a couple problems using it on the new slackware release.

    They switched from gzip to xz for compression, and there was no cd before the cpio, so it blew the files all over my work directory instead of where it wanted them.

    Here\’s a patch. It finished running, but I won\’t know if it wil actually install until I finish my installation.

    I left a couple pieces of my debugging code in it, cause I didn\’t want to retest. It\’s late. Sorry.

    — usbimg2disk.sh 2020-05-24 02:44:23.386639949 -0400
    +++ ../usbimg2disk.sh 2020-05-24 02:38:59.670568156 -0400
    @@ -38,7 +38,7 @@
    [ ! -z \”${MNTDIR2}\” ] && ( umount -f ${MNTDIR2} ; rmdir $MNTDIR2 )
    [ ! -z \”${MNTDIR3}\” ] && rm -rf ${MNTDIR3} || true
    }
    -trap \’echo \”*** $0 FAILED at line $LINENO ***\”; cleanup; exit 1\’ ERR INT TERM
    +trap \’echo \”*** $0 FAILED at line $LINENO ***\”; echo cleanup; exit 1\’ ERR INT TERM

    showhelp() {
    echo \”# \”
    @@ -458,13 +458,14 @@
    # If we are creating a full Slackware installer, there is a lot more to do:
    if [ \”$FULLINSTALLER\” = \”yes\” ]; then
    # Extract the Slackware initrd for modifications we have to do:
    – echo \”— Extracting Slackware initrd.img… ($PWD)\”
    – ( cd ${MNTDIR3}/
    – xz –decompress –stdout ${MNTDIR2}/syslinux/initrd.img | cpio -i -d -H newc –no-absolute-filenames
    – ) 2>> $LOGFILE
    + echo \”— Extracting Slackware initrd.img…\”
    + (
    + gunzip -cd ${MNTDIR2}/syslinux/initrd.img | cpio -i -d -H newc –no-absolute-filenames
    + ) >> $LOGFILE
    +
    # Modify installer files so that installing from USB stick will be easier:
    echo \”— Modifying installer files…\”
    – ( cd ${MNTDIR3}/ && pwd | tee /dev/stderr
    + ( cd ${MNTDIR3}/
    # Try to automatically mount the installer partition:
    mkdir usbinstall
    echo \”mount -t vfat -o ro,shortname=mixed \\$(/sbin/blkid -t LABEL=$FATLABEL | cut -f1 -d:) /usbinstall 1>/dev/null 2>&1\” >> etc/rc.d/rc.S

    • alienbob

      Hi,

      I think the problem is that you are actually are using that 11-years old script taken from Slackware 13.0. It is too old and won’t work now. This script is still present in Slackware until this day and modified to make it still work.

      If you look at the history of that script since 13.0 (https://git.slackware.nl/current/log/usb-and-pxe-installers/usbimg2disk.sh) you’ll notice that it has had many modifications, one of them being in Slackware 13.1 when the initrd.img modification (adding /usbboot) was introduced and then Slackware 14.2 which saw the removal again of that functionality.

      In my scripts nowadays I make sure that I use the correct decompressor for an initrd using a function like:

      uncompressfs () {
      if $(file “${1}” | grep -qi “: gzip”); then
      gzip -cd “${1}”
      elif $(file “${1}” | grep -qi “: XZ”); then
      xz -cd “${1}”
      fi
      }
      uncompressfs initrd.img | cpio -i -d -m -H newc

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

© 2024 Alien Pastures

Theme by Anders NorenUp ↑