Linux, USB pen drive + persistent storage available to Windows and Linux

Introduction
Just a short set of notes to get a bootable Linux pen drive and have it available for read and write persistent storage under Linux and Windows.
Normally, Linux Live ISOs can easily be written to a FAT32 formatted USB pen drives these days allowing you to use the drive as a Linux boot device as well as storing files from within Windows. But what happens when you want to boot your USB Linux and edit that file, or from within your USB booted Linux write to an area of your USB stick that can be read from Windows?

Solution

To achieve this in an elegant way – hiding your bootable Linux partition from Windows, but still having your USB stick work as a data device too follow these instructions ubder Linux. I am using a Freecom 8Gb USB Pen Drive split up as follows

/dev/sdb1 (Removable Drive Under Windows) 5.3Gb Data
/dev/sdb2 (Not visible under Windows) 2.6Gb Bootable Linux

1. Re-partition your USB Stick. Under Windows this can’t be done natively. There are hacks to replace the USB sticks driver in your Windows reg to be that of a removable hard drive but I stayed away from them, instead opting to boot into Linux and using Fdisk:

fdisk /dev/sdb
Delete all partitions (d)
Create a new partition (n)
Partition (1)
Make it as big as you can spare after taking just over 2Gb from it
Change the type (l) to Win95/FAT32 (LBA) (c)
Create a new partition (n)
Partition (2)
Make this just over 2Gb in size
Change the type (l) to Win95/FAT32 (LBA) (c)
Write your changes and exit (w)

2. Format the partitions using mkfs.vfat

mkfs.vfat /dev/sdb1
mkfs.vfat /dev/sdb2

3. Download and run unetbootin, selecting your Linux of choice – selecting the second partition (/dev/sdb2). This is because Windows will only read the first partition (/dev/sdb1) so that will be the place you’ll be storing your data.

4. The end result is a bootable pen drive running Linux, which has access to /dev/sdb1 and if you plug the drive into a Windows PC you’ll just see your data.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s