0
0
Linux CLIscripting~15 mins

File system types (ext4, xfs) in Linux CLI - Mini Project: Build & Apply

Choose your learning style9 modes available
Check and Compare File System Types
📖 Scenario: You are managing a Linux server and want to check the file system types of different mounted drives. Knowing the file system type helps you understand how data is stored and managed on each drive.
🎯 Goal: Build a simple script that lists mounted drives and shows their file system types, then filters to show only drives with ext4 or xfs file systems.
📋 What You'll Learn
Create a variable with a sample list of mounted drives and their file system types.
Add a variable to specify which file system types to filter (ext4 and xfs).
Use a loop or comprehension to select only drives with the specified file system types.
Print the filtered list showing drive names and their file system types.
💡 Why This Matters
🌍 Real World
System administrators often need to check and manage file system types on servers to ensure compatibility and performance.
💼 Career
Knowing how to script file system checks helps in automating server maintenance and troubleshooting tasks.
Progress0 / 4 steps
1
Create a list of mounted drives with file system types
Create a variable called mounted_drives that is a list of dictionaries. Each dictionary should have keys drive and fs_type. Use these exact entries: {'drive': '/dev/sda1', 'fs_type': 'ext4'}, {'drive': '/dev/sdb1', 'fs_type': 'xfs'}, {'drive': '/dev/sdc1', 'fs_type': 'ntfs'}, {'drive': '/dev/sdd1', 'fs_type': 'ext4'}.
Linux CLI
Need a hint?

Use a list with dictionaries. Each dictionary has keys 'drive' and 'fs_type' with the exact values given.

2
Add a variable for file system types to filter
Create a variable called filter_fs_types that is a list containing the strings 'ext4' and 'xfs'.
Linux CLI
Need a hint?

Make a list with the two file system types as strings.

3
Filter drives by file system types
Create a variable called filtered_drives that uses a list comprehension to select only dictionaries from mounted_drives where the fs_type is in filter_fs_types.
Linux CLI
Need a hint?

Use a list comprehension with d for d in mounted_drives if d['fs_type'] in filter_fs_types.

4
Print the filtered drives
Use a for loop to print each drive and its file system type from filtered_drives in the format: Drive: [drive], File System: [fs_type].
Linux CLI
Need a hint?

Use a for loop and an f-string to print each drive and its file system type exactly as shown.