Results 1 to 10 of 1252

Thread: Howto make USB boot drives

Threaded View

  1. #1
    Join Date
    Nov 2011
    Location
    /dev/root
    Beans
    Hidden!

    Howto make USB boot drives

    This thread follows the development of the tool mkusb

    - You get an overview in this first post.

    - You can skip to the end of the thread to read about current problems, tweaks and solutions.

    There are two improvements in mkusb version 12.5.6

    - mkusb-tow 'TO Windows' is a new tool to make a Windows installer boot drive ported from mkusb-plug to mkusb-dus. It works well with most current Windows iso files, including those with a file, install.wim, that expands to more than 4 GiB. So two partitions are created, one with FAT32 to boot from and one with NTFS where the main content of the iso file is extracted. The old mkusb method, that works well in 32-bit systems (but not when install.wim exceeds 4 GiB) is still available.

    - When running in an installed system booted in UEFI mode mkusb-dus selects method silently for persistent live drives. This is made because it is nowadays common to run Ubuntu in this way, and we still want to make drives that boot both in UEFI mode and BIOS mode. Earlier there were warnings, that compressed files were extracted instead of running commands because the grub tool to create a BIOS bootloader (grub-pc) is not compatible with grub for UEFI (grub-efi).

    You may notice some improvements in mkusb version 12.5.7

    - Sparky Linux is recognized as a working host operating system by mkusb (alongside Ubuntu and the Ubuntu family flavours and Debian).

    - watch-flush is imported from mkusb-plug to mkusb-dus in order to show what is happening while the system i flushing the buffers (during writing to a USB drive or memory card).

    The programs watch-flush and mkusb-tow are moved from the mkusb-plug package to the mkusb-common package. This may cause a hiccup when upgrading from a previous version. You can fix it with the following commands

    Code:
    sudo apt update
    sudo apt -f install        # this is the crucial command line with -f, --fix-broken
    sudo apt install mkusb
    Please notice that you need other commands when you want to install mkusb the first time:

    Code:
    sudo add-apt-repository universe  # this line only for standard Ubuntu live
    Code:
    sudo add-apt-repository ppa:mkusb/ppa          # stable PPA for regular usage
    # sudo add-apt-repository ppa:mkusb/unstable   # PPA for development and testing; remove the # in front of the command to use it
    sudo apt update
    sudo apt install mkusb
    
    sudo apt install usb-pack-efi  # for persistent live drives that work in UEFI and BIOS mode with 32-bit iso files

    mkusb-plug is a new and very reliable tool to create a USB boot drive

    When you intend to create a USB boot drive, you should use a tool that is as reliable as possible. It should help you identify the target drive (avoid overwriting data in another drive) and it should create a working bootable drive.

    - Standard mkusb version 12 alias mkusb-dus has served us well for years, and is still the main 'mkusb choice' for the current versions of Ubuntu (and the community flavours Kubuntu, Lubuntu ... Xubuntu) including 18.04.x LTS.

    - Now there is a new version, mkusb-plug, that is even safer. It can create 'plain' cloned USB boot drives of most Linux distros, and also persistent live drives of Ubuntu 19.10 and newer versions. It uses a plug-in method to make the identification of the target drive very safe, and you are welcome to start using it.

    With version 2.4.1, now upgraded to version 2.4.4, there is a desktop file 'mkusb-plug.desktop', so you can start mkusb-plug

    - like any other graphical program

    - but also from a terminal window according to the help text
    Code:
     $ mkusb-plug -h
     Tool to create boot drive, typically a live USB drive
     Usage:    mkusb-plug [source file]
     Examples:
               mkusb-plug linux.iso           # make live drive
               mkusb-plug linux.img           # clone image file
               mkusb-plug ubuntu-19.10+.iso   # make persistent live
               mkusb-plug debian-10+.iso      # make persistent live
               mkusb-plug -v                  # version
               mkusb-plug -h                  # help
    The terminal window will serve as console for the program.

    'Like any other graphical program' means

    - via the menu or other way to access programs graphical desktop programs (depending on the desktop environment)

    - via right-clicking on an iso file
    . select 'Open with ...'
    . expand 'System Tools' and select mkusb-plug

    - The next time you can expect the desktop environment to remember your choice, so that it will be easier to select mkusb-plug.

    Read more and install mkusb-plug from this link



    Quick start manual and mkusb

    The fastest way to start making USB boot drives is to install the mkusb PPA, install and update the mkusb package like all the other program packages. See this link
    https://launchpad.net/~mkusb/+archive/ubuntu/ppa

    If you run standard Ubuntu live, you need an extra instruction to get the repository Universe. (Kubuntu, Lubuntu ... Xubuntu have the repository Universe activated automatically.)

    Text after the # character is not used by the shell interpreter, it is a comment for the human eye.

    Code:
    sudo add-apt-repository universe  # this line only for standard Ubuntu live
    Code:
    sudo add-apt-repository ppa:mkusb/ppa          # stable PPA for regular usage
    # sudo add-apt-repository ppa:mkusb/unstable   # PPA for development and testing; remove the # in front of the command to use it
    sudo apt update
    sudo apt install mkusb
    
    sudo apt install usb-pack-efi  # for persistent live drives that work in UEFI and BIOS mode with 32-bit iso files
    You can download the quick start manual(s) at this link http://phillw.net/isos/linux-tools/mkusb/



    - View or download the new quick start manual mkUSB-quick-start-manual.pdf
    - View or download the nox (text-mode) quick start manual mkUSB-quick-start-manual-nox.pdf

    Alternative: You find alternate links at Quick start (if http://phillw.net/isos/linux-tools/mkusb/ is temporarity down).

    If you want to try the current version of mkusb, get it via the PPA.

    There are more details (text and screenshot pictures) at the wiki page https://help.ubuntu.com/community/mkusb

    Warning about overwriting the target device

    mkusb will 'use the whole device', actually only the head end (size of the iso file), but the rest of the device is not available. mkusb simply clones the ISO 9660 file system with its content from the iso file. This ISO 9660 file system works from CD/DVD disks, and also from USB drives. After using a USB pendrive like this, you make a new partition table and file system, if you want to use it for another purpose.

    Help selecting the correct target device

    The crucial task of mkusb was and is to help selecting the correct device and avoid overwriting other devices.



    Doing the same thing many times

    For the first time I had been helping to test a new Ubuntu version (Lubuntu 12.04 LTS). After a while I wanted to make itsimpler and safer to transfer the code to the USB pendrive. I have been happy using unetbootin, because of its high success rate. I also tested Ubuntu's startup disk creator usb-creator-gtk, which has the advantage that you reach Ubuntu's first screen, that is skipped by unetbootin. Both tools work with my computers and can be used to create persistent live systems.



    dd image of iso file to USB device safely

    But I also read somewhere that it should be possible to boot from a direct image of the iso file. So I tried it with dd, the disk destroyer ;-) And it works, the computer boots from a USB device (pendrive, stick, flash drive, but also disk or SSD) just like it were from a CD drive. Also like a CD, it will be mounted read-only, so it cannot carry persistence.

    Since dd is a bit risky, I made a shell-script, so that you get advice from a help text window and have to run dd manually only once, but with support from the script to avoid writing to any internal drive. The first time you must select the correct USB device, if more than one are connected. So it is safer and also much more convenient (but not 100%).

    The next daily build will automatically select the correct USB device (when it is inserted into the computer). So for the next daily builds it is safe and very convenient.

    I cloned an ubuntu-desktop-amd64.iso this way, and the USB pendrive works in both UEFI and CSM (BIOS) modes.

    Shell script

    The shell-script has been updated and improved and will be updated again when necessary. It is now convenient to use also for one-off creations of USB boot devices from iso files and compressed image files and also to wipe the drives if necessary after the cloning. The shellscript can monitor the data transfer with pv, and suggests that you install it, if not available. Notice that pv shows Mibibytes and dd shows Megabytes.

    Here is the shell-script for anyone to use or improve.

    Download mkusb from the following link

    http://phillw.net/isos/linux-tools/mkusb

    There are also previous versions for users that like simple scripts.

    Use the current md5sum.txt.asc file to check that the md5sum matches before you start using mkusb!

    Verify that this signed md5sum file is correct with the following commands

    Code:
    gpg --keyserver hkp://pgp.mit.edu --recv-keys EB0FC2C8
    gpg --verify md5sum.txt.asc
    
    The output should be something like

    Code:
    gpg --keyserver hkp://pgp.mit.edu --recv-keys EB0FC2C8
    ... 
    gpg: key EB0FC2C8: public key "Nio Sudden Wiklund (sudodus) <address@mailserver.com>" imported (or not changed the second time ...)
    ...
    gpg --verify md5sum.txt.asc
    gpg: Signature made Sat Aug  2 12:09:06 2014 CEST using RSA key ID EB0FC2C8
    gpg: Good signature from "Nio Sudden Wiklund (sudodus) <mail address>"
    gpg: WARNING: This key is not certified with a trusted signature!
    gpg:          There is no indication that the signature belongs to the owner.
    Primary key fingerprint: 0303 EA77 E34C 52F2 2958  47C6 BD43 C742 EB0F C2C8
    The warning "This key is not certified with a trusted signature! There is no indication that the signature belongs to the owner." means that there is no chain of trusted keys between your computer's keyring and the key, that was used to sign the md5sums (the key of sudodus). Check that the result matches, when you verify it: The md5sums and the signature of your output of these commands should match. Then there is reason to trust that nobody else has written the mkusb script file and its md5sum. The date of the signature will change at updates, and the text might be translated to your local language, but it should be clear that it is a

    'Good signature from "Nio Sudden Wiklund (sudodus)"'.



    mkusb-nox

    mkusb-nox is supplied via the PPA. It works in text screens, 'No X', and can do 'everything' that mkusb version 9 can do (but without eye candy). The improved recognition of operating systems in iso files and devices is ported is ported from version 9.

    https://help.ubuntu.com/community/mkusb/v7

    Code:
    sudo add-apt-repository ppa:mkusb/ppa  # and press Enter to accept it
    sudo apt-get update
    sudo apt-get install mkusb-nox
    mkusb-bas

    A very basic version of mkusb is made for old and/or very small operating systems (suitable for very old computers and as portable systems). mkusb-bas is tweaked to run in TinyCore and Wary Puppy. See this link

    mkusb version 7.4.x - mkusb-bas

    mkusb minimal shellscript - mkusb-min

    mkusb-min is simple, the shellscript is very small compared to the other versions, yet it serves the purpose to wrap a safety belt around 'dd'.

    Small and flexible

    - mkusb-min needs no extra packages (but makes the user experience nicer, if you install pv). It runs in text screens, terminal windows, via ssh and other network connections.

    - mkusb-min works in many different linux distros. It needs bash, some standard tools and features, that are present in almost all current linux distros (2017).

    There are more details, for example how to download mkusb-min and how to use it, at the following link,

    help.ubuntu.com/community/mkusb/min



    Wipe the CD file system

    I should add, that if you want to re-use a USB drive that has been used like this, you should wipe it with dd (overwrite with zeros), otherwise grub-install doesn't want to write into the mbr area, because it recognizes the CD file system, iso9660. (You need not wipe it before cloning.)

    You can use the shell-script also for this task and wipe the whole drive, 'wipe-whole-device', but often it is enough to wipe the first megabyte of the drive, 'wipe-1'.

    Code:
    $ sudo -H mkusb wipe
    It is very important that you wipe your intended target drive and nothing else. It will be completely wiped, not even PhotoRec can do anything after that operation. But there are other (and better) tools to wipe an entire HDD or SSD for example hdparm or DBAN.

    And after that you can use gparted to make a new partition table (for example MBR) and suitable partition(s) for example FAT32 with boot and lba flags.

    mkusb 10.2 introduces a 'wipe menu' with several useful options

    • s "Standard: create MSDOS partition table with FAT32 partition"
    • b "Big drive: create GUID partition table with NTFS partition"
    • g "General: use 'gparted' to make partition table and partition(s)"
    • a "Advanced: create GUID partition table (skeleton for installing an OS)"
    • f "wipe the First megabyte (mibibyte)"
    • w "wipe the Whole device - consider other options except for special cases"


    Several iso files can be cloned to working USB pendrives

    ISO files that can be be cloned to working USB boot drives are called hybrid iso files.

    There are mkusb PPAs for {Ubuntu, Kubuntu, Lubuntu, Xubuntu ...} {12.04 LTS, 14.04 LTS, 14.10, 15.04} alias {precise, trusty, utopic, vivid}. mkusb can make working USB installers also from the Ubuntu mini.iso. See this link.

    New: You find working mini.iso files for 12.04 LTS (32-bits pae (and non-pae in a subdirectory)) at this link - precise-updates.

    Arch
    Bento
    Bodhi
    Clonezilla (mkusb-nox)
    Debian Jessie
    Fedora (uses simpler black & white menus because zenity lacks support for html) (live only)
    Knoppix (needed treatment with isohybrid)
    Linux Mint
    LXLE
    Mageia (live only)
    openSUSE (live only)
    ToriOS
    Webconverger

    while some other iso files did not work (although they make good CD boot disks). It is often possible to convert such an iso file to a hybrid iso with the following command

    Code:
    isohybrid downloaded-file.iso
    It converts the iso in-place (the file is overwritten), so make a copy before you run isohybrid if you want to keep the original file untouched. See the following link

    http://gparted-forum.surf4.info/view...d=30798#p30798

    Complete install to USB

    I also installed Lubuntu to a 16 GB USB pendrive, a complete install, like to a HDD. It was a little tricky with the swap partition, so now I know, why people advice, that you should disconnect the internal drive before doing it. This pendrive is truly portable, and probably better than a persistent live system. Please avoid proprietary drivers, if you want portability! There are several compressed image files, that were made from such installed systems, and they can be installed with mkusb. See the following links,

    help.ubuntu.com/community/Installation/UEFI-and-BIOS

    AskUbuntu: Boot Ubuntu from external drive

    Booting USB drives with grub2 and iso files 'grub-n-iso'

    64-bit versions work only in 64-bit computers. 32-bit versions work in 32-bit and 64-bit computer (with BIOS, but not with UEFI, unless you use the methods described in the following paragraph).

    The 'grub-n-iso' method uses grub2 to boot from an iso file, so once you have such a USB pendrive, you can boot most Intel and AMD computers that can run a 32-bit system (except very old non-PAE systems, systems with too low RAM, and systems with non-compatible hardware). The 'grub-n-iso' method can be used to create multi-boot USB pendrives by selecting iso file to boot from in the grub menu.

    You can use the shell-script mkusb also for this task, to clone a compressed image from a file file.img.gz to a USB drive. You can download such files from http://phillw.net/isos/linux-tools/uefi-n-bios/

    mkusb can make persistent live drives

    A modified 'grub-n-iso' method is used, when mkusb creates persistent live drives. See details at mkusb/persistent

    One pendrive for all PC (Intel/AMD) computers - Ubuntu 64-bit and Lubuntu 32-bit

    The following four systems are downloaded as compressed image files and installed via mkusb

    1. One pendrive for all PC (Intel/AMD) computers - Ubuntu 64-bit and Lubuntu 32-bit

    There are methods now to make 32-bit Ubuntu family operating systems boot in UEFI mode via grub and iso files, 'grub-n-iso'. This makes it possible to make a USB pendrive with persistence, that is very portable between different computers :smile:

    2. A smaller and simpler pendrive for all PC (Intel/AMD) computers - 'grub-n-iso' - Lubuntu 32-bit

    3. Multiboot pendrive system for all PC (Intel/AMD) computers

    4. Make persistent live drives with casper-rw and home-rw partitions New 2018-04-30: a shellscript developed within the 'grub-n-iso' method, mk-persistent-live_with_home-rw.

    -o-

    The system with compressed image files makes it easy for a beginner to install, but it is rather inflexible. So I made a shell-script, that does the main part of the work with the help of a couple of files for the configuration of the booting system. See this link

    Build your own single boot or multiboot pendrive for all PC (Intel/AMD) computers



    References to tutorials and tips how to make USB boot drives

    Ubuntu help page - FromUSBStick
    Ubuntu help page - mkusb
    Ubuntu wiki page - Win32DiskImager/iso2usb
    Ubuntu wiki page - Win32DiskImager/compressed-image_2_USB-or-SD
    Ubuntu help page - UEFI-and-BIOS
    Attached Images Attached Images
    Last edited by sudodus; September 12th, 2022 at 05:05 PM. Reason: changes are described in the following posts

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •