Saturday, August 26, 2017

How to make a Linux Live USB with a 2nd, Windows-readable partition for storage


Subscribe by Email!
This article is a "Notes to Self" article. That means I wrote it for my own personal reference and use, with myself as the target audience during drafting, but decided to post it here because I believe it is useful to others too, and I want to reach as many people as possible, not just me. 

Ever wanted to have a bootable Linux USB flash drive with a separate, Windows-readable partition for general file storage? Here's how.

By Gabriel Staples
Written: 26-27 May 2016
Posted online: 26 Aug 2017
Updated: 26 Aug 2017

The Gist of it/The super short version:
-for the experienced Linux user
  1. Use gparted on a Linux computer to make 2 FAT32 partitions on the thumb drive. The partition created first must be for storage, while the 2nd one must be for the Linux distro you are putting on the Live USB.
  2. Use UNetbootin on a Linux computer to install your iso file for the Live USB onto the 2nd partition you just made above.
  3. Done. You can now boot from the USB thumb drive, from its 2nd partition, while its 1st partition only is readable and usable by Windows still (as well as by Linux or Mac too of course).

Detailed Steps:
-for the less-experienced Linux user, and/or any general person who knows how to use Google to answer questions and fill in any blanks
  1. Insert a USB thumb drive into an Ubuntu-based Linux Computer, or a computer running an Ubuntu-based Operating System from a (single-partitioned, for example) Live USB.
    1. Don't have a Linux computer yet?—use UNetbootin (https://unetbootin.github.io/) on Windows to create a Live USB onto a single-partitioned thumb drive, and use that thumb drive as a Live Linux disk.
    2. Boot up onto this Live USB and install gparted with:
      1. sudo apt-get update
      2. sudo apt-get install gparted
    3. Alternatively, download the Parted Magic iso file (costs ~$9 last I checked, here: https://partedmagic.com/--it's worth it—has many useful features), and install it onto a Live USB, using UNetbootin. Parted Magic comes with gparted already installed.
  2. Use Gparted to create a new partition table
    1. First, delete all partitions, then, create a new MBR/msdos partition table:
    2. Device --> Create Partition Table --> "msdos" [to create an MBR partition table for best compatibility]
  3. Create 2 new partitions on the drive. I'm installing Kubuntu 16.04LTS (http://www.kubuntu.org/), so I'll make the first partition FAT32 and call it "StorageKubu," for example. Leave ~4096 MB (4GB) for the 2nd partition. Make the 2nd partition FAT32 as well and call it "Kubuntu64" (signifies Kubuntu 64-bit in my case) or give it whatever name you like to correspond to the Linux distro you want to put on it.
    1. IMPORTANT NOTE 1: your “storage” partition must be the first partition or else Windows won't be able to see it when you want to use it as a normal thumb drive, since Windows can only see the first Windows-compatible partition on a USB thumb drive.
    2. IMPORTANT NOTE 2: ALSO NOTE THAT “FIRST” HERE CORRESPONDS TO THE ORDER IN TIME THAT YOU CREATE THE PARTITIONS, NOT THE SPATIAL ORDER OR PHYSICAL LOCATION ON THE DISK. In short, the “first” partition is the first partition in time you make on the disk, regardless of its physical location on the disk. The “second” partition is the second partition in time you make on the disk, regardless of its physical location on the disk, etc.
  4. Use the UNetbootin application in Linux to create a startup disk on the 2nd partition, which you named "Kubuntu64," for example (as created above), from a downloaded iso file of the Linux distro you'd like to install. (Ex: download the Kubuntu iso file here: http://www.kubuntu.org/. Other Ubuntu-based Linux distros, for example, are described and linked to here: http://www.ubuntu.com/download/ubuntu-flavours.)
    1. Note that if you don't have UNetbootin on your Linux system, you can install it into any Ubuntu or Ubuntu-based Linux distro with the following commands:
      1. sudo apt-get update
      2. sudo apt-get install unetbootin
    2. Now, in UNetbootin, choose the iso file to be installed on the thumb drive, selecting the “Diskimage” option at the bottom, and clicking the three dots (“...”) button to set the path to the iso file you just downloaded above.
    3. Set the “Space used to preserve files across reboots” (persistence file) value to ~2GB or so. Here, I typed in “2048” MB.
    4. For the “Drive” option, use the drop-down menu to select the 2nd partition you just created above (the one I named “Kubuntu64”).
      1. We are doing this with UNetbootin in Linux because in Windows UNetbootin cannot even see this 2nd partition, due to Windows limitations.
    5. Click “OK” to begin. It should take about 10~20 minutes or so, and will have to copy over ~1.5GB of files from the iso image, plus it will install a bootloader and create a persistence file (which I set to 2048 MB above) on the 2nd partition to store settings and things between reboots of the Live USB.
  5. Done! You now have a dual-partitioned Live USB thumb drive, with the 1st partition being a “storage” partition, and the 2nd one being for the Live USB Linux operating system files. Windows will only be able to see the 1st partition, so if you're ever using the Live USB as a normal computer-on-the-go, be sure to store all your files you may want to read with Windows later in the first partition only.
ADVERTISEMENT:

Notes, including misc. problems & solutions:
  • First off, it is worth noting that not all USB thumb drives will work for booting, not all USB ports and or hubs on your computer will work for booting, and not all live USB creator programs will work either.
    • So, if these steps don't work, try the following:
      • Use a different USB port on your computer.
      • If you are using a USB hub, remove it; or conversely, if you are not using a USB hub, try adding one.
      • Change the USB thumb drive you are using; some work well as Live USBs, some do not.
        • For example, these did NOT work for me as Live USBs, though otherwise they seemed to work fine: mosDART 8GB USB 2.0 Flash Drive, $15.55 for 5 x 8GB drives
          • My computer has 3 USB 2.0 ports, and no 3.0 ports.
            • When plugged into the far left port during boot, these drives didn't work as live USB boot drives at all. I could see the Kubuntu logo loading, but then it would back out after a minute and just give an error. I never got into the live Kubuntu operating system.
            • In the back left and back right ports, it would load into Kubuntu, but then it would lock up and be completely unusable. I could move the mouse cursor around, but I couldn't ever click on anything.
        • These USB thumb drives worked great for me, however, as Live USBs! I recommend them: Kingston Digital DataTraveler, $4.99 each for a 16GB drive.
  • Live USB creator programs I tested were Startup Disk Creator (usb-creator-gtk) in Linux, and UNetbootin in both Linux and Windows. Of those three, they all worked to one degree or another, but UNetbootin in Linux worked the best. Problems I had included:
    • Linux Startup Disk Creator problem: “not a COM32R image” error while booting from the live USB (see http://askubuntu.com/questions/486602/ubuntu-14-04-lts-live-usb-boot-error-gfxboot-c32not-a-valid-com32r-image)
      • Solution: when you see this error while booting, press the Tab key, then type “live” and hit enter; it will now boot into the operating system loaded on the Live USB
    • UNetbootin problem, whether done on Linux or Windows: could not run the Memtest86+ program from the UNetbootin live USB, to check the RAM for errors.
      • Solution: on the boot screen, arrow down to the test memory option, then hit Tab to change the load parameter string, and remove the “initrd=/ubninit” part of the command. Now hit enter and Memtest86+ will run as expected. This is not a permanent fix, however, and if you have this problem, you will need to do this solution each time you boot and want to run Memtest86+ from the Live USB created with UNetbootin. See here for where I got this fix: http://www.openmutual.org/2014/09/memtest86-cannot-load-a-ramdisk-with-an-old-kernel-image/.
    • UNetbootin problem on Windows: since Windows can only see the first Windows-compatible partition on a USB thumb drive, even if there are multiple Windows-compatible partitions on the drive, you are limited to ONLY installing your live USB iso file onto the first partition. What if you want the 1st partition to be a “storage” partition, however, and the 2nd one to be the operating system for the live USB? Can you still use UNetbootin from Windows instead of Linux? YES, but it requires a work-around:
      • Solution: use gparted in Linux to make only ONE FAT32 partition, ~4GB in size, at the far right side (end) of the disk. Leave the front (left side) of the USB thumb drive unpartitioned. Now, since you only have a single partition, Windows can see it. Use UNetbootin in Linux to install the Live USB iso file to this single partition. Then, go back into gparted in Linux to add the 1st (left-most) FAT32 storage partition. Now you *must* set the “boot” flag on the 2nd (Live USB), or right-most, partition, since UNetbootin in Windows does NOT automatically do this, though UNetbootin if used in Linux does automatically set the “boot” flag. Done.
        • In short: after making a Live USB with UNetbootin in Windows, it will NOT work to boot until you:
          • A) enable the boot flag of the Live USB (right-most) partition, via gparted.
          • B) format the first (left-most, or “storage”) partition.
          • Otherwise, until you do the above two things, if you try to boot from this Live USB, you will get the following error: “Missing operating system” ... “operating system not found.”
  • Note that persistence does work for me when I use UNetbootin in either Linux or Windows. This is great! I've had problems with persistence before, so I'm glad to see it working.

Misc. References & Links:
  1. *****http://www.howtogeek.com/97177/how-to-put-ubuntu-linux-on-a-usb-thumb-drive-without-the-mess/ - explains using gparted for partitioning – shows making 2 partitions on bootable USB drive, with the shareable partition for storage being first; has lots of screenshots
  2. GPT or MBR partition table?
    1. Short answer:
      1. For best compatibility, choose MBR ("msdos" in gparted). Limitation: it only goes up to 2TB max partition sizes, and can only have up to 4 logical partitions max.
      2. For newer systems, and for partition sizes >2TB, choose GPT, which is a newer standard, and is slowly replacing MBR. Downside: it's not compatible with older systems.

END

Keywords: Linux, Ubuntu, Kubuntu, Linux Live USB, Linux Bootable Thumb Drive, Live Disk, Boot Disk, Bootable USB, Dual partition bootable USB, Windows-readable storage partition on bootable USB

***Subscribe by Email!***

1 comment:

Thanks for your comment or question! If it is a question, I will try to get back to you quickly. Notice to spammers: I personally remove all spam promptly and report spammers to Google, so please don't do it.

Note: some HTML tags are allowed in your comments. To learn how to add bold (<b>...</b>), italics (<i>...</i>), or hyperlinks (<a href="URL">NAME</a>) to your comments, read here.

~Sincerely, Gabriel Staples.

P.S. Yo hablo español también. Je parle français aussi. (I speak Spanish & French too).