Home | Hire | Products | News | Support | Training | Contact | Calendar | Events Space | Faq | Freelance | Links

How to partition & format a USB drive for the Linux OS

How to partition and format a USB drive for the Linux OS

Assuming you haven't already connected the drive, do so now.

Open a shell and become root (type 'su -' and then the root password).

Type 'dmesg'

At the bottom of the text look for the SCSI device name which has been assigned to the device (it should look something along the lines of 'sde' or 'sdf' etc).
It should also have some text about being a USB device and have a KiloByte value roughly corresponding to the size of the USB drive.
Once you are sure you have identified the correct device you can then open the partition tool.

Type 'parted'

This opens a linux disk partitioning tool called 'parted'.
It should say 'using /dev/sda'
This means it is working with SCSI device 'sda' which will be your main linux system drive.
Since we don't want to repartition this and lose all our data we need to switch to the USB drive.

If you type 'h' it will give you a list of commands.
The one we want is 'select DEVICE'

Type 'select *' Where * is the name of the USB device you found using dmesg. For example 'select /dev/sde'

You should now be working on the USB drive.
You can view the current partition table by typing 'print'

You will see some information. The important bits are 'Disk' which should show the correct device and also the correct size.
It will also list any current partitions (eg NTFS, FAT, EXT, HFS etc)

The quickest way to partition is to create a new partition table and then add a new partition.

Type 'mklabel bsd'

Type 'print' to verify

Type 'mkpart primary 0 *' Where * is the value given in the previous 'print' command. It is the upper size of the drive.
eg 'mkpart parimary 0 1015' for a 1GB USB key

Type 'print' to verify

If everything is ok type 'q' to exit parted.

Now we need to format the drive partition we have just made.

Type 'mkfs -t ext3 /dev/*1' where *1 is the USB device name eg /dev/sde1. The number 1 represents the partition number you have just created using parted.

It will format the disk, which may take a while.

You can then mount the disk using the GUI.

Click the Home icon and on the top left you will see '+dev'

Click on this and right click 'mount' on the freshly formatted USB disk.

When you have fininshed using the USB disk, close any open windows and or applications associated with the disk and right click 'unmount'

You can then disconnect the drive or leave it connected ready for mounting again.

Partners
XTFX Partners

XTFX
About Us | Site Map | Privacy Policy | Contact Us | ©2010 XTFX Ltd
Flame Rental UK