CertNote/ Commute Study Notes
Roadmap
KOEN
CLF-C02 · FoundationalCloud Practitioner - Foundational
DVA-C02 · AssociateDeveloper - Associate
SAA-C03 · AssociateSolutions Architect - Associate
SOA-C02 · AssociateCloudOps Engineer - Associate
SAP-C02 · ProfessionalSolutions Architect - Professional
DOP-C02 · ProfessionalDevOps Engineer - Professional
Linux Master 2 · 2급KAIT Linux Master - Level 2
  • Week 1
    • 1.Operating Systems and the Kernel: What Linux Does
    • 2.The Birth of Linux: From Unix to Linus
    • 3.Free Software and Open Source: What a License Decides
    • 4.Distributions: The Unit That Bundles the Kernel and Tools for Sale
    • 5.Week 1 Review: The Identity Behind the Name Linux
  • Week 2
    • 1.Installation Types and Preparation: Before You First Install Linux
    • 2.Partitions: How to Divide a Disk
    • 3.File Systems: What to Lay Over the Divided Space
    • 4.The Boot Manager: From Power-On to Login
    • 5.Week 2 Review: From Installation to Boot in One Line
  • Week 3
  • Week 4
  • Week 5
  • Week 6
  • Week 7
  • Week 8
  • Week 9
  • Week 10
  • Week 11
SCS-C03 · SpecialtySecurity - Specialty
Linux Master 1 · 1급KAIT Linux Master - Level 1
MLA-C01 · AssociateMachine Learning Engineer - Associate
AIF-C01 · FoundationalAI Practitioner - Foundational
DEA-C01 · AssociateData Engineer - Associate
MLS-C01 · SpecialtyMachine Learning - Specialty
SQLD · 개발자SQL Developer (SQLD)

© CertNote · 주간랩스

  • About
  • Changelog
  • Contact
  • Terms
  • Privacy
← Linux Master 2/Week 2/Day 2

Based on the Linux Master 2 exam syllabus·Report an error

Linux Master 2· AssociateWeek 2 · Day 2~22 min read

Day 2 - Partitions: How to Divide a Disk

📌 Key Takeaways

  • The MBR scheme can create only up to 4 primary partitions; if you need more, you create logical partitions inside an extended partition.
  • GPT removes MBR's limits (2TB, 4 partitions) and is paired with UEFI.
  • In device names, /dev/sda is the first disk and /dev/sda1 is its first partition.
  • The minimal layout is just two: / (root) and swap. Separating /boot and /home on top of that is a common choice.
  • The partitioning tools are fdisk (MBR), gdisk (GPT), and parted (both).

Why Divide?

There are reasons to divide a disk rather than use it whole.

  • Isolation: If /home is kept separate, then even if logs run wild and fill up /var, user data stays safe.
  • Easier reinstallation: If /home is separate, personal files survive even when you wipe and replace the distribution.
  • Per-purpose tuning: Each partition can have a different file system and mount options.
  • Securing swap: Swap needs a separate partition (or file).

MBR and GPT

CategoryMBRGPT
Full nameMaster Boot RecordGUID Partition Table
Maximum disk size2TBPractically unlimited
Number of primary partitionsUp to 4128 or more
Paired firmwareBIOSUEFI
Backup of partition infoNone (a single first sector)A copy kept at the end of the disk
  • 2TB and 4 — memorize MBR's two limits as numbers and most questions can be solved.
  • Most newly installed systems these days use the UEFI + GPT combination.

Why Exactly 4, Why Exactly 2TB?

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 × 4
  • Recording one partition takes 16 bytes and there are only 64 bytes of room, so 4 slots is all there is. That's why there are 4 primary partitions.
  • Each slot records the partition's start position and size as 32-bit numbers (in sectors). Since one sector is 512 bytes, 2³² × 512 bytes = 2TB is the limit of what can be expressed.
  • The first 446 bytes are the place for the bootloader. The statement "BIOS reads the bootloader from the MBR" points to exactly this area.

GPT discards this structure and puts a generous, separate table at the front of the disk.

  • It records partition positions in 64 bits, so the capacity limit has practically vanished, and it provides 128 slots by default. The distinction of extended and logical partitions is no longer needed.
  • It puts one more copy of the table at the very end of the disk. Even if the front is damaged, it can be recovered.
  • In the very first sector it leaves a protective MBR. This is a device to prevent old tools that don't know GPT from mistaking the disk for "empty" and overwriting it.
  • Each partition gets a unique identifier (GUID). This is the G in the name.

The Three Kinds of MBR Partitions

  ┌──────────────────────────────────────────────┐
  │  Primary partitions   up to 4                  │
  │  ┌────┬────┬────┬──────────────────────────┐ │
  │  │sda1│sda2│sda3│  Extended partition       │ │
  │  │    │    │    │  ┌──────┬──────┬───────┐  │ │
  │  │    │    │    │  │ sda5 │ sda6 │ sda7  │  │ │
  │  │    │    │    │  │ Logical               │  │ │
  │  │    │    │    │  └──────┴──────┴───────┘  │ │
  │  └────┴────┴────┴──────────────────────────┘ │
  └──────────────────────────────────────────────┘
KindDescription
PrimaryA partition you actually use. Up to 4
ExtendedA shell that holds logical partitions. You can't put data directly in it. Only 1 per disk
LogicalA 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.

Reading Device Names

   /dev/sda1
        │││
        ││└── Partition number (from 1)
        │└─── Disk order (a = first, b = second ...)
        └──── Device type
NotationMeaning
/dev/hdaThe first disk of the IDE type (old notation)
/dev/sdaThe first SATA, SCSI, or USB disk
/dev/sdb2The second partition of the second disk
/dev/nvme0n1p1The first partition of an NVMe SSD
/dev/sr0Optical drive (CD/DVD)
/dev/vdaThe virtual disk of a virtual machine (KVM)
/dev/fd0Floppy 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 nameConnection location
/dev/hdaprimary master
/dev/hdbprimary slave
/dev/hdcsecondary master
/dev/hddsecondary slave
  • The 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.
  • NVMe has three pieces: nvme0 (controller) · n1 (storage space) · p1 (partition). It differs from sda1 in that a p is added before the partition number.

⚠️ Trap: /dev/sda is the whole disk and /dev/sda1 is a partition inside it. You pass the disk (/dev/sda) to fdisk, which divides partitions, and the partition (/dev/sda1) to mkfs, which creates file systems. One digit's difference makes the target completely different.

Which Mount Points to Divide Into

Mount pointWhat it holdsWhy separating is good
/ (root)Everything elseMust exist
swapSpare space used when memory runs shortNeeds a separate area
/bootKernel and bootloader filesEssential for booting, keep it small (about 1GB)
/homeUsers' personal filesData is preserved even on reinstall
/varLogs, mail, DB, and other frequently changing dataPrevents the system from halting due to runaway logs
/tmpTemporary filesAnyone can write to it, so runaway risk
  • The minimal layout is the two: / and swap. If the exam asks what is "absolutely required," the answer is /.
  • A UEFI system additionally needs an EFI System Partition (ESP, /boot/efi).

swap Size

  • Old rule: 1 to 2 times the memory.
  • Memory is large these days, so it isn't applied as-is. With 8GB or more, it's often set equal to or less than the memory.
  • To use hibernation, you need at least the memory size.
  • The exam still sometimes asks the classic "1 to 2 times" rule.

Swap is not a place for storing files, so there are separate commands both for creating it and for turning it on.

CommandWhat it does
mkswap /dev/sda2Initializes the partition as a swap area (it's not mkfs)
swapon /dev/sda2Turns swap on (it's not mount)
swapoff /dev/sda2Turns swap off
swapon -sLists the swap that's on. Same content as cat /proc/swaps
free -hShows memory and swap usage together
  • Swap isn't attached to the directory tree, so it has no mount point. It doesn't show up in df either.
  • To make it turn on automatically at every boot, write a line like /dev/sda2 swap swap defaults 0 0 in /etc/fstab (we cover this tomorrow).

Partitioning Tools

CommandScheme it handlesFeature
fdiskMBR (recent versions GPT too)The most traditional interactive tool
gdiskGPT onlyOperates similarly to fdisk
partedBoth MBR and GPTCan 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

Reading the Output

$ 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 Linux
  • Disklabel type is the partitioning scheme. dos means MBR, and gpt means GPT. Be careful: the letters "MBR" don't appear.
  • The * in the Boot column marks the partition flagged as bootable.
  • Id is a hexadecimal code indicating the partition's purpose.
IdType
83Linux — an ordinary Linux partition
82Linux swap — swap
5Extended — an extended partition
7HPFS/NTFS/exFAT — a Windows partition
bW95 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 rom
  • The line with TYPE 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.

Commands Used Inside fdisk

If you enter by specifying a disk like fdisk /dev/sdb, you get an interactive screen that accepts one-letter commands.

KeyMeaningMnemonic
mHelpmenu
pPrint the current partition tableprint
nCreate a new partitionnew
dDelete a partitiondelete
tChange the partition type (Id)type
lList the type codeslist
wSave and exitwrite
qExit without savingquit
$ 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.
  • The 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.
  • For the size, it's usual to write something like +5G rather than an end sector number.
  • For a partition to be used as swap, change its type to 82 with t.

⚠️ Trap: Work done inside fdisk is not written to disk until you press w. If you made a mistake, exit with q and it's as if nothing happened. Conversely, if you leave without w, everything you carefully divided disappears. Options that swap the keys for "save and exit" and "exit without saving" are easily used as wrong answers.

Commonly Mistaken Points

  1. "MBR can create only up to 4 partitions" → It's up to 4 primary partitions. If you create logical partitions inside an extended partition, you can have more.
  2. "With 3 primary + 1 extended, logical starts at 4" → Numbers 1 to 4 are reserved for primary and extended. Logical always starts at 5.
  3. "GPT also has extended partitions" → It doesn't. With plenty of slots, they aren't needed.
  4. "Swap is also created with mkfs and attached with mount" → It's mkswap and swapon.
  5. "If fdisk -l shows dos, it's a Windows disk" → It means the MBR scheme, regardless of operating system.
  6. "/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.

📖 Glossary

  • Partition : A logically divided region of a single disk.
  • MBR : Master Boot Record. The traditional partitioning scheme with limits of 2TB and 4 primary partitions.
  • GPT : GUID Partition Table. A scheme that removes MBR's limits and is used together with UEFI.
  • Primary partition : A partition that holds actual data. Up to 4 in MBR.
  • Extended partition : A shell for holding logical partitions. One per disk, can't store directly.
  • Logical partition : A partition created inside an extended partition. Numbering starts from 5.
  • Swap : An area where disk is used as temporary memory when memory runs short.
  • Mount point : The point that specifies where in the directory tree a partition is attached.
  • ESP : EFI System Partition. Needed for UEFI booting and usually mounted at /boot/efi.

📝 Practice Questions

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?

PreviousInstallation Types and Preparation: Before You First Install LinuxWeek 2 · Day 1Next File Systems: What to Lay Over the Divided SpaceWeek 2 · Day 3

Official references

  • Linux Master 2 official exam syllabus(opens in a new tab)

On this page

  • Key Takeaways
  • Why Divide?
  • MBR and GPT
  • Why Exactly 4, Why Exactly 2TB?
  • The Three Kinds of MBR Partitions
  • Reading Device Names
  • Which Mount Points to Divide Into
  • swap Size
  • Partitioning Tools
  • Reading the Output
  • Commands Used Inside fdisk
  • Commonly Mistaken Points
  • Glossary
  • Practice Questions