How to make an E2B USB drive using linux
You can install E2B to an existing partition on a USB drive using the /_ISO/docs/linux_utils/fmt.sh (FAT32) or fmt_ntfs.sh (NTFS) linux bash shell script which is included in all Easy2Boot download files (v1.83+).
Note: E2B is now provided as a Windows self-extracting .exe - rename it with a .zip file extension and then extract the E2B files from it using 7Zip.
The .sh script will format an existing partition, then it will copy the E2B files onto it and then run bootlace to install grub4dos:
- Download and unzip the Easy2Boot file to a folder on your internal linux hard disk (rename .exe to .zip first - ensure no spaces in folder path) - use 7Zip to extract the files if any problems (sudo apt-get install 7zip).
- Open a Terminal session at the \_ISO\docs\linux_utils folder (contains utilities and scripts)
- Use chmod to make the files in linux_utils executable (sudo chmod 777 *)
- Type ./fmt.sh or ./fmt_ntfs.sh (this requires the bash shell - if you are using the sh shell you will get errors - or try sudo bash ./fmt.sh)
Read the ReadMe file in the \_ISO\docs\linux_utils folder for more details and see the article on www.rmprepusb.com #114
or my blog post here
To format a partition as NTFS, you can use fmt_ntfs.sh
and use the 32-bit executable udefrag
to defrag the files (E2B v1.83+)
For best bootability, I strongly recommend you create a small (hidden) primary partition at the end of the USB drive as well (use gparted).
You should make all payload (ISO) files contiguous under linux:
- Use defragfs on FAT32 volumes.
- Use udefrag -om /dev/sdX1 for NTFS volumes (see ReadMe file in linux_utils folder).
E2B will try up to three different methods to boot most linux ISO files, these are (in order):
- Add the ISO as an extra USB partition (ISO file must be contiguous)
- Copy a non-contiguous ISO to a contiguous file (CONTIG.ISO) using dd and then use method 1 above
- Try to identify the type of linux ISO from it's file name and use linux cheat codes to boot from ISO (isoboot)
How to update E2B
Simply extract the files from the E2B download and copy them to your E2B USB drive to update the E2B version (or use the cp command).
If you prefer, you can use something like: rsync -auv E2Bnew/ /myUSBdrive/
The linux scripts only format a pre-existing partition on your USB drive.
For best bootability/compatibility with all systems, your E2B USB drive should contain 2 PRIMARY PARTITIONS.
The second primary partition can be very small and unformatted or it can be larger and formatted - it just needs to be there!
Some BIOSes will not boot from a USB Flash drive correctly unless there are two or more primary partitions. If there is only one Primary partition, some BIOSes will attempt to boot from the USB drive as a floppy disk or super-floppy or ZIP drive and grub4dos will fail to boot correctly.
Also, for best compatibility, you should ensure that the E2B partition is marked as 'Active' (has the boot flag set) and that grub4dos is installed to both the MBR (LBA0) and the Partition Boot Record of the E2B partition (PBR).
Also, do not place any EFI boot files on the E2B drive (i.e. there should be no \EFI folder on the E2B drive). The presence of valid EFI boot files can prevent some BIOSes from booting to the E2B grub4dos menu - they will always try to EFI-boot instead!
If you use the Windows .cmd script to make your E2B USB drive, these features are fully automated for you. You can still use linux to add your ISOs and defrag the files afterwards.
After you have run the E2B format .sh script, you should copy your payload files onto the USB drive.
Tip: Never download an ISO directly on to the USB drive because the file may be heavily fragmented (due to multiple download threads being used). Always download the ISO to your internal hard disk first and then copy it to the USB drive.
for details of where to copy your payload files.
After copying payload files, make sure that all files are contiguous (see below).
File Extensions and 'Auto-suggest'
For instance, to boot to MiniXP from a Hirens Boot CD, you should name the iso file with a .isowinvh file extension or answer 'Y' when prompted by E2B.
for more details.
Making files contiguous
Most ISOs and all persistence files need to be contiguous for best and fastest use.
Windows .VHD and .WIM files don't need to be contiguous.
Note that if you are using large ISOs, you will need a much larger drive because at least as much contiguous free space is needed (e.g. a non-contiguous 3GB ISO on an 8GB NTFS drive cannot be made contiguous because there is not enough free space!).
Fig. 1 FILE4 cannot be de-fragmented due to insufficient contiguous free space. The free space clusters must first be consolidated (e.g. by using Windows Defraggler).
Note: NTFS volumes will usually have directory files at the 3GB point - these files cannot be moved.
Defragging a volume, or making files contiguous on a volume, may not always be successful due to lack of free space.
To defrag files on a FAT32 volume use...
sudo perl ~/Downloads/Easy2Boot/_ISO/docs/linux_utils/defragfs /media/Multiboot -f
If using an NTFS volume, then defrag the whole volume (udefrag is in the \_ISO\docs\linux_utils folder):
sudo umount /dev/sdb1
sudo ./udefrag -om /dev/sdb1
Note: udefrag is a 32-bit program, you will need to install 32-bit libraries if you have 64-bit linux (see the ReadMe file for details).
To run udefrag under Ubuntu 64-bit:
sudo dpkg --add-architecture i386
sudo apt-get update
sudo apt-get install libc6:i386 libncurses5:i386 libstdc++6:i386
(change to _ISO/docs/linux_utils folder)
sudo chmod 777 *
sudo udefrag -om /dev/sdX1 (where sdX1 is your NTFS USB partition)
Tip: If you have problems making files contiguous, copy your ISO files into the source download E2B folder structure on your internal linux hard disk first, and then run the fmt_ntfs.sh script to copy all the files to the USB drive.
E2B includes a 500MB contiguous empty file \_ISO\CONTIG.ISO. This is used by E2B if you attempt to boot from an ISO which is not contiguous.
file will usually be contiguous because it was copied to the E2B USB drive immediately after it was formatted by the fmt_ntfs.sh script.
E2B will use dd to copy the non-contiguous ISO file to CONTIG.ISO and then boot from CONTIG.ISO. In this was, E2B can make non-contiguous files contiguous!
You can delete CONTIG.ISO to make more free space on the USB drive, but all files will need to be contiguous
You can replace CONTIG.ISO with a larger file (you can use ANY larger file, just name it \_ISO\CONTIG.ISO), but the CONTIG.ISO file must be contiguous.
To use a larger file, I suggest you delete CONTIG.ISO from the download source folder and replace it with a larger file of the same name.
Be aware that using dd to copy a 3GB ISO to CONTIG.ISO will take some time however, and E2B will have to use dd each time you run E2B!
If you are booting a linux ISO and it cannot be made contiguous, E2B will use a similar technique to MultiSystem, XBOOT or YUMI and try to boot from the ISO using known linux cheat code parameters ('isoboot
'). However, only some linux distros are supported and this method may not work on new releases because new versions seem to always change the boot parameters!
[SHIFT]+[ENTER] - If you hold down the SHIFT key before you press the ENTER key, E2B will only use isoboot to attempt to boot a linux ISO.
Creating files containing ext2/3/4 filesystems for persistence
For persistence, you often need to create a file which is formatted internally as an ext2/3/4 filesystem (instructions are always inside the .mnu file). To do this under linux AND have it contiguous (which is required for E2B) - see the thread here
Use cd to get to the directory where you have mounted the USB drive - e.g. /media/USBDrive, then create a file as follows (example uses 1GB mint-rw, volume name is normally casper-rw)
dd if=/dev/zero of=mint-rw bs=1M count=1024
mkfs -t ext2 mint-rw -L casper-rw
or for ext3
mkfs.ext3 -F mint-rw -L casper-rw
Making a sparse file using dd may be faster, try this...
dd if=/dev/zero of=casper-rw bs=1M count=0 seek=1024
Testing using QEMU under linux
1. Run following command to find the E2B USB drive (use lowercase -L for list)
sudo fdisk -l
2. Boot using qemu-system-x86_64
sudo qemu-system-x86_64 -machine accel=kvm:tcg -m 512 -hda /dev/sdc
"/dev/sdc" is the usb device as listed by fdisk, 512 is the amount of memory to allocate.
Note that QEMU may prevent or delay normal file writes during or after use. After using QEMU, run sync and check that any changes you have made to the E2B drive have actually occured by dismounting and removing the E2B USB drive and re-connecting it again - then check file contents.
Unfortunately, there is no linux equivalent of the MakePartImage.cmd Windows script which makes .imgPTN files.
You can run Windows from a Virtual Machine under linux and use the MakePartImage scripts from within Windows.
If you want to try UEFI-booting to linux
ISOs without using a Windows system and without needing to make the files contiguous, try the E2B grub2 menu system
(for 'experts' only!).