sábado, 1 de julho de 2017

Ultimate Guide for Multiboot USB - All Your CD/DVD Live on a USB

For many years, all IT enthusiasts struggle with CD and DVD for system installations, upgrades, recovery or just to test a new release.

Also I was always having problems with GPL, shareware, freeware, IDEs, scripts, and other initiatives that  from time to time stop working, or don't support your target distro or go buggy.

I had a hard time dealing with BIOS/EFI/UEFI different standard, brands and approaches to bootstrap your system and startup a selected OS from a block or stream device (ie. HDD, ODD, SSD, etc.)

To make it even more difficult, old BIOS desktops usually make USB option very difficult task (since USB is relatively new in PC world of BIOS devices).  So many updated solutions just drop support for old systems, and people like me that like to use old (but as good as new) devices that are neglected by the Y/Z generation, but in some cases are the very best to help many who can not afford continuous updates of hardware (almost every six months), specially for poor countries and community schools.  And also to have a positive environmental attitude: reduce, reuse, recycle.

So after many years testing all options available I believe that now I have a stable (and understandable), straightforward solution.

Dependencies:

1. Have a working GNU distribuition (I use Ubuntu 14.04.5 i686)
2. Syslinux - isohybrid - Postprocess ISO images for hybrid mode
3. dd - convert, copy a file to devices
4. gparted (and also a win32 VM with a partition program if needed)
5. nano, vi or gedit (or any editor)

Procedure steps:

1. Start by downloading the Live ISO image you would usually burn a CD/DVD.

2. Prepare the ISO to be usable on a USB/HDD/SSD by the command:

  isohybrid --partok <name_of_iso_file>

Ref: http://www.syslinux.org/wiki/index.php?title=Isohybrid

3. Partition a new USB (or backup it first and clean all files from it) as the following:

3.1. Now with a clean USB you can just start by resize it using gparted or a win32 partitioning application, so that is about 512MB and leave all the rest as free space.

Notice that you will not need to much space for the first partition because it should hold only the syslinux modules, configuration files and your customization image for background.

3.2. Now create as many new partitions as needed to accommodate each live ISO you will want to boot, but follow this rule: use a round value always larger than the ISO file size.  Exemple: for 1.1GB ISO use a 1.5/2GB partition.  For a 220MB ISO use a 512MB partiton.  For a 640MB use a 1GB partiton.  Usually 512MB increments is a good rule, but avoid very tight choices, exemple: for a 1.9GB choose 2.5GB not 2GB.  This is just to avoid last minute problems and have to start all over again.  Remember, this takes time.  But this is not a strict order, try it out if you need to save space

3.3.  Remember that DOS only understands 4 primary partitions and on USB only ONE, so you should a good strategy is to create a extended partition and many logical partitions (as many as you wish/need), limited to your USB available space/size, remember that sectors usually are in 512 bytes increments.

4. Format the first partition as FAT (FAT16 not FAT32).  Sometimes FAT32 will work, but FAT16 will make first bootloader sector be on the right spot (on sector number 63) or you will hack it with fdisk and more the first sector to position 63.

Tip:
The bootloader must start on setor 63, which is the physical sector number (or LBA) containing the first sector of the partition (unlike the sector count used in the sectors value of CHS tuples, which counts from one, the absolute or LBA sector value starts counting from zero).

Ref: https://en.wikipedia.org/wiki/Master_boot_record#Disk_identity


5. Install syslinux bootloader (I use example that my USB is /dev/sdb):

  syslinux --directory /boot/syslinux/ --install /dev/sdb1

Ref: http://www.syslinux.org/wiki/index.php?title=Install#Linux


6. Edit the /boot/syslinux/syslinux.cfg and insert the ISO partitions you will create, one by one, following this framework at the end of the file:

#start partition X  where X is 2,3...n
LABEL ubuntu-sdbX
MENU LABEL <Name the ISO>
COM32 chain.c32
APPEND boot X
#end


Example:

You could use the following syslinux.cfg:

# This file was created origionally by MultiBootUSB.
default vesamenu.c32
prompt 0
menu title John's MultiBoot USB
#MENU BACKGROUND image
MENU BACKGROUND MYU-bg.png
TIMEOUT 300
MENU WIDTH 80
MENU MARGIN 10
MENU PASSWORDMARGIN 3
MENU ROWS 12
MENU TABMSGROW 18
MENU CMDLINEROW 18
MENU ENDROW -1
MENU PASSWORDROW 11
MENU TIMEOUTROW 20
MENU HELPMSGROW 22
MENU HELPMSGENDROW -1
MENU HIDDENROW -2
MENU HSHIFT 0
MENU VSHIFT 0
MENU COLOR border       30;44   #40ffffff #a0000000 std
MENU COLOR title        1;36;44 #9033ccff #a0000000 std
MENU COLOR sel          7;37;40 #e0ffffff #20ffffff all
MENU COLOR unsel        37;44   #50ffffff #a0000000 std
MENU COLOR help         37;40   #c0ffffff #a0000000 std
MENU COLOR timeout_msg  37;40   #80ffffff #00000000 std
MENU COLOR timeout      1;37;40 #c0ffffff #00000000 std
MENU COLOR msg07        37;40   #90ffffff #a0000000 std
MENU COLOR tabmsg       31;40   #30ffffff #00000000 std
label Boot from Hard Drive
MENU LABEL Boot from  Hard Disk
KERNEL chain.c32
APPEND hd1
MENU DEFAULT

#start extended partition 5
LABEL ubuntu-sdb5
MENU LABEL Ubuntu 14.04.5 i686(32bits)
COM32 chain.c32
APPEND boot 5
#end ubuntu extended

#start extended partition 6
LABEL ubuntu-sdb6
MENU LABEL Ubuntu 14.04.5 amd (64bits)
COM32 chain.c32
APPEND boot 6
#end ubuntu extended

#start extended partition 7
LABEL ubuntu-sdb7
MENU LABEL GParted Live 0.28
COM32 chain.c32
APPEND boot 7
#end ubuntu extended


REF:  http://multibootusb.org/


7. Now lets copy the prepared ISO files (see previous procedure 2)

  dd if=<prepared ISO file name> of=/dev/sdbX bs=2048

Please double check your device location (use df -h) and also check the correct partition to set the X variable of the command, since each partition was made with the size as a critical factor.

That is it, you now have a MULTIPLE BOOT USB for ISO live images.

To test the new multiboot usb use qemu with the command:

qemu-system-i386 -enable-kvm -localtime -m 1024M \
-vga std -drive file=/dev/sdb,cache=none,format=raw,if=virtio


Check this screenshot of a 4GB USB stick (32/64 bits ubuntu and gparted ISOs)




Please share your tests and help make it better.

Cheers!

Nenhum comentário:

Postar um comentário