Format a device
This is an HOWTO about device formatting. It came from the ArchWiki.
Before starting you need to know which name Linux gave to your device. All device nodes are placed in /dev by udev, hard drives and USB keys should be either /dev/sdX or /dev/hdX where "X" is a lowercase letter and the nodes for the partitions of these devices are /dev/sdXY or /dev/hdXY where "Y" is a number.
If the device you want to format is mounted then the mtab (mounted file systems table) file may help you:
and you will need to unmount it:
If your device is not mounted:
ls -l /dev/disk/by-id
will give you something like this:
lrwxrwxrwx 1 root root 9 oct. 30 22:54 scsi-SATA_ST980811AS_5RL094R5 -> ../../sda lrwxrwxrwx 1 root root 10 oct. 30 22:54 scsi-SATA_ST980811AS_5RL094R5-part1 -> ../../sda1 lrwxrwxrwx 1 root root 10 oct. 30 22:54 scsi-SATA_ST980811AS_5RL094R5-part2 -> ../../sda2 lrwxrwxrwx 1 root root 10 oct. 30 22:54 scsi-SATA_ST980811AS_5RL094R5-part5 -> ../../sda5 lrwxrwxrwx 1 root root 10 oct. 30 22:54 scsi-SATA_ST980811AS_5RL094R5-part6 -> ../../sda6 lrwxrwxrwx 1 root root 10 oct. 30 22:54 scsi-SATA_ST980811AS_5RL094R5-part7 -> ../../sda7 lrwxrwxrwx 1 root root 9 oct. 31 18:29 usb-_USB_DISK_25X_0758081701F8-0:0 -> ../../sdb lrwxrwxrwx 1 root root 10 oct. 31 18:29 usb-_USB_DISK_25X_0758081701F8-0:0-part1 -> ../../sdb1
where you can see that the kernel name of my USB stick is sdb because sda is already used by my hard drive. If I plugged in an other USB stick the kernel would name it sdc and udev would create the device node /dev/sdc, etc.
2 Step 1: delete the previous partitions
For that you can use fdisk:
# fdisk /dev/<your_device>
3 Step 2: create the new file system
3.1 In console
To create a file system you just have to use mkfs:
# mkfs -t vfat /dev/<your_device>
As mkfs is just a unified front-end for the different mkfs scripts you need to install the packages providing these scripts.
dosfstools provides FAT16 and FAT32 support:
4 Step 3: check
Now you can check the new file system with fsck:
# fsck /dev/<your_device>
5 GUI tools
There are several GUI tools for partition management:
- GParted (GTK) is available in extra