I Have a 16GB USB drive. I found out that multiple partitions on USB drives are possible. I need to make two partitions, one that contains Linux OS and the other one for storing files. A system like any other system (An OS Partition with different file storage partition). I want the storage partition to be accessible by Windows, which means that the storage partition should come before the OS partition in USB. The problem is, when storage partition is before the OS partition, the OS partition is useless and BIOS can't detect an OS if I select USB on boot. I think installing GRUB may solve problems but 'install-grub' throws errors.
Bootable usb thumb drive with 2 (or more) partitions, and windows to access the data partition.
Edit: This example uses an ISO instead of an installed OS. It should be simple to adjust for an installed OS.
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
- partition 3 - linux swap
The second partition is where you will store the bootable iso, or the installed OS. Use grub to load and select what OS you want to use.
1: Zero out partition table on the USB device.
dd if=/dev/zero of=/dev/sdx bs=512 count=4
2: Create partitions (use cli "fdisk" or gui "gparted")
Create partition table "msdos" type.
3: Install grub bootloader to usb device.
Mount ext partition on USB to PC.
mount /dev/sdx2 /mnt/usbp2
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 the host pc.
sudo grub-mkconfig --output=/mnt/usbp2/boot/grub/grub.cfg
Test by booting to usb.
When you boot the USB drive you should get a list of the OS that was on the host PC not the empty USB, but this will test the grub and grub config that is on the USB.
5: Copy support files to the USB.
installed OS image from clonezilla or the like.
memdisk binary -- get from syslinux
6: Edit the
grub.cfg on the USB for your ISOs and installed OS.
Each live ISO may require different grub information.
If you only get a grub command line, your
grub.cfg probably contains errors. Go minimal to start like a single ISO.