0

I have a bootable USB stick as shown in the screenshot:

# 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 the filesystem as isofs. The system boots and everything works fine.

The problem is, I want to use the USB stick 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.

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.

2 Answers 2

1

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...

  • /mnt/usbp2/boot/grub/fonts -- minimum unicode.pf2
  • /mnt/usbp2/boot/grub/i386-pc -- *.mod modules to load in you grub.cfg
  • /mnt/usbp2/boot/grub/local -- languages
  • /mnt/usbp2/boot/grub/grubenv -- environment variable storage

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

  • iso files
  • memdisk binary -- get from syslinux
  • grub.cfg -- custom for your usb stick. Overwrite grub.cfg created by grub-mkconfig

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

4
  • here is my grub.cfg I live boot gparted, "Super grub disk", Acronis" and others.
    – jc__
    Commented Jul 6, 2016 at 15:26
  • grub-install was giving error "Attempting to install GRUB to a disk with multiple partition labels", probably because I set the label for both partitions when formatting them. Then, in GParted, I created a new table with two partitions and formatted them without setting the labels. Still the same problem. I used --force, and now I get grub console instead of a menu. In your grub.cfg I replaced your entries by mine, for which I used your PartedMagic entry and only changed iso, first argument to linux and argument to initrd. No error messages from grub at boot. Any ideas what is wrong?
    – kyrill
    Commented Jul 7, 2016 at 9:51
  • See answer for update. Note steps 4 and 5. If you have a grub command line you are almost there.
    – jc__
    Commented Jul 7, 2016 at 17:29
  • Sorry, problem was between keyboard and chair -- a simple mistake in grub.cfg. Everything works fine now, except for the grub-install error (both partitions are always called "CDROM", even after e2label /dev/sdc2 '' and fatlabel /dev/sdc1 ''), but with --force, it installs. Thanks.
    – kyrill
    Commented Jul 7, 2016 at 22:46
0

To make this explicit -

  • "I would like to simply use dd, as I do now."
  • "Windows and others may only see the first partition on a usb device even when there are multiple partitions."

I don't think these goals are practical to achieve, so you will have to compromise somewhere.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .