0
0
Linux CLIscripting~10 mins

File system types (ext4, xfs) in Linux CLI - Step-by-Step Execution

Choose your learning style9 modes available
Concept Flow - File system types (ext4, xfs)
Start
Choose device
Select file system type
Format device with chosen FS
Mount file system
Use storage
End
This flow shows how to format a storage device with a file system type like ext4 or xfs, then mount it for use.
Execution Sample
Linux CLI
sudo mkfs.ext4 /dev/sdb1
sudo mount /dev/sdb1 /mnt
ls /mnt
Formats the device /dev/sdb1 with ext4, mounts it to /mnt, then lists contents of /mnt.
Execution Table
StepCommandActionOutput/Result
1sudo mkfs.ext4 /dev/sdb1Format /dev/sdb1 with ext4 file systemFilesystem created successfully
2sudo mount /dev/sdb1 /mntMount /dev/sdb1 to /mnt directoryNo output (success)
3ls /mntList contents of mounted device(empty or existing files if any)
4exitEnd of processProcess complete
💡 All commands executed successfully; device formatted and mounted.
Variable Tracker
VariableStartAfter Step 1After Step 2After Step 3Final
/dev/sdb1unformattedformatted with ext4mounted at /mntaccessible at /mntready for use
Key Moments - 3 Insights
Why do we need to format the device before mounting?
Formatting creates a file system structure on the device (see Step 1 in execution_table). Without it, the system cannot organize files.
What happens if we try to mount without formatting?
Mounting an unformatted device will fail or show errors because no file system exists (refer to Step 2).
Why does 'ls /mnt' sometimes show empty?
After formatting and mounting a new device, it is usually empty unless files were added (Step 3).
Visual Quiz - 3 Questions
Test your understanding
Look at the execution table, what is the state of /dev/sdb1 after Step 1?
AFormatted with ext4 file system
BMounted at /mnt
CUnformatted
DContains files
💡 Hint
Check the 'Action' and 'Output/Result' columns in Step 1.
At which step is the device mounted to the directory?
AStep 1
BStep 3
CStep 2
DStep 4
💡 Hint
Look for the 'mount' command in the execution_table.
If we skip formatting and run only 'mount /dev/sdb1 /mnt', what likely happens?
AMount succeeds with no issues
BMount fails or shows error
CDevice gets formatted automatically
DFiles appear in /mnt
💡 Hint
Refer to key_moments about mounting without formatting.
Concept Snapshot
File system types like ext4 and xfs organize data on storage devices.
Use 'mkfs.ext4 /dev/device' or 'mkfs.xfs /dev/device' to format.
Mount with 'mount /dev/device /mountpoint' to access files.
Formatting is required before mounting.
Listing mountpoint shows stored files or empty if new.
Full Transcript
This lesson shows how to prepare a storage device by formatting it with a file system type such as ext4 or xfs. First, you choose the device to format. Then you run a command like 'mkfs.ext4' to create the file system structure. After formatting, you mount the device to a directory so the system can access it. Finally, you can list the contents of the mounted directory to see files or confirm it is empty. Formatting is necessary before mounting; otherwise, mounting will fail. This process helps organize data on disks for Linux systems.