Lweb
Boot multiple iso from USB using SYSLINUX
  1. Partitions and Formatting

    Partitions and Formatting on usb device

    Create partitions and filesystem. You can find your device using "lsblk" command. In my case it is sdb.

    Create two primary partitions partitions with any program fdisk/gdisk/parted/gparted your prefer. First reasonably large one is "0b" fat32 partition for boot files and the second one is for iso files. The first partition should be active.

    The partition table should be looked as below

                Disk /dev/sdb: 3.69 GiB, 3963617280 bytes, 7741440 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
                Disklabel type: dos
                Disk identifier: 0xbc1ec006
    
                Device            Boot  Start     End Sectors  Size Id Type
                /dev/sdb1         *      2048  206847  204800  100M  b W95 FAT32
                /dev/sdb2              206848 7741439 7534592  3.6G 83 Linux
            

    Format both partitions: first as vfat and the second one as ext2

                sudo mkfs.vfat /dev/sdb1
                sudo mkfs.ext2 /dev/sdb2
            

    Install syslinux

                sudo dd bs=440 count=1 conv=notrunc if=/usr/share/syslinux/mbr.bin of=/dev/sdb
                sudo syslinux --directory syslinux --install /dev/sdb1
            

    Partitions and Formatting on usb disk image file.

    You can create an empty image file, say syslinuxdisk.img, with fallocate, dd, or qemu-img commands

                fallocate -l 4G syslinuxdisk.img
                dd if=/dev/zero of=syslinuxdisk.img bs=1M count=4M
                qemu-img create -f qcow2 syslinuxdisk.img 4G
            

    I prefer to make image file which exactly fit to usb drive.

                dd if=/dev/sdb of=syslinuxdisk.img bs=1M status=progress oflag=sync
            

    Finally, you can partition image file in similar way as real device with e.g. fdisk.

                Disk syslinuxdisk.img: 3.69 GiB, 3963617280 bytes, 7741440 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
                Disklabel type: dos
                Disk identifier: 0xbc1ec006
    
                Device            Boot  Start     End Sectors  Size Id Type
                syslinuxdisk.img1 *      2048  206847  204800  100M  b W95 FAT32
                syslinuxdisk.img2      206848 7741439 7534592  3.6G 83 Linux
            

    Further format partitions as vfat and ext2 and install syslinux on the first partition.

                sudo dd bs=440 count=1 conv=notrunc if=/usr/share/syslinux/mbr.bin of=syslinuxdisk.img
                sudo losetup /dev/loop2 syslinuxdisk.img -o 1048576 --sizelimit 104857088
                sudo mkfs.vfat /dev/loop2
                sudo mkdir /mnt/usb
                sudo mount /dev/loop2 /mnt/usb
                sudo syslinux --directory syslinux --install /dev/loop2
                sudo umount /mnt/usb
                sudo losetup -d /dev/loop2
                sudo losetup /dev/loop5 syslinuxdisk.img -o 105906176 --sizelimit 3962568192
                sudo mkfs.ext2 /dev/loop5
                sudo mount /dev/loop5 /mnt/usb
            
  2. Copy iso files

    Create a directory, e.g. ISO, on the second partition and copy iso files in the directory

                sudo mkdir /mnt/usb/ISO
                sudo rsync --info=progress2 openSUSE-Leap-15.3-KDE-Live-x86_64-Media.iso /mnt/usb/ISO/opensuse.iso
                sudo umount /mnt/usb
            
  3. Syslinux configuration

    I prefer to copy main syslinux files in the root directory on vfat partition, so that /dev/sdb1 partition has following structure:

                boot
                boot/syslinux/....
                boot/menu/
                boot/menu/default.cfg
                boot/menu/tools.cfg
                boot/menu/opensuse.cfg
                boot/grub
                ......
                suseboot
                suseboot/linux
                suseboot/initrd
                open
                cmd.c32
                hdt.c32
                ldlinux.c32
                ldlinux.sys
                libcom32.c32
                libgpl.c32
                liblua.c32
                libmenu.c32
                libutil.c32
                menu.c32
                suseboot
                syslinux.cfg
            

    Main configurational file syslinux.cfg is found in the root directory whereas other cfg files are located in the directory /boot/menu

    The default.cfg file contains the menu layout commands. I use a nice very simple layout:

                #default.cfg
                MENU TITLE Boot USB - Main menu
                MENU MARGIN 0
                MENU ROWS -9
                MENU TABMSG
                MENU TABMSGROW -3
                MENU CMDLINEROW -3
                MENU HELPMSGROW -4
                MENU HELPMSGENDROW -1
                MENU COLOR SCREEN 37;40
                MENU COLOR BORDER 34;40
                MENU COLOR TITLE 1;33;40
                MENU COLOR SCROLLBAR 34;46
                MENU COLOR SEL 30;47
                MENU COLOR UNSEL 36;40
                MENU COLOR CMDMARK 37;40
                MENU COLOR CMDLINE 37;40
                MENU COLOR TABMSG 37;40
                MENU COLOR DISABLED 37;40
                MENU COLOR HELP 32;40
            

    The tools.cfg includes some useful tools:

                #tools.cfg
                MENU SEPARATOR
     
                LABEL -
                    MENU LABEL BOOT TOOLS:
                    MENU DISABLE
                
                LABEL hdt
                    MENU LABEL Hardware Info
                    COM32 hdt.c32
                
                LABEL reboot
                    MENU LABEL Reboot
                    COM32 /boot/syslinux/reboot.c32
            

    The main config file, syslinux.cfg, enables boot different linux live OS as well as other loaders such as GRUB.

                UI /boot/syslinux/menu.c32
                MENU INCLUDE /boot/menu/defaults.cfg
    
                LABEL -
                    MENU LABEL BOOT TYPES:
                    MENU DISABLE
                
                LABEL Boot from Hard Drive
                    MENU LABEL Windows 10 (hd0)
                    KERNEL /boot/syslinux/chain.c32
                    APPEND hd0
                    MENU DEFAULT
    
                LABEL opensuse
                    MENU LABEL openSUSE Live ISO 
                    KERNEL /boot/syslinux/menu.c32
                    APPEND /boot/menu/opensuse.cfg
                
                LABEL usbosboot
                    MENU LABEL Boot OS from USB
                    KERNEL /boot/syslinux/vesamenu.c32
                    APPEND /boot/menu/usbosboot.cfg
                
                LABEL grub4dos
                    MENU LABEL GRUB4DOS
                    KERNEL /boot/grub/grub.exe
                
                LABEL grub2
                    MENU LABEL GRUB2
                    COM32 /boot/syslinux/chain.c32
                    APPEND file=/boot/grub2/i386-pc/core.img
    
                MENU INCLUDE /boot/menu/tools.cfg
            

    The only relevant part related to iso boot is under label opensuse where opensuse.cfg looks like

                #opensuse.cfg
                MENU INCLUDE /boot/menu/defaults.cfg
    
                LABEL -
                    MENU LABEL BOOT OS:
                    MENU DISABLE
    
                LABEL livesuse
                    MENU LABEL openSUSE LiveDVD 15.3 Leap (nopersistent)
                    LINUX /suseboot/linux
                    APPEND root=UUID=c08caa7d-be72-4400-9930-0a46a5134bd7 rw rootwait  iso-scan/filename=/ISO/openSUSE.iso root=live:CDLABEL=openSUSE_Leap_15.3_KDE_Live loader=isolinux splash=silent quiet showopts initrd=/suseboot/initrd
                
                MENU SEPARATOR
                
                LABEL -
                    MENU LABEL BOOT DEVELOPMENT (not working):
                    MENU DISABLE
    
                LABEL suselin1
                    MENU LABEL openSUSE LiveDVD 15.3 Leap - CDLABEL
                    set isofile="/ISO/openSUSE.iso"
                    set isolabel="openSUSE_Leap_15.3_KDE_Live"
                    loopback loop $isofile
                    LINUX (loop)/boot/x86_64/loader/linux boot=isolinux iso-scan/filename=$isofile root=live:CDLABEL=$isolabel ro rd.live.image rhgb
                    APPEND initrd=(loop)/boot/x86_64/loader/initrd
                
                
                LABEL livesuse2
                    MENU LABEL openSUSE LiveDVD 15.3 Leap 
                    set isofile="/ISO/openSUSE.iso"
                    set isolabel="openSUSE_Leap_15.3_KDE_Live"
                    LINUX /suseboot/linux
                    APPEND root=UUID=c08caa7d-be72-4400-9930-0a46a5134bd7 rw rootwait  iso-scan/filename=$isofile root=live:CDLABEL=$isolabel loader=isolinux splash=silent quiet showopts initrd=/suseboot/initrd
                
                LABEL suselin3
                    MENU LABEL openSUSE LiveDVD 15.3 Leap - rd.live.image rhgb
                    LINUX /suseboot/linux
                    APPEND root=UUID=c08caa7d-be72-4400-9930-0a46a5134bd7 rw rootwait loop=/ISO/openSUSE.iso loader=isolinux rd.live.image rhgb initrd=/suseboot/initrd
                    
                LABEL susemem2
                    MENU LABEL openSUSE LiveDVD 15.3 Leap - memdisk try?
                    KERNEL /boot/syslinux/memdisk
                    APPEND root=UUID=c08caa7d-be72-4400-9930-0a46a5134bd7 rw rootwait initrd=/ISO/openSUSE.iso iso raw 
                    
                LABEL susechain
                    MENU LABEL openSUSE LiveDVD 15.3 Leap - chain
                    KERNEL /boot/syslinux/chain.c32
                    APPEND hd1 1 initrd=ISO/openSUSE.iso
                    
                LABEL susechain2
                    MENU LABEL openSUSE LiveDVD 15.3 Leap - chain disk1
                    KERNEL /boot/syslinux/chain.c32
                    APPEND hd1 1 boot isolinux=/opensuse/boot/x86_64/loader/isolinux.bin
                    
                LABEL susechain3
                    MENU LABEL openSUSE LiveDVD 15.3 Leap - chain disk0
                    KERNEL /boot/syslinux/chain.c32
                    APPEND hd0 1 boot isolinux=/opensuse/boot/x86_64/loader/isolinux.bin
    
                MENU INCLUDE /boot/menu/tools.cfg
            

    All entries under BOOT DEVELOPMENT are non working and are given only for references.

    UUID of the partition with iso files (/dev/sdb2) can be found with blkid command:

                sudo blkid /dev/sdb2
                #output:
                /dev/sdb2: UUID="c08caa7d-be72-4400-9930-0a46a5134bd7" BLOCK_SIZE="4096" TYPE="ext4" PARTUUID="bc1ec006-02"
            

    Finally, one should put kernel and initrd files from linux distribution on FAT partition. I put the them on both partitions in the directory opensuse.

                sudo mount -o loop openSUSE-Leap-15.3-KDE-Live-x86_64-Media.iso /mnt/iso
                sudo mount /dev/sdb1 /mnt/usb
                sudo mkdir /mnt/usb/suseboot
                sudo cp /mnt/iso//boot/x86_64/loader/linux /mnt/usb/suseboot/
                sudo cp /mnt/iso//boot/x86_64/loader/initrd /mnt/usb/suseboot/
                sudo umount /mnt/usb
                sudo umount /mnt/iso
            

    Now you can try to boot opensuse from usb.

    For testing of the image or usb stick one can use qemu

                qemu-system-x86_64 -m 512 -hda syslinuxdisk.img (or /dev/sdb)
            

    Good luck!

  • Boot Linux from USB. part I

    Multiple boot using GRUB2 from live ISO files located on USB
    Read more ...

  • Boot Linux from USB. part II

    Multiple boot using SYSLINUX from live ISO files located on USB
    Read more ...

  • Tweet update.

    Added tweet on @lloadm
    Read