Based on the Linux Master 2 exam syllabusReport an error
/dev/sda is the first disk and /dev/sda1 is its first partition./ (root) and swap. Separating /boot and /home on top of that is a common choice.fdisk (MBR), gdisk (GPT), and parted (both).There are reasons to divide a disk rather than use it whole.
/home is kept separate, then even if logs run wild and fill up /var, user data stays safe./home is separate, personal files survive even when you wipe and replace the distribution.| Category | MBR | GPT |
|---|---|---|
| Full name | Master Boot Record | GUID Partition Table |
| Maximum disk size | 2TB | Practically unlimited |
| Number of primary partitions | Up to 4 | 128 or more |
| Paired firmware | BIOS | UEFI |
| Backup of partition info | None (a single first sector) | A copy kept at the end of the disk |
These two numbers aren't arbitrarily set rules; they come from the fact that the space MBR occupies is only 512 bytes.
First sector of the disk (512 bytes) = MBR
┌──────────────────────────┬─────────────────────┬──────────┐
│ Bootloader code 446 B │ Partition table 64 B │ Signature 2 B │
└──────────────────────────┴─────────────────────┴──────────┘
16-byte slot × 4GPT discards this structure and puts a generous, separate table at the front of the disk.
┌──────────────────────────────────────────────┐
│ Primary partitions up to 4 │
│ ┌────┬────┬────┬──────────────────────────┐ │
│ │sda1│sda2│sda3│ Extended partition │ │
│ │ │ │ │ ┌──────┬──────┬───────┐ │ │
│ │ │ │ │ │ sda5 │ sda6 │ sda7 │ │ │
│ │ │ │ │ │ Logical │ │ │
│ │ │ │ │ └──────┴──────┴───────┘ │ │
│ └────┴────┴────┴──────────────────────────┘ │
└──────────────────────────────────────────────┘| Kind | Description |
|---|---|
| Primary | A partition you actually use. Up to 4 |
| Extended | A shell that holds logical partitions. You can't put data directly in it. Only 1 per disk |
| Logical | A partition created inside the extended partition. Numbering starts from 5 |
Two traps. ① An extended partition is not storage space in itself. ② Logical partition numbers start at
sda5— even if there are only 2 primary partitions, logical ones start at 5.
/dev/sda1
│││
││└── Partition number (from 1)
│└─── Disk order (a = first, b = second ...)
└──── Device type| Notation | Meaning |
|---|---|
/dev/hda | The first disk of the IDE type (old notation) |
/dev/sda | The first SATA, SCSI, or USB disk |
/dev/sdb2 | The second partition of the second disk |
/dev/nvme0n1p1 | The first partition of an NVMe SSD |
/dev/sr0 | Optical drive (CD/DVD) |
/dev/vda | The virtual disk of a virtual machine (KVM) |
/dev/fd0 | Floppy disk drive |
With the old IDE type, the motherboard had two cables (primary and secondary), and each cable had two devices (master and slave). So the letter after hd was decided by where it was connected.
| Device name | Connection location |
|---|---|
/dev/hda | primary master |
/dev/hdb | primary slave |
/dev/hdc | secondary master |
/dev/hdd | secondary slave |
sd family is different. a, b, c are assigned in the order the kernel discovered them, not by location. When you plug in a USB stick, it gets the next letter that is still free at that moment.nvme0 (controller) · n1 (storage space) · p1 (partition). It differs from sda1 in that a p is added before the partition number.⚠️ Trap:
/dev/sdais the whole disk and/dev/sda1is a partition inside it. You pass the disk (/dev/sda) tofdisk, which divides partitions, and the partition (/dev/sda1) tomkfs, which creates file systems. One digit's difference makes the target completely different.
| Mount point | What it holds | Why separating is good |
|---|---|---|
/ (root) | Everything else | Must exist |
| swap | Spare space used when memory runs short | Needs a separate area |
/boot | Kernel and bootloader files | Essential for booting, keep it small (about 1GB) |
/home | Users' personal files | Data is preserved even on reinstall |
/var | Logs, mail, DB, and other frequently changing data | Prevents the system from halting due to runaway logs |
/tmp | Temporary files | Anyone can write to it, so runaway risk |
/ and swap. If the exam asks what is "absolutely required," the answer is /./boot/efi).Swap is not a place for storing files, so there are separate commands both for creating it and for turning it on.
| Command | What it does |
|---|---|
mkswap /dev/sda2 | Initializes the partition as a swap area (it's not mkfs) |
swapon /dev/sda2 | Turns swap on (it's not mount) |
swapoff /dev/sda2 | Turns swap off |
swapon -s | Lists the swap that's on. Same content as cat /proc/swaps |
free -h | Shows memory and swap usage together |
df either./dev/sda2 swap swap defaults 0 0 in /etc/fstab (we cover this tomorrow).| Command | Scheme it handles | Feature |
|---|---|---|
fdisk | MBR (recent versions GPT too) | The most traditional interactive tool |
gdisk | GPT only | Operates similarly to fdisk |
parted | Both MBR and GPT | Can even resize, good for scripting |
df | — | Checks the usage of mounted partitions |
lsblk | — | Shows the structure of disks and partitions as a tree |
sudo fdisk -l # List of disks and partitions
lsblk # View as a tree
df -h # Usage of mounted partitions$ sudo fdisk -l /dev/sda
Disk /dev/sda: 20 GiB, 21474836480 bytes, 41943040 sectors
Units: sectors of 1 * 512 = 512 bytes
Disklabel type: dos
Device Boot Start End Sectors Size Id Type
/dev/sda1 * 2048 2099199 2097152 1G 83 Linux
/dev/sda2 2099200 6293503 4194304 2G 82 Linux swap / Solaris
/dev/sda3 6293504 41943039 35649536 17G 83 LinuxDisklabel type is the partitioning scheme. dos means MBR, and gpt means GPT. Be careful: the letters "MBR" don't appear.* in the Boot column marks the partition flagged as bootable.Id is a hexadecimal code indicating the partition's purpose.| Id | Type |
|---|---|
| 83 | Linux — an ordinary Linux partition |
| 82 | Linux swap — swap |
| 5 | Extended — an extended partition |
| 7 | HPFS/NTFS/exFAT — a Windows partition |
| b | W95 FAT32 |
$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 20G 0 disk
├─sda1 8:1 0 1G 0 part /boot
├─sda2 8:2 0 2G 0 part [SWAP]
└─sda3 8:3 0 17G 0 part /
sr0 11:0 1 1024M 0 romTYPE of disk is the disk, and the part lines beneath are partitions. Swap is shown as [SWAP] instead of a mount point.fdisk -l shows how it's divided, and df -h shows the usage of what's mounted. A partition that was created but not mounted does not appear in df.If you enter by specifying a disk like fdisk /dev/sdb, you get an interactive screen that accepts one-letter commands.
| Key | Meaning | Mnemonic |
|---|---|---|
m | Help | menu |
p | Print the current partition table | |
n | Create a new partition | new |
d | Delete a partition | delete |
t | Change the partition type (Id) | type |
l | List the type codes | list |
w | Save and exit | write |
q | Exit without saving | quit |
$ sudo fdisk /dev/sdb
Command (m for help): n
Partition type
p primary (0 primary, 0 extended, 4 free)
e extended (container for logical partitions)
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-41943039, default 2048):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-41943039, default 41943039): +5G
Created a new partition 1 of type 'Linux' and of size 5 GiB.
Command (m for help): w
The partition table has been altered.p (primary) and e (extended) the screen asks about are the primary and extended partitions we saw earlier. 4 free is the number of remaining primary partition slots.+5G rather than an end sector number.t.⚠️ Trap: Work done inside
fdiskis not written to disk until you pressw. If you made a mistake, exit withqand it's as if nothing happened. Conversely, if you leave withoutw, everything you carefully divided disappears. Options that swap the keys for "save and exit" and "exit without saving" are easily used as wrong answers.
mkfs and attached with mount" → It's mkswap and swapon.fdisk -l shows dos, it's a Windows disk" → It means the MBR scheme, regardless of operating system./dev/sdb is the second partition" → It's the second disk. A partition has a number after it.Tomorrow we look at what goes onto the divided partitions — the types of file systems and their differences.
/boot/efi.Click a choice to reveal the answer and explanation.
Question 1
Which of the following is the maximum number of primary partitions you can create in the MBR scheme?
Question 2
Which of the following correctly describes an extended partition?
Question 3
Which of the following is the device name for the first partition of the second SATA disk?
Question 4
Which of the following is the mount point that must be specified when installing Linux?
Question 5
Which of the following correctly pairs the limits of the MBR scheme?