Tuesday, August 19, 2008

Formatting a USB disk on the eee

Having managed to get some of the 50% from the so-called "overhead" on my salary back in the form of a 8 GB USB disk, I decided to partition it into linux and windows partition.

This turned out to be a bit impractical, as you need to be root everytime you want to mount the linux partition. The eee was nice enough to manage to do the repartitioning well (thumbs down for opensuse on this part), but I forgot how I did it, so here I do it the other way around:

Step 1: plug the usb disk in.

If you have a "Kingston DataTraveler 8GB, this might end up to be more difficult than it sounds. More about that in another post.

Step 2: Check /etc/mtab
...
/dev/sdc1 /media/DataTraveler\0402.0/partition1 vfat rw,nosuid,nodev,noexec,fmask=0111,dmask=0000,codepage=cp850,iocharset=utf8,shor
tname=mixed 0 0
...

Obviously, the disk is mounted at /dev/sdc. /dev/sda is the main disk, you don't want to fdisk that, /dev/sdb is a SD card in my case.
-
Step 3: make sure that you are root

I usually do "sudo su", but I guess that is cheating

Step 4: fdisk to delete partitions

fdisk /dev/sdc


it says: press "m" for help. Do that. For example p to print the partition table:

Disk /dev/sdc: 8006 MB, 8006926336 bytes
247 heads, 62 sectors/track, 1021 cylinders
Units = cylinders of 15314 * 512 = 7840768 bytes

Device Boot Start End Blocks Id System
/dev/sdc1 * 1 400 3062769 c W95 FAT32 (LBA)
/dev/sdc2 * 401 1021 4754997 83 Linux


I want to get rid of them both, and make one W95 FAT32 (LBA) partition.
So "d 1", "d" (it sees only one partition and selects it). "w" to write, you WILL SEE warning messages :p

Step 5: fdisk to add partitions

Again:

fdisk /dev/sdc


and p. If all went well, an empty list is shown. If you press "l" you'll see that the partition we had and want again is:

c W95 FAT32 (LBA)


then: "n" for a new partition, "p" for a primary partition, "1" for partition 1, then twice "enter" for the default values. This created a linux partition the size of the disk, so use "t" to change it to disk type "c". Again, write with "w".

Step 6: unmount the disk using umount

DO NOT unmount via the USB icon on the menu bar, that will remove /dev/sdc from your system, and to edit the partitions, you will have to replug your usb disk and umount again anyway. This step could probably better be done earlier on in the process.

Step 7: Make a filesystem with mkfs.

To be able to write stuff to the partition, a filesystem should be installed on the disk. That is done with mkfs, mkfs.vfat for windows disks.

mkfs.vfat /dev/sdc1


Step 8: unmount via task bar, replug

It should mount as usual, check "/etc/mtab" again and "df -h" to see the partition size. Nice.

0 comments: