Goals:
Partitioning a USB flash drive into 2 partitions. One used to general storage task and it will be supported on both the Windows and Linux; And another partition will be only supported on Linux, then you can use this partition to install a USB-bootable Linux.
Requirements:
1. A runnable Linux operating system. At here, I used Ubuntu 8.04.
2. fdisk: a partition table manipulator for Linux that existing on general Linux system.
2. A USB flash drive.
Step1. Find the USB flash drive device.
sudo fdisk -l
On my machine, I had the following output like this:
Disk /dev/sdb: 523 MB, 523091968 bytes
17 heads, 59 sectors/track, 1018 cylinders
Units = cylinders of 1003 * 512 = 513536 bytes
Disk identifier: 0x6f20736b
So, I assume you had same the device with my which is the /dev/sdb.
Step2. Create the one partition for general storage.
sudo fdisk /dev/sdb
2.1 Use "d" command to delete all existing paritions. First, use "p" command to print the partition table, get the partition number, then repeatedly use "d" command to delete if you have more than one existing partitions. My partition table look like the following output from "p" command:
Device Boot Start End Blocks Id System
/dev/sdb1 1 718 360047+ 6 FAT16
/dev/sdb2 * 719 1018 150450 83 Linux
Then use "d" command to delete:
Command (m for help): d
Partition number (1-4): 2
Command (m for help): d
2.2 Use "n" command to create the partition.
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-1018, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-1018, default 1018): 509
After above commands had been done, I got a new partition:
Device Boot Start End Blocks Id System
/dev/sdb1 1 509 255234 83 Linux
2.3 Use "t" command to change the partition's system id.
Command (m for help): t
Partition number (1-4): 1
Hex code (type L to list codes): b
Finally, the partition has been done, but at here this partition is not compatible with Windows yet.
Device Boot Start End Blocks Id System
/dev/sdb1 1 509 255234 b W95 FAT32
Step3. Create a bootable Linux partition.
Reference Step-2 to create a Linux partition, but use "a" command instead of "t" command that introduced in Step2-3. The "a" command used to toggle partition is bootable.
Command (m for help): a
Partition number (1-4): 2
The final output like this:
Device Boot Start End Blocks Id System
/dev/sdb1 1 509 255234 b W95 FAT32
/dev/sdb2 * 510 1018 255263+ 83 Linux
Step4. Make the general storage partition is compatible with the Windows.
Command (m for help): c
DOS Compatibility flag is not set
Command (m for help): c
DOS Compatibility flag is set
Step5. Commit all work that you had done.
Command (m for help): w
If you do something wrong, you can rollback all your work via "q" command.
Step6. Format the Linux partition to ext3.
This step is optional if you like ext3 file system.
sudo mke2fs -j /dev/sdb2
5/03/2008
How to partition a USB Flash Drive
Labels:
Tao of Programming
Subscribe to:
Post Comments (Atom)
1 comment:
Post a Comment