Exercise: Formatting and Mounting Filesystems
Bringing a Partition to Life
1 Purpose
An empty partition is still unusable. This exercise covers the final step in preparing a drive: formatting. You will learn how to create a filesystem on the partition you created in the previous exercise. You will then learn how to mount that filesystem to make it accessible to the operating system, and how to work with different filesystem types like ext4 and exFAT.
2 What You’ll Accomplish
By the end of this exercise, you will be able to:
- Format a partition with the
ext4andexFATfilesystems usingmkfs. - Create a directory to serve as a mount point.
- Mount and unmount a filesystem using the
mountandumountcommands. - Verify that a filesystem is mounted using
lsblkanddf.
This exercise maps to the following program and course learning outcomes:
- Program Learning Outcomes (PLOs):
- 3. Apply terminology and numeric or system concepts: You will apply the concepts of filesystems and mount points by creating and managing them directly.
- Course Learning Outcomes (CLOs):
- 4. Configure hardware and basic network components: Formatting and mounting are essential, everyday tasks for a Linux system administrator.
This exercise develops the following skills, which align with the O*NET SOC Code 15-1232.00 for Computer User Support Specialists.
| Learning Objective | O*NET KSAs | Technologies Used |
|---|---|---|
| Format a partition with a specific filesystem. | Knowledge: Computers & Electronics Skills: Installation |
mkfs, ext4, exFAT |
| Mount and unmount a filesystem in Linux. | Knowledge: Computers & Electronics Abilities: Information Ordering |
mount, umount |
3 Prerequisites
This exercise requires a running Fedora 42 virtual machine and assumes you have completed Exercise 6.1. You must have the my_raw_disk.img file from that exercise.
4 Step-by-Step Guide
Open a terminal window in your Fedora VM to begin.
4.1 Step 1: Verify Your Block Device
First, ensure the virtual disk from the last exercise is still attached as a block device. If you have rebooted your VM, you will need to re-attach it.
Run
lsblkto see if your loop device (e.g.,loop0with partitionloop0p1) is present.If it is not present, re-run the
losetupcommand from the previous exercise with the raw disk image:sudo losetup -fP my_raw_disk.img
4.2 A Note on NBD Devices
Exercise 6.1 also introduced the qemu-nbd method for qcow2 files. If you were using that method, your device would be /dev/nbd0 instead of a loop device. The following commands would need to be adjusted (e.g., sudo mkfs.ext4 /dev/nbd0p1). This exercise will proceed assuming you have followed the primary path using the raw image and losetup.
4.3 Step 2: Install Filesystem Utilities
To create exFAT filesystems, you need an extra utility.
Run the following command to install the
exfatprogspackage:sudo dnf install -y exfatprogs
4.4 Step 3: Format with the ext4 Filesystem
Your first task is to format your new partition with ext4, the standard Linux filesystem.
Use the
mkfs.ext4command. The partition name is the loop device name withp1appended.# Replace /dev/loop0p1 if your device name is different sudo mkfs.ext4 /dev/loop0p1The command will create the filesystem and report that it is done.
4.5 Step 4: Mount the Filesystem
To access the newly formatted volume, you must mount it on a directory.
First, create a directory to serve as the mount point:
sudo mkdir /mnt/my_new_drive sudo mount /dev/loop0p1 /mnt/my_new_driveVerify the mount was successful. Run
lsblkagain. You should now see your mount point (/mnt/my_new_drive) listed next to your partition.lsblk
Take a screenshot of this lsblk output and add it to your notebook.
4.6 Step 5: Unmount and Re-Format with exFAT
Now, you will practice re-formatting with a different filesystem for cross-platform compatibility.
First, unmount the device using the
umountcommand:sudo umount /mnt/my_new_driveNow, format the same partition with the
exFATfilesystem:sudo mkfs.exfat /dev/loop0p1You will be warned that the device contains an existing filesystem. Type
yand press Enter to proceed.Mount the exFAT filesystem to the same mount point:
sudo mount /dev/loop0p1 /mnt/my_new_driveVerify the mount again using the
df -hTcommand, which shows disk free space and filesystem Type.df -hTLook for the line for
/dev/loop0p1and confirm that the “Type” is nowexfat.
Take a screenshot of the df -hT output and add it to your notebook.
5 Reflect and Review
Now that you have completed this exercise, reflect on your experience in your Microsoft Teams Student Notebook:
- 3 filesystems you have learned about.
- 2 commands used to manage mounting.
- 1 question you still have about why different filesystems exist.
Answer these questions in your notebook to solidify your understanding:
- What does the
mkfscommand stand for, and what is its purpose? - Before you can mount a filesystem, what must you first create?
- You want to format a USB drive to share files between Windows, Mac, and Linux computers. The files are very large. Would
ext4orexFATbe a better choice? Why? - What command would you use to see all mounted filesystems and their types?