Format a device - ParabolaWiki

# Format a device

This is an HOWTO about device formatting. It came from the ArchWiki.

Warning: formatting a device removes everything on it, make sure to backup everything you want to keep.
Note: the authors of this article cannot be considered responsible of any data loss, hardware deterioration or any other problem related to this article.

## Pre-requirements

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:

    cat /etc/mtab

and you will need to unmount it:

    umount /dev/sdXY

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.

## Step 1: delete the previous partitions

For that you can use fdisk:

    # fdisk /dev/<your_device>

Note: enter m for the help

## Step 2: create the new file system

### 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.

e2fsprogs contains:

- mkfs.ext2
- mkfs.ext3
- mkfs.ext4
- mkfs.ext4dev

dosfstools provides FAT16 and FAT32 support:

- mkfs.vfat
- mkfs.msdos

ntfsprogs provides:

- mkfs.ntfs

jfsutils contains:

- mkfs.jfs

xfsprogs provides:

- mkfs.xfs

reiserfsprogs contains:

- mkfs.reiserfs

## Step 3: check

Now you can check the new file system with fsck:

    # fsck /dev/<your_device>

## GUI tools

There are several GUI tools for partition management:

- GParted (GTK) is available in extra

## Acknowledgement

This wiki article is based on ArchWiki. We may have removed non-FSDG bits from it.
Categories:

- File systems
- Stub