I have a bootable USB disk:
# dd if=/path/to/os_image.iso of=/dev/sdb
(...everything OK...)
# sudo dumpe2fs /dev/sdb
dumpe2fs 1.42.9 (4-Feb-2014)
dumpe2fs: Bad magic number in super-block while trying to open /dev/sdb
Couldn't find valid filesystem superblock.
GParted doesn't recognize any partitions (screenshot), the GUI file manager reports filesystem as isofs
. The system boots and everything works fine.
The problem is, I want to use the USB disk for a live OS and as a storage with PCs and TVs which only recognize FAT32 and NTFS.
I have tried creating two partitions, doing dd
on sdb1
and making sdb1
the only bootable partition, but the system didn't boot.
So my question is: how to put both FAT32/NTFS and (any) bootable ISO image on an MBR-partitioned disk without using an external bootable-usb-creator program? I would like to simply use dd
, as I do now.
Presumably this could be solved using the right bootloader with the right configuration, I just don't know which bootloader and what configuration.
Bootable usb thumb drive with 2 partitions.
Windows and others may only see the first partition on a usb device even when there are multiple partitions. Therefore make your first primary partition the fat32 or NTFS partition so windows can see and use it.
partition 1 - ntfs or vfat
partition 2 - ext4
The second partition is where you will store the bootable iso. Use grub to load and select what live OS you want to use.
steps:
1: zero out partition table
sudo dd if=/dev/zero of=/dev/sdx bs=512 count=4
2: Create partitions (use cli “fdisk” or gui “gparted”)
create partition table "msdos"
create 2 partitions
p1 = ntfs
p2 = ext4 -- tag as bootable.
format partitions.
3: Install grub bootloader to usb device
sudo grub-install --boot-directory /mnt/usbp2/boot /dev/sdx
Verify: If these exist all is well so far...
4: Create a grub.cfg file for the OS's on this pc
sudo grub-mkconfig --output=/mnt/usbp2/boot/grub/grub.cfg
Test by booting to usb
5: Copy support files to the usb
Note: each live iso may require different grub information.
Note: If you only get a grub command line, your grub.cfg probably contains errors. Go minimal to start.
6: Create your custom usb boot installer.
Copy the MBR and Partition Table
dd if=/dev/sdx of=/custom_boot/cb_mbr.img bs=512 count=1
Copy the bootable partition
dd if=/dev/sdx2 of=/custom_boot/cb_ext4.img bs=512
7: Create new bootable usb device
Delete all existing partitions and clean MBR
fdisk or gparted (delete partitions)
dd if=dev/zero of=/dev/sdx bs=512 count=1
restore MBR and Partition Table
dd if=/custom_boot/cb_mbr.img of=/dev/sdx bs=512
Restore bootable partition
dd if=/custom_boot/cb_ext4.img of=/dev/sdx2 bs=512
Fix the first partition and reformat (fat32 or ntfs)
fdisk or gparted
My grub.cfg
My Notes
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments