Creating Linux FileSystems

Creating Linux FileSystems

Try creating some filesystems on a spare partition or a removable disk. Even a floppy disk will do, although you won't be able to create journaling filesystems on a floppy disk. The following steps assume that you're using a USB flash drive, /dev/sdc1; change the device specification as necessary.

WARNING: Be sure to use an empty partition! Accidentally entering the wrong device filename could wipe out your entire system!

This exercise uses a few commands that are described in more detail later in this Lesson. To create some filesystems, follow these steps:
  1. Log in as root.
  2. Use fdisk to verify the partitions on your target disk by typing fdisk -l /dev/sdc. You should see a list of partitions, including the one you'll use for your tests. (If fdisk reports a single partition with ee under the Id column, the disk is a GPT disk, and you should verify the disk's partitions with gdisk rather than fdisk.)
  3. Verify that your test partition is not currently mounted. Type df to see the currently mounted partitions and verify that /dev/sdc1 is not among them.
  4. Type mkfs -t ext2 /dev/sdc1. You should see several lines of status information appear.
  5. Type mount /dev/sdc1 /mnt to mount the new filesystem to /mnt. (You may use another mount point if you like.)
  6. Type df /mnt to see basic accounting information for the filesystem. On our test system with a /dev/sdc1 that's precisely 1000MiB in size, 1,007,896 blocks are present; 1,264 are used, and 955,432 blocks are available. Most of the difference between the present and available blocks is caused by the 5 percent reserved space.
  7. Type umount /mnt to unmount the filesystem.
  8. Type mkfs -t ext2 -m 0 /dev/sdc1 to create a new ext2 filesystem on the device, but without any reserved space.
  9. Repeat steps 5–7. Note that the available space has increased (to 1,006,632 blocks on our test disk). The available space plus the used space should now equal the total blocks.
  10. Repeat steps 4–7, but use a filesystem type code of ext3 to create a journaling filesystem. (This won't be possible if you use a floppy disk.) Note how much space is consumed by the journal.
  11. Repeat steps 4–7, but use another filesystem, such as JFS or ReiserFS. Note how the filesystem creation tools differ in the information that they present and in their stated amounts of available space.
Be aware that, because of differences in how filesystems store files and allocate space, a greater amount of available space when a filesystem is created may not translate into a greater capacity to store files.