My Patriot Xporter XT 32GB Flash Drive came with a single 32GB FAT32 partition.
For this project, I wanted to change the way the Flash Drive was carved out to the following:
- - One small active partition where the boot loader files are kept. This is formatted with ext3
- - Another patition where I would keep all my linux OS's that I wanted to boot up. This is formatted with ext3
- - A third partition that I can use to put files that I can access from Linux and Windows based computers. This has to be a FAT32 partition since it's the only file system type supported by both operating systems.
A visual representation of this setup looks something like this
--------------------------------------------------
| 5MB | 16GB | 15GB |
| ext3 | ext3 | FAT32 |
--------------------------------------------------
After I created and formatted the partitions the way they are shown above, I couldn't get Windows XP to recognize, assign a letter, or access the FAT32 partition. This is an issue I'm currently working on resolving. I'll post more details on this as soon as I figure out the solution.
It's up to you how you want your flash drive partitioned. The partition where I planned on saving the boot loader
files to didn't have to be on its own. The whole drive could be one big partition. I wanted the boot loader files to be on its own partition because I thought that was a much cleaner setup.
Besides, depending on the distro used, the boot loader's directory and files names may conflict with the distro's directory names and files. Therefore it's better to have them in differnet partitions
So, on with carving out the USB flash drive.
- Plug in your USB flash drive to your computer running linux and note the device that the operating system assigns to the drive.
- You may want check your systems log files to figure out what the OS assigned drive is. On my system, this was /dev/sdc . Since the drive already had one big FAT32 partition, /dev/sdc1 was also created by the OS when the flash drive was plugged in. This of course may be different on your system, so check the system log files.
I'll be using /dev/sdc or /dev/sdcx to refer to my usb flash drive throughout this document. Make sure you use the correct device name that refers to yours
- Use fdisk to setup the paritions on the USB flash drive
- The commands I ran are in bold and my comments are in bold and italics below:
# fdisk /dev/sdc
The number of cylinders for this disk is set to 391577.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)
Command (m for help): m
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition
l list known partition types
m print this menu
n add a new partition
o create a new empty DOS partition table
p print the partition table
q quit without saving changes
s create a new empty Sun disklabel
t change a partition's system id
u change display/entry units
v verify the partition table
w write table to disk and exit
x extra functionality (experts only)
Command (m for help): p
Disk /dev/sdc: 32.0 GB, 32078036992 bytes
5 heads, 32 sectors/track, 391577 cylinders
Units = cylinders of 160 * 512 = 81920 bytes
Disk identifier: 0xc0620719
Device Boot Start End Blocks Id System
/dev/sdc1 51 391578 31322176 c W95 FAT32 (LBA)
---Begin: Deleted the existing partition ------
Command (m for help): d
Selected partition 1
---End: Deleted the existing partition ------
---Begin: Creating the first primary partition of 5MB ------
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-391577, default 1): # hit [Enter] here
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-391577, default 391577): +5M
---End: Creating the first primary partition of 5MB ------
Command (m for help): p
Disk /dev/sdc: 32.0 GB, 32078036992 bytes
5 heads, 32 sectors/track, 391577 cylinders
Units = cylinders of 160 * 512 = 81920 bytes
Disk identifier: 0xc0620719
Device Boot Start End Blocks Id System
/dev/sdc1 1 62 4944 83 Linux
---Begin: Making the first partition bootable ------
Command (m for help): a
Partition number (1-4): 1
---End: Making the first partition bootable ------
Command (m for help): p
Disk /dev/sdc: 32.0 GB, 32078036992 bytes
5 heads, 32 sectors/track, 391577 cylinders
Units = cylinders of 160 * 512 = 81920 bytes
Disk identifier: 0xc0620719
Device Boot Start End Blocks Id System
/dev/sdc1 * 1 62 4944 83 Linux
---Begin: Creating the second partition ------
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 2
First cylinder (63-391577, default 63): # Hit [Enter] here
Using default value 63
Last cylinder or +size or +sizeM or +sizeK (63-391577, default 391577): +16384M
---End: Creating the second partition ------
Command (m for help): p
Disk /dev/sdc: 32.0 GB, 32078036992 bytes
5 heads, 32 sectors/track, 391577 cylinders
Units = cylinders of 160 * 512 = 81920 bytes
Disk identifier: 0xc0620719
Device Boot Start End Blocks Id System
/dev/sdc1 * 1 62 4944 83 Linux
/dev/sdc2 63 200063 16000080 83 Linux
---Begin: Creating the third partition ------
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 3
First cylinder (200064-391577, default 200064): # Hit [Enter] here
Using default value 200064
Last cylinder or +size or +sizeM or +sizeK (200064-391577, default 391577): # Hit [Enter] here
Using default value 391577
---End: Creating the third partition ------
Command (m for help): p
Disk /dev/sdc: 32.0 GB, 32078036992 bytes
5 heads, 32 sectors/track, 391577 cylinders
Units = cylinders of 160 * 512 = 81920 bytes
Disk identifier: 0xc0620719
Device Boot Start End Blocks Id System
/dev/sdc1 * 1 62 4944 83 Linux
/dev/sdc2 63 200063 16000080 83 Linux
/dev/sdc3 200064 391577 15321120 83 Linux
---Begin: Changing the 3rd partition's type to FAT32 ------
Command (m for help): t
Partition number (1-4): 3
Hex code (type L to list codes): c
Changed system type of partition 3 to c (W95 FAT32 (LBA))
---End: Changing the 3rd partition's type to FAT32 ------
Command (m for help): p
Disk /dev/sdc: 32.0 GB, 32078036992 bytes
5 heads, 32 sectors/track, 391577 cylinders
Units = cylinders of 160 * 512 = 81920 bytes
Disk identifier: 0xc0620719
Device Boot Start End Blocks Id System
/dev/sdc1 * 1 62 4944 83 Linux
/dev/sdc2 63 200063 16000080 83 Linux
/dev/sdc3 200064 391577 15321120 c W95 FAT32 (LBA)
---Begin: Saving the new partition information ------
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table.
The new table will be used at the next reboot.
WARNING: If you have created or modified any DOS 6.x
partitions, please see the fdisk manual page for additional
information.
Syncing disks.
---End: Saving the new partition information ------
#
Next, the file systems were created.
---Begin: Creating ext3 file systems on the first and 2nd partitions ------
# mkfs -t ext3 /dev/sdc1
mke2fs 1.40.8 (13-Mar-2008)
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
1240 inodes, 4944 blocks
247 blocks (5.00%) reserved for the super user
First data block=1
Maximum filesystem blocks=5242880
1 block group
8192 blocks per group, 8192 fragments per group
1240 inodes per group
Writing inode tables: done
Creating journal (1024 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 39 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
# mkfs -t ext3 /dev/sdc2
mke2fs 1.40.8 (13-Mar-2008)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
1001712 inodes, 4000020 blocks
200001 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4097835008
123 block groups
32768 blocks per group, 32768 fragments per group
8144 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 30 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
---End: Creating ext3 file systems on the first and 2nd partitions ------
---Begin: Creating FAT32 file system on the 3rd partitions ------
# mkfs.msdos -v -F 32 /dev/sdc3
mkfs.msdos 2.11 (12 Mar 2005)
/dev/sdc3 has 5 heads and 32 sectors per track,
logical sector size is 512,
using 0xf8 media descriptor, with 30642240 sectors;
file system has 2 32-bit FATs and 16 sectors per cluster.
FAT size is 14948 sectors, and provides 1913269 clusters.
Volume ID is 498de6ce, no volume label.
---End: Creating FAT32 file system on the 3rd partitions ------
Creating mount points
With partitioning and file systems creation done, I ended up with /dev/sdc , /dev/sdc1, /dev/sdc2, and /dev/sdc3.
I created two directories that will be used as mount points for the first and second partitions of the USB flash drive.
# mkdir -p /mnt/usb1 --- This will be the mount point for the first partition
# mkdir -p /mnt/usb2 --- This will be the mount point for the second partition