Understanding the Linux File System, MBRs, UEFI, ext4 - A Primer Guide

We go over the power of the Linux f ile system, how it works, how to configure it, how to activate partitions, setting up Volume Groups, setting up BIOS etc..

Understanding the Linux File System, MBRs, UEFI, ext4 - A Primer Guide

You might want to bookmark this page, because few Linux file system guides will explain it at this thorough and basic foundational level. But by doing this you can actually really understand what is occurring in a Linux system within its partitions.

To understand why things are as they are we need to look at the computer ecosystem itself.

  • Older systems used MBR partitioning.  It was limited to 4 partitions and 2 TB disk size. It does not utilize the UEFI (GPT) labelling such as 16E7FAC2-2F8C-45DB-AC18-25B255150A18.
  • UEFI stands for Unified Extensible Firmware Interface.
  • UUID stands for Universally Unique Identifier
  • The Non-UEFI MBR partitioning scheme uses 32-bit addressing (hence 2 TB Limits)
  • UEFI schemes use the GPT partition table system and uses 64-bit addressing. They can also support network booting.
  • Typically today you enable UEFI in your bios. Newer systems support it adhoc and give you no other options.
  • Linux will install a /boot/efi FAT32 partition typically 300MB as the first partition for UEFI compatibility, and add an optional linux-swap.

Part A: Basic Partitioning and UUID Understanding

Inside linux you can visually inspect your paritions with gparted:

sudo apt install gparted -y
sudo gparted
An example partition scheme using /boot/efi

You will also be able  to see this from the command line:

  • lsblk means 'list bulk devices'
sudo lsblk
sda      8:0    0 931.5G  0 disk 
├─sda1   8:1    0 922.7G  0 part 
└─sda2   8:2    0   8.8G  0 part 
sdb      8:16   0 119.2G  0 disk 
├─sdb1   8:17   0 110.4G  0 part /home
│                                /
└─sdb2   8:18   0   8.8G  0 part [SWAP]
  • We can see all the physical drives, (sda, sdb) This is a system with two hard drives.
  • The partitions are listed underneath namely (sda1, sda2 .. etc)
  • '/' is your 'root' parition or 'root frame-of-reference' everything is mounted under that.
  • We can inspect the physical drives with bkid;
sudo blkid --probe /dev/sda

We will see:

c@parrot 192.168.1.4 [~] $ sudo blkid --probe /dev/sda
/dev/sda: PTUUID="74794bd6" PTTYPE="dos"
  • /dev/sda, PTUUID (Partition Table Unique ID) is 74794bd6.  PTTYPE (Partition Table Type) is "dos"
  • This is important making a DOS compatible partition table will make your hard drive compatible with pre-UEFI systems.

We can then inspect the partitions inside, note:

  • Even thought sda1 is shown as a 'sub-fork' of sda, you reference it as '/dev/sda1' NOT '/dev/sda/sda1'  This is a common mistake.

Looking at /dev/sdb:

sudo bulkid --probe /dev/sdb
c@parrot 192.168.1.4 [~] $ sudo blkid --probe /dev/sdb
/dev/sdb: PTUUID="5fbe8a2e" PTTYPE="dos"
  • We look at /dev/sdb1 as it holds the root mount point : '/'
sudo blkid --probe /dev/sdb1

We will see:

c@parrot 192.168.1.4 [~] $ sudo blkid --probe /dev/sdb1
/dev/sdb1: UUID="f36d35d6-a57c-4e5d-90c3-3c955d6a1691" UUID_SUB="b4221676-fe66-4452-953a-c1f1013222dc" BLOCK_SIZE="4096" TYPE="btrfs" USAGE="filesystem" PART_ENTRY_SCHEME="dos" PART_ENTRY_UUID="5fbe8a2e-01" PART_ENTRY_TYPE="0x83" PART_ENTRY_FLAGS="0x80" PART_ENTRY_NUMBER="1" PART_ENTRY_OFFSET="2048" PART_ENTRY_SIZE="231610804" PART_ENTRY_DISK="8:16"
  • We can see that - PART_ENTRY_UUID is a subset of the PTTYPE from above '5fbe8a2e-01'

How the system specifies mount points at boot time is kept in a record at /etc/fstab. If you 'cat' it (dump to screen) it's contents you will see:

sudo cat /etc/fstab

You will see:

# <file system>             <mount point>  <type>  <options>  <dump>  <pass>
UUID=f36d35d6-a57c-4e5d-90c3-3c955d6a1691 /              btrfs   subvol=/@,defaults,noatime,autodefrag,compress=zstd,discard,compress=lzo 0 0
UUID=f36d35d6-a57c-4e5d-90c3-3c955d6a1691 /home          btrfs   subvol=/@home,defaults,noatime,autodefrag,compress=zstd,discard,compress=lzo 0 0
UUID=709be9a5-223c-464c-94b4-a20c2506fe37 swap           swap    defaults,noatime,discard 0 0
tmpfs                                     /tmp           tmpfs   defaults,noatime,mode=1777 0 0
  • We can see that they match, namely 'f36d35d6..' matches the blkid --probe /dev/sdb1.
  • btrfs stands for 'B-Tree FileSystem' an advanced filesystem that can support native compression etc.

Part B: Understand Linux Partitioning Power and Configurability.

  • Recall that we used a 'dos' type partitioning table to maintain compatibility with non-UEFI, and windows systems:
/dev/sdb: PTUUID="5fbe8a2e" PTTYPE="dos"
  • However after this point Linux's true power can come out. Consider the following partial lsblk dump:
sdc      8:32   0 111.8G  0 disk 

It has no partitions! However what gets interesting is partitions are optional! We can fully do this:

c@parrot 192.168.1.4 [~] $ sudo mkfs.ext4 /dev/sdc
mke2fs 1.47.2 (1-Jan-2025)
/dev/sdc contains a ext4 file system
	last mounted on Mon Dec 22 11:55:49 2025
Proceed anyway? (y,N) Y
Discarding device blocks: done                            
Creating filesystem with 29305206 4k blocks and 7331840 inodes
Filesystem UUID: 970602c5-720a-4963-af49-72ed58fa959d
Superblock backups stored on blocks: 
	32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 
	4096000, 7962624, 11239424, 20480000, 23887872

Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (131072 blocks): done
Writing superblocks and filesystem accounting information: done   

c@parrot 192.168.1.4 [~] $ 
  • We have just formatted the raw physical platter and completely skipped the partition table!
  • mkfs (make filesystem) .ext4 (extended 4 filesystem)

When we examine this inside fdisk (linux partition manager) we will see the partition dump as:

Device does not contain a recognized partition table.
Created a new DOS (MBR) disklabel with disk identifier 0x43e663b3.

Command (m for help): p
Disk /dev/sdc: 111.79 GiB, 120034123776 bytes, 234441648 sectors
Disk model: YongzhenWeiye   
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: dos
Disk identifier: 0x43e663b3

We can now add a GPT partition when we access the help:

  Create a new label
   g   create a new empty GPT partition table
   G   create a new empty SGI (IRIX) partition table
   o   create a new empty MBR (DOS) partition table
   s   create a new empty Sun partition table
Command (m for help): g
Created a new GPT disklabel (GUID: 833C493A-B89D-284C-81B1-BA4BD36BDEDD).
The device contains 'ext4' signature and it will be removed by a write command. See fdisk(8) man page and --wipe option for more details.

Command (m for help): w

The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
  • Once we have setup a partition table to a disk we pretty much must used fdisk to make partitions inside of it:
  • If one types 'n' and hits enter a few times you will get a default Linux partition:
Command (m for help): n
Partition number (1-128, default 1): 1
First sector (2048-234441614, default 2048): 
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-234441614, default 234440703): 

Created a new partition 1 of type 'Linux filesystem' and of size 111.8 GiB.
  • Remember to type 'w' to save this:
  • We can now see it in the lsblk table:
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS
sda      8:0    0 931.5G  0 disk 
├─sda1   8:1    0 922.7G  0 part 
└─sda2   8:2    0   8.8G  0 part 
sdb      8:16   0 119.2G  0 disk 
├─sdb1   8:17   0 110.4G  0 part /home
│                                /
└─sdb2   8:18   0   8.8G  0 part [SWAP]
sdc      8:32   0 111.8G  0 disk 
└─sdc1   8:33   0 111.8G  0 part 
sdd      8:48   0 931.5G  0 disk 
├─sdd1   8:49   0   512M  0 part 
└─sdd2   8:50   0   931G  0 part 
sr0     11:0    1  1024M  0 rom  
  • We used fdisk to remove the partitions / partition tables.

Please note: /dev/sdc1 is not formatted. You will still need to do:

sudo mkfs.ext4 /dev/sdc1

You will see:

c@parrot 192.168.1.4 [~] $ sudo mkfs.ext4 /dev/sdc1
mke2fs 1.47.2 (1-Jan-2025)
Discarding device blocks: done                            
Creating filesystem with 29304832 4k blocks and 7331840 inodes
Filesystem UUID: ede3fe7f-7382-4d99-99ed-ecc06e402eae
Superblock backups stored on blocks: 
	32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 
	4096000, 7962624, 11239424, 20480000, 23887872

Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (131072 blocks): done
Writing superblocks and filesystem accounting information: done   

Part C: Mounting Partitions

  • Linux is not constrained to 'C:' and a physical drive (/dev/sda) or it's parititon (/dev/sda1) can be mounted anywhere it is not already mounted:
  • Consider the following mounting example:
mount -t auto /dev/sdc1 sdc1

We can now see on our lsblk it's mount points:

sda      8:0    0 931.5G  0 disk 
├─sda1   8:1    0 922.7G  0 part 
└─sda2   8:2    0   8.8G  0 part 
sdb      8:16   0 119.2G  0 disk 
├─sdb1   8:17   0 110.4G  0 part /home
│                                /
└─sdb2   8:18   0   8.8G  0 part [SWAP]
sdc      8:32   0 111.8G  0 disk 
└─sdc1   8:33   0 111.8G  0 part /home/c/sdc1
sdd      8:48   0 931.5G  0 disk 
├─sdd1   8:49   0   512M  0 part 
└─sdd2   8:50   0   931G  0 part 
sr0     11:0    1  1024M  0 rom  

And we can then umount it with:

sudo umount /dev/sdc1     # or
sudo umount /home/c/sdc1  
  • You can specify the mount point (/home/c/sdc1) or the device (/dev/sdc1)

Part D. Ownership Permissions

If you looked at the drive before and after mouting you will see some interesting things.

Before mounting:

c c (User 'c' / Group 'c') for simplicity sake.
drwxr-xr-x 1 c c  0 Dec 22 11:36 sda1
drwxr-xr-x 1 c c  0 Dec 22 11:08 sdc
drwxr-xr-x 1 c c  0 Dec 22 14:06 sdc1
drwx------ 1 c c 22 Jul  2 10:46 Templates

After mounting:

drwxr-xr-x 1 c    c       0 Nov 28 19:22 Public
drwxr-xr-x 1 c    c       0 Dec 22 11:36 sda1
drwxr-xr-x 1 c    c       0 Dec 22 11:08 sdc
drwxr-xr-x 3 root root 4096 Dec 22 14:07 sdc1
drwx------ 1 c    c      22 Jul  2 10:46 Templates
  • Ownership has changed to 'root'

Changing ownership of the entire mounted point becomes:

sudo chown -R c:c sdc1
sudo umount /dev/sdc1
sudo mount -t auto /dev/sdc1 sdc1
  • This is persistent, it will come back at the remount point.

It should be understood that we have effectivelly 'mounted a filesystem inside a filesystem'

  • When we called mkfs.ext4 it automatcally gave ownership to 'root' and once we changed it with 'chown' Change Ownership -R (recursive) to user 'c' group 'c' it was permanent.

Part E: 'chkdsk' and Disk Health Management in Linux

Once you get the hang of partitions, disks/ their block and partition references, it is always a good idea to scan the disk and mark off any bad sectors.

  • SATA Disks typically use a manual process to mark off bad sectors.
  • SSD / NVMe disks automatically will mark off back sectors of a disk from their firmware and this is not recommended.
lsblk -o NAME,TYPE,SIZE,MODEL,TRAN
  • Explanation of output columns:
  • NAME: Device name (e.g., sda, nvme0n1).
  • TRAN: Transport type (this is the key column):
  • sata → SATA drive (HDD or SSD).
  • nvme → NVMe drive.
  • usb → USB-attached drive.
  • ata → Also SATA (some older systems may show this instead of sata).
  • MODEL: Drive model name.

Example output:

[sudo] password for c: 
NAME   TYPE   SIZE MODEL                     TRAN
sda    disk 931.5G HGST HTS721010A9E630      sata
├─sda1 part 922.7G                           
└─sda2 part   8.8G                           
sdb    disk 119.2G TOSHIBA THNSNJ128G8NU     sata
├─sdb1 part 110.4G                           
└─sdb2 part   8.8G                           
sdc    disk 111.8G Samsung SSD 840 EVO 120GB usb
└─sdc1 part 111.8G                           
sdd    disk 931.5G ST1000LM024 HN-M101MBB    usb
├─sdd1 part   512M                           
└─sdd2 part   931G                           
sr0    rom   1024M HL-DT-ST DVDRAM GUB0N     sata
  • Naturally you can google the device to get it's characteristics

We can then use smartctl and badblocks to handle SATA management (make sure it is not mounted)

sudo smartctl -H /dev/sdb

Will produce an output as:

c@parrot 192.168.1.4 [~] $ sudo smartctl -H /dev/sdb
smartctl 7.4 2023-08-01 r5530 [x86_64-linux-6.12.32-amd64] (local build)
Copyright (C) 2002-23, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF READ SMART DATA SECTION ===
SMART overall-health self-assessment test result: PASSED
Please note the following marginal Attributes:
ID# ATTRIBUTE_NAME          FLAG     VALUE WORST THRESH TYPE      UPDATED  WHEN_FAILED RAW_VALUE
194 Temperature_Celsius     0x0023   063   018   020    Pre-fail  Always   In_the_past 37 (Min/Max -11/82)

And we can scan / repair it with -n

  • Note if you use -w that is a destructive test. (destroyes existing data on disk)
  • Note if you use -n that is a non-destructive test. (keeps existing data on disk)
sudo badblocks -n -s /dev/sdc
badblocks being scanned and repaired.

Part F: LVM (Logical Volume Management)

Above all disk management we now look at a the LVM framework.  It is installed with:

sudo apt install lvm2 -y
  • It is the power that allows you to make striped, RAID5, RAID 1,0, RAID 10 type builds in a system.
  • Only Logical Volumes are listed in your /etc/fstab.  

There are three levels to understand:

  • PV : Physical Volumes LEVEL 1 (base layer - built off of /dev/sdc or /dev/sdc1 partitions)

 - Cannot be mounted (at all) it is a frame-of-reference only for Volume Groups.

 - You cannot make multiple PV's to a single partition.  If you need multiple PV's make multiple partitions under it. aka make /dev/sda1, /dev/sda2.. etc

- You can force an entire disk to a physical volume and wipe it's partition table out directly mapping /dev/sda ..

 - Can be defined to either the entire disk /dev/sda or a partition inside of it /dev/sda1..

  • VG: Volume Group LEVEL 2 (One or MORE Physical Volumes)

- Cannot be mounted (at all) it is a frame-of-reference that allows Logical Volumes to be defined.

  • LV: Logical Volume LEVEL 3 (Only ONE Volume Group can be referenced by a Logical Volume)

 - Multiple LV (Logical Volumes) can be defined.  Forinstance if your Volume Group has 4 PV's (Physical Volumes) you can define  two RAID 10's to the same VG!

 - Logical Volumes are listed in your /etc/fstab. ONLY LV's are listed in fstab.

Before one gets started it requires some planning and thought. Pretend you wanted to make an 'artificial RAID5' that requires 3 PV's (Physical Volumes) but only have a single disk, and want to make a 'pseudo-RAID5'  - it can be done, but then it is upon you to use fdisk to make 3 partitions beneath it first! Then those 3 partitions become 3 PV's, and those 3PV's become 1 VG (Volume Group) and the LV (Logical Volume) will check to see that the VG has 3 members!

Part G(a): LVM Construction WalkThrough:

We will start with the following lsblk example:

sda      8:0    0 931.5G  0 disk 
sdb      8:16   0 119.2G  0 disk 
├─sdb1   8:17   0 110.4G  0 part /home
│                                /
└─sdb2   8:18   0   8.8G  0 part [SWAP]
sdc      8:32   0 111.8G  0 disk 
sdd      8:48   0 931.5G  0 disk 
sr0     11:0    1  1024M  0 rom  

We want to use /dev/sda and /dev/sdc and make a basic LVM. (2 TB from 1 TB)

sudo pvcreate /dev/sda
sudo pvcreate /dev/sdd

It should be noted that the 'dos signature' or 'dos boot record' is wiped because we are working with the root whole disks

c@parrot 192.168.1.4 [~] $ sudo pvcreate /dev/sda
WARNING: dos signature detected on /dev/sda at offset 510. Wipe it? [y/n]: y
  Wiping dos signature on /dev/sda.
  Physical volume "/dev/sda" successfully created.

It should be noted that 'fragments' of a partition table can exist, and you may have to wipe it at a higher level as in:

sudo wipefs -a /dev/sdd
c@parrot 192.168.1.4 [~] $ sudo wipefs -a /dev/sdd
/dev/sdd: 8 bytes were erased at offset 0x00000200 (gpt): 45 46 49 20 50 41 52 54
/dev/sdd: 8 bytes were erased at offset 0xe8e0db5e00 (gpt): 45 46 49 20 50 41 52 54
/dev/sdd: 2 bytes were erased at offset 0x000001fe (PMBR): 55 aa
/dev/sdd: calling ioctl to re-read partition table: Success

After this point it should finally create the physical volume:

c@parrot 192.168.1.4 [~] $ sudo pvcreate /dev/sdd
  Physical volume "/dev/sdd" successfully created.

Viewing the Physical volumes:

sudo pvs
c@parrot 192.168.1.4 [~] $ sudo pvs
  PV         VG Fmt  Attr PSize   PFree  
  /dev/sda      lvm2 ---  931.51g 931.51g
  /dev/sdd      lvm2 ---  931.51g 931.51g

Part G(b): Making the Volume Groups.

  • We can now start making the volume groups:
sudo vgcreate vg_a /dev/sda /dev/sdd

Which can be view with:

sudo vgs

Will show up as:

c@parrot 192.168.1.4 [~] $ sudo vgs
  VG   #PV #LV #SN Attr   VSize  VFree 
  vg_a   2   0   0 wz--n- <1.82t <1.82t

Or we can obtain higher details with:

sudo vgdisplay vg_a
c@parrot 192.168.1.4 [~] $ sudo vgdisplay vg_a
  --- Volume group ---
  VG Name               vg_a
  System ID             
  Format                lvm2
  Metadata Areas        2
  Metadata Sequence No  1
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                0
  Open LV               0
  Max PV                0
  Cur PV                2
  Act PV                2
  VG Size               <1.82 TiB
  PE Size               4.00 MiB
  Total PE              476934
  Alloc PE / Size       0 / 0   
  Free  PE / Size       476934 / <1.82 TiB
  VG UUID               cNgHFC-5WCc-0AQh-eLfc-cTBI-jEYh-a5gyb9

Part G(c): Extending a Volume Group

  • Extending a volume group is pretty straightforward. In our case we went up and added another 1 TB disk to the group.
Linux Rocks Every Day