Linux – How to partition a USB drive so that it’s bootable and has a Windows-compatible data storage partition

linuxlive-usbpartition

split from here

I have a 16gb flash drive, which I want a live ISO to boot from (via unetbootin or something similar). It'll be some 32bit distro that I can plug-in and boot on whatever computer I need to. Since it will be a live ISO, I'll need somewhere to save data. I want the USB drive to have about 1gb for the distro, and the other 15gb for data storage.

I made two FAT partitions, the first called 'bootable' and the second 'storage'. The storage works fine in Linux, but Windows only sees the bootable partition. The storage isn't accessible.

How can I make the data accessible on Windows, and still have a bootable distribution? If the answer is how to partition it, please include the order and type of each partition. Do I need swap space for this, or is this handled differently?

Best Answer

I would do it like this (assuming that sdb is your stick):

Delete any previous partition table:

# dd if=/dev/zero of=/dev/sdb bs=512 count=1

Create the new ones:

# fdisk /dev/sdb
> n
> p
> 1
(+1GB)
> a
> 1
(toggles boot flag)
> t
> c
(filesystem type)
> n
> p
> 2
(defaults)
> t
(specify 2nd partition)
> c
(filesystem type)
> p
(prints current configuration)
> w
(write the new table and quit)

Create the filesystems:

# mkfs.vfat /dev/sdb1
# mkfs.vfat /dev/sdb2
Related Question