Make an E2B USB drive using Linux
I recommend that you use a Windows 10 system to make an E2B USB drive because it is much easier. Many useful Windows-based E2B utilities are also available.
Once you have made the E2B USB drive, you can use Linux to configure it, add payloads, etc.
If you only have a Linux system available, you will need to follow the instructions below:
First ensure your USB drive has two Primary MBR Partitions (not GPT). I suggest:
Ptn1: Primary Active (Max 128GB) – will be formatted by shell script provided
Ptn2: Primary FAT32 (min. 200MB – max 32GB) I recommend 600MB to 1GB
Use GParted or a similar partitioning tool.
The .sh scripts provided will format an existing partition, then it will then copy the E2B files onto it and then run bootlace to install grub4dos:
- Download and unzip the Easy2Boot .ZIP file to a folder on your internal linux hard disk – use Desktop GUI or 7Zip to extract the files (sudo apt-get install 7zip).
- Open a Terminal session at the new \_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)
Note: be sure to select the correct partition such as sdb1or you will get a ‘MISSING MBR HELPER’ error message when you boot!).
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 recommended) linux bash shell script which is included in the Easy2Boot download files.
- Note: if you get a ‘permission denied‘ error, precede the command with sudo.
- Password ‘e2b‘ may be requested.
- Use Linux GUI to extract the files to a new folder (e.g. E2B) or use command line…
md E2B 7z x ./Easy2Boot_v2.04_password_is_e2b.zip -o.\E2B sudo su - cd ./E2B/_ISO/docs/linux_utils sudo chmod 777 * (or chmod u+x *) mount sudo lsblk sudo bash ./fmt.sh (or sudo bash ./fmt_ntfs.sh)
For a 64-bit system, you will need to install i386 support (use the add-32-bit-support.sh script or see below).
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, use instead the fmt_ntfs.sh script and use the 32-bit executable udefrag to defrag the files.
You should make all payload (ISO) files contiguous under linux:
- Use defragfs on FAT32 volumes.
- Use udefrag -qm /dev/sdX1 for NTFS volumes, where X is the device letter, e.g. /dev/sdb1 (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)
I recommend adding agFM to the 2nd partition for direct UEFI booting (see below). Also, in many cases agFM will be able to boot from fragmented files and so running udefrag is not required.
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/
Tip: use the –preallocate switch to avoid fragmentation of files.
agFM for UEFI booting
To add agFM to the E2B USB drive for UEFI booting you simply need to create a second FAT32 Primary partition of 60MB or more in size and then extract the agFM files to that partition:
Partition 1: NTFS with E2B files (max. 128GB for maximum compatibility)
Partition 2: FAT32 with agFM files (max. 32GB for maximum compatibility) – 600MB+ recommended
IMPORTANT: Both partitions must be Primary partitions.
1. Download agFM
2. Extract the files to the FAT32 partition.
See here for details on agFM. Updating is done in the same way.
If you have added agFM, you can also add Ventoy.
- Ventoy does not require the payload files to be contiguous.
- You can Secure UEFI64-Boot to Ventoy by first booting to agFM.
1. Update your E2B files to v2.05 or later
2. Update the agFM files on partition 2 (download – unzip – overwrite all files on partition 2 with the new files) – must use agFM v1.57 or later
3. You now need to add the Ventoy files (latest version e.g. 1.0.20).
First make a new folder E2B_VENTOY on your computer somewhere…
4. Download the latest Ventoy for Easy2Boot release as a .zip file.
Open the zip file using 7zip and open the ventoy.disk.img folder (e.g. \ventoy-1.0.xx -ventoy – ventoy.disk.img.xz – ventoy.disk.img)
Extract all the folders to the empty E2B_VENTOY folder (four folders in all)
5. We need to change some files in these new E2B_VENTOY folders:
The Certificate file ENROLL_THIS_KEY_IN_MOKMANAGER.cer can be deleted.
Go to the E2B_VENTOY\EFI\BOOT folder…
- Rename the file grubx64_real.efi to ventoyx64.efi
- Rename the file grubia32_real.efi to ventoyia32.efi
- Delete all other files in the EFI\BOOT folder.
6. The .zip file should contain a core.img file (top level) – extract the core.img file to the E2B_VENTOY\ventoy folder
7. Your E2B_VENTOY folder should now contain these new files (amongst the old files\folders)…
- E2B_VENTOY\EFI\BOOT\ventoyx64.efi (used for UEFI64 booting)
- E2B_VENTOY\EFI\BOOT\ventoyia32.efi (used for UEFI32 booting)
- E2B_VENTOY\ventoy\core.img (used for Legacy\MBR BIOS booting)
- E2B_VENTOY\ventoy\ventoy.cpio (used for Legacy\MBR BIOS booting)
- E2B_VENTOY\tool and \grub folders
8. Now simply copy the entire contents of the E2B_VENTOY folder to the root of the 2nd partition of your E2B USB drive which should already contain agFM boot files. You should not be prompted to overwrite any existing files on the USB drive – if you are then you did something wrong (or you are updating an existing version of Ventoy)!
Do NOT overwrite any existing files when you add the E2B_VENTOY files (unless updating an earlier version).
Check your 2nd partition now has a new /tool folder (as well as existing /ventoy, /grub and /EFI + others).
Now you can boot to agFM first and then press F5 to boot to Ventoy. Legacy, UEFI32 and UEFI64 using Ventoy should all work.
Copying payload files
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 onto 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.
See here for details of where to copy your payload files. After copying payload files, make sure that all files are contiguous (see below). If you have problems making files contiguous when the drive becomes full, you may find it quicker to use this method:
1. Delete the 500MB \_ISO\CONTIG.ISO file from the download folder (to improve the copy speed)
2. Add all your ISO files, etc., into the download folder structure
3. Run fmt.sh or fmt_ntfs.sh to make a new E2B drive
4. Defrag the drive (not necessary if the drive is freshly formatted)
Making files contiguous
E2B requires most ISOs and all persistence files to be contiguous for best and fastest use.
agFM does not require all ISOS to be contiguous depending on menu option.
Ventoy does not require any file to be contiguous (but you must use standard file extensions).
Usually Windows .VHD and .WIM files don’t need to be contiguous.
Note that if you are using large ISOs, you will need a large drive because when defragmenting a file, 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!).
Note: NTFS volumes will usually have directory files ($MFT) 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 contiguous 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 run the add-32-bit-support.sh script…
sudo dpkg --add-architecture i386 sudo apt-get update sudo apt-get install libc6:i386 libncurses5:i386 libstdc++6:i386
and then run udefrag…
(change to _ISO/docs/linux_utils folder) sudo chmod 777 * sudo ./udefrag -om /dev/sdX1 (where sdX1 is your NTFS USB partition) - use -qvm instead of -om for quicker optimisation.
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. Untested to defrag whole NTFS partition:
Type “su” and enter password for root when prompted.
Type “fsck -t ntfs –kerneldefrag /dev/sdX1” without quotes. Replace “sdX1” with the drive letter of your E2B disk.
You may aso try to compile a later version of udefrag if you wish UltraDefrag for Linux (untested).
Note: Both the agFM and Ventoy can boot non-contiguous ISOs.
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.
The CONTIG.ISO 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 way, 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 copying a 3GB ISO to CONTIG.ISO will take some time however, and E2B will have to use dd to do this each time you select the ISO!
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 non-contiguous linux ISO.
Use a .isoboot file extension if you always want to boot an ISO using ISOBOOT.
Also try the agFM and Ventoy menu systems.
File Extensions and ‘Auto-suggest’
E2B may suggest a ‘better’ file extension to use based on the file name or contents (the auto-suggest feature). 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.
The linux scripts provided 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 because 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).
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! The only remedy is to temporariliy remove the EFI boot files (e..g. rename the \EFI folder) so that the BIOS will provide a Legacy boot option.
Creating files containing ext2/3/4 filesystems for persistence
Linux LiveCD ISOs + persistence can be made using .mnu files. For persistence, you often need to create a persistence 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 (recommended because ext2 can be easily corrupted!): mkfs.ext3 -F mint-rw -L casper-rw
Making a sparse file using dd may be faster (untested), try this…
dd if=/dev/zero of=casper-rw bs=1M count=0 seek=1024
sh CreatePersistentImg.sh [ -s SIZE_IN_MB ] [ -t FSTYPE ] [ -l LABEL ] [ -c CFG ] for example: sh CreatePersistentImg.sh ----> persistence.dat in 1GB size and ext4 filesystem and casper-rw label sh CreatePersistentImg.sh -l MX-Persist ----> persistence.dat in 1GB size and ext4 filesystem and MX-Persist label sh CreatePersistentImg.sh -s 2048 ----> persistence.dat in 2GB size and ext4 filesystem and casper-rw label sh CreatePersistentImg.sh -s 4096 -t xfs ----> persistence.dat in 4GB size and xfs filesystem (ext2/3/4 xfs are supported) and casper-rw label sh CreatePersistentImg.sh -l persistence -c persistence.conf ----> persistence.dat in 1GB size and ext4 filesystem and persistence label. Finally will create a persistence.conf file inside the persistence.dat. The file only has 1 line "/ union". Some distros have this requirement (e.g. Debian/Kali/CloneZilla...)
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 occurred by dismounting and removing the E2B USB drive and re-connecting it again – then check the 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 ISOs then add the agFM files to the second FAT32 partition (E2B v2).You can also add Ventoy (see above) and boot to that menu system via agFM. Ventoy does not require the ISO file to be contiguous.
Restore E2B partition after booting to Linux from a .imgPTN file (E2B v1.A9+)
If you have switched to a .imgPTN file and booted to Linux, you can run the Restore_E2B.sh script to restore the E2B partitions.
1. Type Ctrl+Alt+t at the desktop to get a terminal window
2. cd to the /e2b/ folder on the USB drive – e.g. cd /cdrom/e2b (type lsblk to find the USB drive’s mountpoint)
3. Type sudo bash Restore_E2B.sh4. Enter the device path of the USB drive – e.g. /dev/sdb
IMPORTANT: Very little checking is done by the script – make sure you select the correct drive!
Under Ubuntu, the command can be shortened to sudo bash /cdrom/e2b/Restore_E2B.sh
If necessary, you may have to type these commands instead to make the file executable…
sudo cp Restore_E2B.sh /home/
sudo chmod u+x Restore_E2B.sh
sudo bash /home/Restore_E2B.sh
Under linux, the USB drive contents will not appear to change until you unplug&reinsert or reboot (you can try sudo partx -u /dev/sdX but it may not work if the drive is mounted and locked).
When you reboot from the USB drive, the MBR E2B menu system will load. If you have an older version of a .imgPTN file which does not contain the Restore_E2B.sh script, you can copy the file to the /e2b folder on the USB drive after you have switched it in.
These must be made using Windows to run the MakePartImage.cmd script. However, you can mount these files under linux using a command like:
mount -o loop arch.imgPTN /mnt
Once mounted, you can modify the contents as desired, before unmount and sync is used.