< Previous | Contents | Next >
Creating A New File System With mkfs
With our partition editing done (lightweight though it might have been) it’s time to create a new file system on our flash drive. To do this, we will use mkfs (short for “make file system”), which can create file systems in a variety of formats. To create an ext4 file sys - tem on the device, we use the “-t” option to specify the “ext4” system type, followed by the name of the device containing the partition we wish to format:
[me@linuxbox ~]$ sudo mkfs -t ext4 /dev/sdb1
mke2fs 1.40.2 (12-Jul-2007)
Filesystem label= OS type: Linux
Block size=1024 (log=0) Fragment size=1024 (log=0) 3904 inodes, 15608 blocks
780 blocks (5.00%) reserved for the super user First data block=1
Maximum filesystem blocks=15990784
2 block groups
8192 blocks per group, 8192 fragments per group 1952 inodes per group
Superblock backups stored on blocks: 8193
Writing inode tables: done
Creating journal (1024 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 34 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override. [me@linuxbox ~]$
[me@linuxbox ~]$ sudo mkfs -t ext4 /dev/sdb1
mke2fs 1.40.2 (12-Jul-2007)
Filesystem label= OS type: Linux
Block size=1024 (log=0) Fragment size=1024 (log=0) 3904 inodes, 15608 blocks
780 blocks (5.00%) reserved for the super user First data block=1
Maximum filesystem blocks=15990784
2 block groups
8192 blocks per group, 8192 fragments per group 1952 inodes per group
Superblock backups stored on blocks: 8193
Writing inode tables: done
Creating journal (1024 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 34 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override. [me@linuxbox ~]$
The program will display a lot of information when ext4 is the chosen file system type. To re-format the device to its original FAT32 file system, specify “vfat” as the file system
type:
[me@linuxbox ~]$ sudo mkfs -t vfat /dev/sdb1
[me@linuxbox ~]$ sudo mkfs -t vfat /dev/sdb1
This process of partitioning and formatting can be used anytime additional storage de- vices are added to the system. While we worked with a tiny flash drive, the same process can be applied to internal hard disks and other removable storage devices like USB hard drives.