Based on the Linux Master 2 exam syllabusReport an error
mkfs./etc/fstab. Disk → Partition → File system → Mount → Use
(dividing) (mkfs) (mount)| Name | Journaling | Feature |
|---|---|---|
| ext2 | ✗ | The early file system that was the Linux standard |
| ext3 | ✓ | Adds journaling to ext2. Good compatibility |
| ext4 | ✓ | Improved for large capacity and performance. The most widely used today |
| XFS | ✓ | Strong with large files. The default from RHEL 7 |
| Btrfs | ✓ | Rich in features such as snapshots and compression. Adopted as the default by SUSE |
The exam point is "since when is there journaling." The answer is ext3. ext2 doesn't have it.
Lining up the three ext generations by numbers makes the differences clear (capacities assume a 4KB block size).
| Category | ext2 | ext3 | ext4 |
|---|---|---|---|
| Appeared | 1993 | 2001 | 2008 |
| Journaling | ✗ | ✓ | ✓ |
| Maximum file size | 2TB | 2TB | 16TB |
| Maximum file system size | 16TB | 16TB | 1EB |
| One-line summary | The early Linux standard | ext2 + journaling | Improved for large capacity and performance |
tune2fs -j /dev/sdb1).| Group | File systems | Feature |
|---|---|---|
| For Linux disks | ext2, ext3, ext4, XFS, Btrfs, JFS, ReiserFS | Created on a partition |
| Other OSes and removable media | FAT32 (vfat), exFAT, NTFS, ISO 9660 | Can be mounted and read on Linux too |
| Network | NFS, SMB/CIFS | Attach another computer's directory as if it were your own |
| Virtual (memory) | proc, sysfs, tmpfs | Not on disk. The kernel creates and shows them from memory |
/proc is the classic virtual file system. The /proc/version we saw last week is not a file stored on disk but content the kernel generates the moment you read it.cat /proc/filesystems. A line prefixed with nodev is a virtual file system that doesn't need a disk device.| Name | Where it's used |
|---|---|
| FAT32 | General-purpose such as USB. Best compatibility, 4GB limit per file |
| exFAT | FAT32 without the 4GB limit. Large-capacity USB |
| NTFS | The Windows standard |
| ISO 9660 | CD/DVD optical media |
| swap | Dedicated to swap areas |
| HFS+ / APFS | macOS |
The cause of the common symptom "a file over 4GB won't fit on the USB drive" is FAT32.
| What's in the inode | What's NOT in the inode |
|---|---|
| File type, permissions | The file name |
| Owner and group | |
| Size | |
| Time information (modified, accessed) | |
| Location of the blocks holding the data |
ls -i file # Show the inode number
df -i # Check inode usageAn ext-family file system uses a partition roughly as four regions.
| Region | What it holds |
|---|---|
| Boot block | The very first area that may be used for booting |
| Superblock | Information about the entire file system — total size, block size, total and remaining inode counts, mount count |
| inode table | Information about each individual file |
| Data blocks | The actual contents of files |
Superblock backups in the mkfs output below is that.tune2fs -l /dev/sdb1.Once you know the structure "the name is in the directory, everything else in the inode," you don't need to memorize the difference between the two links.
$ echo hello > a.txt
$ ln a.txt hard.txt # Hard link
$ ln -s a.txt soft.txt # Symbolic link (-s)
$ ls -li
total 8
1311 -rw-r--r-- 2 user user 6 Mar 4 10:12 a.txt
1311 -rw-r--r-- 2 user user 6 Mar 4 10:12 hard.txt
1312 lrwxrwxrwx 1 user user 5 Mar 4 10:12 soft.txt -> a.txta.txt and hard.txt have the same inode number (1311). Two names are attached to the same file. The number 2 after the permissions is the count of those names (the link count).soft.txt has its own separate inode (1312), and its first character is l. Its content is only the path string a.txt, so its size is 5 bytes.| Category | Hard link | Symbolic link |
|---|---|---|
| How to create | ln original link | ln -s original link |
| inode | Same as the original | Has its own |
| If the original is deleted | The data remains (just one fewer name) | Becomes a broken link |
| Across partitions (file systems) | Not possible — inode numbers are valid only inside a file system | Possible |
| Directories | Not possible | Possible |
| Step | Command | Description |
|---|---|---|
| Create | mkfs.ext4 /dev/sdb1 | Create a file system on the partition (= format) |
| Attach | mount /dev/sdb1 /data | Connect it to a directory |
| Detach | umount /data | Disconnect it |
| Check | df -h, mount, lsblk -f | View the status |
| Inspect | fsck /dev/sdb1 | Check and repair file system errors |
| Permanent registration | Edit /etc/fstab | Auto-mount even after reboot |
mount command, it disappears on reboot. To keep using it, you must write it in /etc/fstab.fsck with the file system unmounted. Checking while mounted can cause damage.There are several notations that do the same job, so they appear mixed in the options. The three below are all the same command creating ext4.
mkfs -t ext4 /dev/sdb1 # Specify the type with -t
mkfs.ext4 /dev/sdb1 # The type attached to the name
mke2fs -t ext4 /dev/sdb1 # The program that actually creates the ext family| Command | What it creates |
|---|---|
mke2fs -j /dev/sdb1 | ext3 — -j means journal |
mkfs.xfs /dev/sdb1 | XFS |
mkfs.vfat /dev/sdb1 | FAT |
mkswap /dev/sdb2 | A swap area (not a file system; the command is separate) |
$ sudo mkfs.ext4 /dev/sdb1
mke2fs 1.46.5 (30-Dec-2021)
Creating filesystem with 1310720 4k blocks and 327680 inodes
Filesystem UUID: 5c1e2f0a-8d3b-4e7a-9b61-2f4d7c9a1e35
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736
Allocating group tables: done
Writing inode tables: done
Creating journal (16384 blocks): done
Writing superblocks and filesystem accounting information: donemkfs.ext4 actually calls mke2fs.327680 inodes — the number of inodes is decided at this moment. It's the basis for the statement "even with space left, if the inodes run out you can't create files."Creating journal — because it's ext4, a journal is created. If created as ext2, this line is absent.mkfs erases all existing contents. If you write the wrong partition number, it can't be undone.mount # With no arguments — the list currently mounted
mount -t ext4 /dev/sdb1 /data # Specify the type with -t (usually figured out automatically even if omitted)
mount -o ro /dev/sdb1 /data # Specify options with -o — read-only
mount -o remount,rw /data # Remount with changed options without detaching
mount -a # Mount everything listed in /etc/fstab at once
umount /data # Detach — you can give either the mount point or the device name| Option | Meaning | Opposite |
|---|---|---|
rw | Read and write | ro read-only |
exec | Allow running executables | noexec |
suid | Allow the SetUID bit | nosuid |
auto | Auto-mount at boot and at mount -a | noauto |
nouser | Only root can mount | user regular users can too |
defaults | rw, suid, dev, exec, auto, nouser, async all at once | — |
mkdir /data). Files that were originally in that directory are hidden and not visible while the mount is in place./etc/fstab, test it with mount -a before rebooting. If you reboot with a typo, booting can halt./etc/mtab (or /proc/mounts). fstab is "what to do at boot," and mtab is "the current state."⚠️ Trap: The command to detach is
umount. It's notunmount— there is no n. And ifumountrefuses withtarget is busy, it means someone is using that directory, and the common culprit is your own shell that hascd'd into it.
fsck is a front end that looks at the type and calls the appropriate program. For the ext family, e2fsck actually does the work.xfs_repair, not fsck.fsck -y.lost+found directory at the top level of an ext-family file system is where fsck collects file fragments whose owner it couldn't find. Don't delete it./dev/sdb1 /data ext4 defaults 0 2
│ │ │ │ │ │
│ │ │ │ │ └── fsck check order (0 = none, 1 = root, 2 = others)
│ │ │ │ └────── dump backup flag (usually 0)
│ │ │ └───────────── Mount options
│ │ └────────────────────── File system type
│ └────────────────────────────── Mount point
└──────────────────────────────────────── Device/) gets 1, other file systems to be checked get 2, and ones not to be checked (swap, etc.) get 0.In the first field, a UUID is often written instead of the device name.
$ sudo blkid /dev/sdb1
/dev/sdb1: UUID="5c1e2f0a-8d3b-4e7a-9b61-2f4d7c9a1e35" BLOCK_SIZE="4096" TYPE="ext4"
# /etc/fstab
UUID=5c1e2f0a-8d3b-4e7a-9b61-2f4d7c9a1e35 /data ext4 defaults 0 2sd is the order in which the kernel discovered the disks, so if you add another disk or boot with a USB plugged in, sdb can get shifted to sdc.blkid or lsblk -f.mkfs and then also mount it.df -i.fsck can be run while mounted" → The rule is to run it unmounted./etc/mtab, it's auto-mounted at boot" → That role belongs to /etc/fstab. mtab merely shows the current state.Tomorrow we follow the path from the moment the power is switched on until the login screen appears — the boot process and the boot manager.
/etc/fstab : A configuration file recording the entries to be mounted automatically at boot.Click a choice to reveal the answer and explanation.
Question 1
Which of the following is the Linux file system in which journaling was first introduced?
Question 2
Which of the following is information NOT stored in the inode?
Question 3
Which of the following is the configuration file that records the file systems to be mounted automatically at boot?
Question 4
Which of the following is a file system in which a single file cannot exceed 4GB, limiting storage of large files?
Question 5
Which of the following is the command that creates a file system on a partition?