I am currently available as a freelance Senior Perl Programmer. Download my up-to-date resume (PDF)
John Bokma MexIT
freelance Perl programmer

Formatting a USB flash drive as ext3

Wednesday, February 17, 2010 | 0 comments

In the afternoon I decided that in the evening I was going to install Ubuntu 9.10, also known as Karmic Koala, on my mother-in-law's computer. But I needed something easy to put a backup on of the /home directory, which has two accounts, one for Esme and one for her mother. Since we have an old 256MB USB pen drive we hardly use I decided to reformat it to the ext3 file format so I could copy the files and preserve the file attributes and owners; both Esme and her mother have an account on that computer.

I connected the 256MB USB flash drive to my Dell Vostro 200 ST, which is running Ubuntu 8.10 - I know, I have to update, most likely to Ubuntu 10.04 LTS when it becomes available - and made a back up of the old files on the drive. After I had verified the backup I used the df command in the Gnome terminal emulator to find out the device name of the only partition on the USB drive. It showed up as the last line in the output:

/dev/sdd1               249576     70164    179412  29% /media/ESMERALDA

Next I unmounted the USB thumb drive using:

umount /dev/sdd1

and turned the FAT16 formatted partition into an ext3 one using:

mkfs.ext3 /dev/sdd1

which gave the following output inside the virtual terminal window:

mke2fs 1.41.3 (12-Oct-2008)
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
62496 inodes, 249840 blocks
12492 blocks (5.00%) reserved for the super user
First data block=1
Maximum filesystem blocks=67371008
31 block groups
8192 blocks per group, 8192 fragments per group
2016 inodes per group
Superblock backups stored on blocks: 
	8193, 24577, 40961, 57345, 73729, 204801, 221185

Writing inode tables: done                            
Creating journal (4096 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 36 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.

Next I gave the partition a label - Esmeralda, since it's her USB flash drive - using:

sudo e2label /dev/sdd1 Esmeralda

After I had unplugged the USB drive and plugged it back in it was automatically mounted under /media as Esmeralda. The df -h command showed the USB pen drive as follows:

/dev/sdd1             237M  6.1M  219M   3% /media/Esmeralda

Note how the -h option prints the sizes in human readable format.

Earlier this year I formatted a Western Digital My Passport Elite 320GB portable hard drive to ext3, using the same method as described above, so I can use it to backup my home directory in an easy manner.

Please post a comment | read 0 comments | RSS feed
Snow in Mexico >
< Barcodes with Apache FOP