Storage Concepts
Table of Contents
BIOS vs UEFI#
Both BISO and UEFI constitute an interface between the Operating System and the firmware of the hardware platform. They are pieces of software that is embedded on some chip or controller on the hardware, i.e. the motherboard of a server. Both BIOS and UEFI look for instructions on the disks that help locate the respective bootloader. BIOS Looks for the MBR (Master Boot Record) in the first sector of the disk. UEFI looks for the .efi files that are located in the EFI Special Partition (ESP) under /boot/efi/EFI/. Once the bootloader is located, the interface (BIOS or UEFI) loads it in memory and give it control for the rest of the OS boot operations.
The EFI Special Partition (ESP) is mount at the /boot/efi/ mount point:
Wassim@linux:~$ ls -la /boot/efi/EFI
ls: cannot access '/boot/efi/EFI': Permission denied
Wassim@linux:~$
Wassim@linux:~$ sudo ls -la /boot/efi/EFI/
total 16
drwx------. 4 root root 4096 Mar 15 01:00 .
drwx------. 3 root root 4096 Jan 1 1970 ..
drwx------. 2 root root 4096 Jun 21 12:42 BOOT
drwx------. 2 root root 4096 Jun 21 12:42 rocky
Wassim@linux:~$
Under the /boot/efi/ mount point, I have a directory called rocky. It makes sense because Rocky Linux is the unique OS I have on this machine. In that directory, I found the .efi bootloader files:
Wassim@linux:~$ sudo ls -l /boot/efi/EFI/rocky
total 7988
-rwx------. 1 root root 104 May 23 02:00 BOOTX64.CSV
-rwx------. 1 root root 159 Oct 2 2025 grub.cfg
-rwx------. 1 root root 4200776 May 23 02:00 grubx64.efi
-rwx------. 1 root root 874808 May 23 02:00 mmx64.efi
-rwx------. 1 root root 1036024 May 23 02:00 shim.efi
-rwx------. 1 root root 1036024 May 23 02:00 shimx64.efi
-rwx------. 1 root root 1019168 May 23 02:00 shimx64-rocky.efi
Wassim@linux:~$
Although BIOS requires MBR and UEFI requires GPT, UEFI creates a section of the disk called ==protective MBR== in the LBA 0 for retrocompatibility with BIOS systems; The protective MBR is configured is a way, that when a BIOS system detects the protective MBR, it concludes that the rest of the disk space has already been allocated. LBA stands for Logical Bloc Address and is the memory addressing scheme used by UEFI.
BIOS and EUFI are properties of the hardware platform. A hardware platform can support either BIOS, UEFI or both.
Both BIOS and UEFI offer a central configuration interface that is typically accessible by pressing F2 during system boot. The configuration interface of UEFI typically looks modern whe compared with that of BIOS.
My hardware platform seem to support UEFI and the bootloader file (shimx64.efi) is under the /rocky/ directory, which is the only OS installed:
Wassim@linux:~$ sudo efibootmgr -v
[sudo] password for Wassim:
BootCurrent: 0001
Timeout: 1 seconds
BootOrder: 0001,0002
Boot0001* rocky HD(1,GPT,b8cee562-e729-421c-b068-eff40ef3edc2,0x800,0x12c000)/\EFI\rocky\shimx64.efi
dp: 04 01 2a 00 01 00 00 00 00 08 00 00 00 00 00 00 00 c0 12 00 00 00 00 00 62 e5 ce b8 29 e7 1c 42 b0 68 ef f4 0e f3 ed c2 02 02 / 04 04 32 00 5c 00 45 00 46 00 49 00 5c 00 72 00 6f 00 63 00 6b 00 79 00 5c 00 73 00 68 00 69 00 6d 00 78 00 36 00 34 00 2e 00 65 00 66 00 69 00 00 00 / 7f ff 04 00
Boot0002* UEFI OS HD(1,GPT,b8cee562-e729-421c-b068-eff40ef3edc2,0x800,0x12c000)/\EFI\BOOT\BOOTX64.EFI0000424f
dp: 04 01 2a 00 01 00 00 00 00 08 00 00 00 00 00 00 00 c0 12 00 00 00 00 00 62 e5 ce b8 29 e7 1c 42 b0 68 ef f4 0e f3 ed c2 02 02 / 04 04 30 00 5c 00 45 00 46 00 49 00 5c 00 42 00 4f 00 4f 00 54 00 5c 00 42 00 4f 00 4f 00 54 00 58 00 36 00 34 00 2e 00 45 00 46 00 49 00 00 00 / 7f ff 04 00
data: 00 00 42 4f
Wassim@linux:~$
Disks#
A disk is a raw storage device that needs these things to be operational: labeling, partitioning, filesystem formatting and a special section that contains a bootloader. A disk is said to be labeled when a partition table is written on it, typically MBR or GPT. A disk that holds an MBR label is called an MBR disk (aka a dos disk). A disk that holds a GPT label is called a GPT disk. Labeling a disk must inevitably occur before it is partitioned.
Disk partitions#
A partition is a logical portion of a hard disk. It defines a single logical drive.
Partition tables#
A partition table contains entries about partitions. Each partition table entry contains information like the start and end points of a partition on the hard disk, the type and state of the partition. There are two partition table types supported on most hardware platfomrs: MBR (for BIOS systems) and GPT (for UEFI systems).
Master Boot Record: MBR#
MBR is the firmware interface that is located on the first sector of the disk. It is also the partion table format used by BIOS systems. MBR is also called dos.
Partitions in BIOS systems#
When a system uses MBR disks, there are the concepts of primary, extended and logical partition. Both a primary and a logical partition hold data. The extended partition is merely a container of logical partitions. On a Linux MBR-based system, there can up to four primary partitions or three primary partitions and one extended partition that holds the logical partitions.
Storage in Linux#
Finding out the local storage devices, partitions and removable media:
user1@rhel10-vm2:~$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
sr0 11:0 1 9.5G 0 rom
vda 252:0 0 25G 0 disk
├─vda1 252:1 0 1M 0 part
├─vda2 252:2 0 1G 0 part /boot
└─vda3 252:3 0 24G 0 part
├─rhel-root 253:0 0 22G 0 lvm /
└─rhel-swap 253:1 0 2G 0 lvm [SWAP]
user1@rhel10-vm2:~$
vda stands for “virtual disk a”. The digit indicates the partition number.
using the fdisk command#
This section describes the use of fdisk to CRUD partitions on MBR disks. (CRUD stands for Create, Read, Update, Delete).
Listing disks and partitions with fdisk#
List all partitions:
user1@rhel10-vm2:~$ sudo fdisk -l
[sudo] password for user1:
Disk /dev/vda: 25 GiB, 26843545600 bytes, 52428800 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 15DBF6BF-18B3-4524-8FFB-394998182EBA
Device Start End Sectors Size Type
/dev/vda1 2048 4095 2048 1M BIOS boot
/dev/vda2 4096 2101247 2097152 1G Linux extended boot
/dev/vda3 2101248 52426751 50325504 24G Linux LVM
Disk /dev/mapper/rhel-root: 21.95 GiB, 23571988480 bytes, 46039040 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/mapper/rhel-swap: 2.04 GiB, 2193620992 bytes, 4284416 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
user1@rhel10-vm2:~$
#QA Why are /dev/mapper/rhel-root and /dev/mapper/rhel-swap are listed as disks and not partitions?
I manually added a disk to the RHEL VM:
user1@rhel10-vm2:~$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
sda 8:0 0 399.4M 0 disk
sdb 8:16 0 399.4M 0 disk
sdc 8:32 0 399.4M 0 disk
sdd 8:48 0 409.6M 0 disk
sr0 11:0 1 9.5G 0 rom
vda 252:0 0 25G 0 disk
├─vda1 252:1 0 1M 0 part
├─vda2 252:2 0 1G 0 part /boot
└─vda3 252:3 0 24G 0 part
├─rhel-root 253:0 0 22G 0 lvm /
└─rhel-swap 253:1 0 2G 0 lvm [SWAP]
user1@rhel10-vm2:~$
I list the physical disks and the partitions:
user1@rhel10-vm2:~$ sudo fdisk -l
[sudo] password for user1:
Disk /dev/vda: 25 GiB, 26843545600 bytes, 52428800 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 15DBF6BF-18B3-4524-8FFB-394998182EBA
Device Start End Sectors Size Type
/dev/vda1 2048 4095 2048 1M BIOS boot
/dev/vda2 4096 2101247 2097152 1G Linux extended boot
/dev/vda3 2101248 52426751 50325504 24G Linux LVM
Disk /dev/sdb: 399.36 MiB, 418759680 bytes, 817890 sectors
Disk model: QEMU HARDDISK
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/sdc: 399.36 MiB, 418759680 bytes, 817890 sectors
Disk model: QEMU HARDDISK
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/sda: 399.36 MiB, 418759680 bytes, 817890 sectors
Disk model: QEMU HARDDISK
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/sdd: 409.6 MiB, 429497344 bytes, 838862 sectors
Disk model: QEMU HARDDISK
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x113ba544
Disk /dev/mapper/rhel-root: 21.95 GiB, 23571988480 bytes, 46039040 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/mapper/rhel-swap: 2.04 GiB, 2193620992 bytes, 4284416 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
user1@rhel10-vm2:~$
user1@rhel10-vm2:~$
The sda disk represented by /dev/sda. Note that /dev/vda shows Disklabel type: gpt while the other disks show no mention of any disk label.
Creating partitions with fdisk#
I create a new partition on /dev/sda:
user1@rhel10-vm2:~$ sudo fdisk /dev/sda
Welcome to fdisk (util-linux 2.40.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Device does not contain a recognized partition table.
Created a new DOS (MBR) disklabel with disk identifier 0xef2f6a52.
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-817889, default 2048):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-817889, default 817889): 200
Value out of range.
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-817889, default 817889): +200
Created a new partition 1 of type 'Linux' and of size 100.5 KiB.
Command (m for help): n
Partition type
p primary (1 primary, 0 extended, 3 free)
e extended (container for logical partitions)
Select (default p):
From the output it seems that up to only four primary partitions can be created, which is a typical behavior of BIOS systems.
I pressed CTRL-C to exit the interactive menu, get back to the main fdisk menu and write the changes:
Select (default p):
Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
user1@rhel10-vm2:~$
Here is the new layout for the disks and partitions:
user1@rhel10-vm2:~$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
sda 8:0 0 399.4M 0 disk
└─sda1 8:1 0 100.5K 0 part
sdb 8:16 0 399.4M 0 disk
sdc 8:32 0 399.4M 0 disk
sdd 8:48 0 409.6M 0 disk
sr0 11:0 1 9.5G 0 rom
vda 252:0 0 25G 0 disk
├─vda1 252:1 0 1M 0 part
├─vda2 252:2 0 1G 0 part /boot
└─vda3 252:3 0 24G 0 part
├─rhel-root 253:0 0 22G 0 lvm /
└─rhel-swap 253:1 0 2G 0 lvm [SWAP]
user1@rhel10-vm2:~$
user1@rhel10-vm2:~$ sudo fdisk -l
[sudo] password for user1:
Disk /dev/vda: 25 GiB, 26843545600 bytes, 52428800 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 15DBF6BF-18B3-4524-8FFB-394998182EBA
Device Start End Sectors Size Type
/dev/vda1 2048 4095 2048 1M BIOS boot
/dev/vda2 4096 2101247 2097152 1G Linux extended boot
/dev/vda3 2101248 52426751 50325504 24G Linux LVM
<---- output omitted ---->
Disk /dev/sda: 399.36 MiB, 418759680 bytes, 817890 sectors
Disk model: QEMU HARDDISK
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xef2f6a52
Device Boot Start End Sectors Size Id Type
/dev/sda1 2048 2248 201 100.5K 83 Linux
<---- output omitted ---->
user1@rhel10-vm2:~$
I list the disk and partition information for a specific disk by printing the partition table entry with fdisk then the print option. Note that I must specify the device file as an argument, not the disk name:
user1@rhel10-vm2:~$ sudo fdisk sda
Welcome to fdisk (util-linux 2.40.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
fdisk: cannot open sda: No such file or directory
user1@rhel10-vm2:~$
user1@rhel10-vm2:~$ sudo fdisk /dev/sda
Welcome to fdisk (util-linux 2.40.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Command (m for help): print
Disk /dev/sda: 399.36 MiB, 418759680 bytes, 817890 sectors
Disk model: QEMU HARDDISK
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xef2f6a52
Device Boot Start End Sectors Size Id Type
/dev/sda1 2048 2248 201 100.5K 83 Linux
Command (m for help):
Also note that the output of fdisk -l /dev/sda is identical to that of fdisk /dev/sda then print.
user1@rhel10-vm2:~$ sudo fdisk -l /dev/sda
Disk /dev/sda: 399.36 MiB, 418759680 bytes, 817890 sectors
Disk model: QEMU HARDDISK
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xef2f6a52
Device Boot Start End Sectors Size Id Type
/dev/sda1 2048 2248 201 100.5K 83 Linux
user1@rhel10-vm2:~$
user1@rhel10-vm2:~$ sudo fdisk /dev/sda
Welcome to fdisk (util-linux 2.40.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Command (m for help): print
Disk /dev/sda: 399.36 MiB, 418759680 bytes, 817890 sectors
Disk model: QEMU HARDDISK
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xef2f6a52
Device Boot Start End Sectors Size Id Type
/dev/sda1 2048 2248 201 100.5K 83 Linux
Command (m for help):
Changing partition types with fdisk#
I change the type of the partition within the fdisk configuration menu:
user1@rhel10-vm2:~$ sudo fdisk /dev/sda
Welcome to fdisk (util-linux 2.40.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Command (m for help): print
Disk /dev/sda: 399.36 MiB, 418759680 bytes, 817890 sectors
Disk model: QEMU HARDDISK
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xef2f6a52
Device Boot Start End Sectors Size Id Type
/dev/sda1 2048 2248 201 100.5K 83 Linux
Command (m for help): type
Selected partition 1
Hex code or alias (type L to list all): L
00 Empty 27 Hidden NTFS Win 82 Linux swap / So c1 DRDOS/sec (FAT-
01 FAT12 39 Plan 9 83 Linux c4 DRDOS/sec (FAT-
02 XENIX root 3c PartitionMagic 84 OS/2 hidden or c6 DRDOS/sec (FAT-
03 XENIX usr 40 Venix 80286 85 Linux extended c7 Syrinx
04 FAT16 <32M 41 PPC PReP Boot 86 NTFS volume set da Non-FS data
05 Extended 42 SFS 87 NTFS volume set db CP/M / CTOS / .
06 FAT16 4d QNX4.x 88 Linux plaintext de Dell Utility
07 HPFS/NTFS/exFAT 4e QNX4.x 2nd part 8e Linux LVM df BootIt
08 AIX 4f QNX4.x 3rd part 93 Amoeba e1 DOS access
09 AIX bootable 50 OnTrack DM 94 Amoeba BBT e3 DOS R/O
0a OS/2 Boot Manag 51 OnTrack DM6 Aux 9f BSD/OS e4 SpeedStor
0b W95 FAT32 52 CP/M a0 IBM Thinkpad hi ea Linux extended
0c W95 FAT32 (LBA) 53 OnTrack DM6 Aux a5 FreeBSD eb BeOS fs
0e W95 FAT16 (LBA) 54 OnTrackDM6 a6 OpenBSD ee GPT
0f W95 Ext'd (LBA) 55 EZ-Drive a7 NeXTSTEP ef EFI (FAT-12/16/
10 OPUS 56 Golden Bow a8 Darwin UFS f0 Linux/PA-RISC b
11 Hidden FAT12 5c Priam Edisk a9 NetBSD f1 SpeedStor
12 Compaq diagnost 61 SpeedStor ab Darwin boot f4 SpeedStor
14 Hidden FAT16 <3 63 GNU HURD or Sys af HFS / HFS+ f2 DOS secondary
16 Hidden FAT16 64 Novell Netware b7 BSDI fs f8 EBBR protective
17 Hidden HPFS/NTF 65 Novell Netware b8 BSDI swap fb VMware VMFS
18 AST SmartSleep 70 DiskSecure Mult bb Boot Wizard hid fc VMware VMKCORE
1b Hidden W95 FAT3 75 PC/IX bc Acronis FAT32 L fd Linux raid auto
1c Hidden W95 FAT3 80 Old Minix be Solaris boot fe LANstep
1e Hidden W95 FAT1 81 Minix / old Lin bf Solaris ff BBT
24 NEC DOS
Aliases:
linux - 83
swap - 82
extended - 05
uefi - EF
raid - FD
lvm - 8E
linuxex - 85
Hex code or alias (type L to list all): 8e
Changed type of partition 'Linux' to 'Linux LVM'.
Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
user1@rhel10-vm2:~$ sudo fdisk -l /dev/sda
Disk /dev/sda: 399.36 MiB, 418759680 bytes, 817890 sectors
Disk model: QEMU HARDDISK
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xef2f6a52
Device Boot Start End Sectors Size Id Type
/dev/sda1 2048 2248 201 100.5K 8e Linux LVM
user1@rhel10-vm2:~$
Note that:
- the
typeandtoptions are equivalent, - the
landLoptions are equivalent.
user1@rhel10-vm2:~$ sudo fdisk /dev/sda
Welcome to fdisk (util-linux 2.40.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Command (m for help): t
Selected partition 1
Hex code or alias (type L to list all): l
00 Empty 27 Hidden NTFS Win 82 Linux swap / So c1 DRDOS/sec (FAT-
01 FAT12 39 Plan 9 83 Linux c4 DRDOS/sec (FAT-
02 XENIX root 3c PartitionMagic 84 OS/2 hidden or c6 DRDOS/sec (FAT-
03 XENIX usr 40 Venix 80286 85 Linux extended c7 Syrinx
04 FAT16 <32M 41 PPC PReP Boot 86 NTFS volume set da Non-FS data
05 Extended 42 SFS 87 NTFS volume set db CP/M / CTOS / .
06 FAT16 4d QNX4.x 88 Linux plaintext de Dell Utility
07 HPFS/NTFS/exFAT 4e QNX4.x 2nd part 8e Linux LVM df BootIt
08 AIX 4f QNX4.x 3rd part 93 Amoeba e1 DOS access
09 AIX bootable 50 OnTrack DM 94 Amoeba BBT e3 DOS R/O
0a OS/2 Boot Manag 51 OnTrack DM6 Aux 9f BSD/OS e4 SpeedStor
0b W95 FAT32 52 CP/M a0 IBM Thinkpad hi ea Linux extended
0c W95 FAT32 (LBA) 53 OnTrack DM6 Aux a5 FreeBSD eb BeOS fs
0e W95 FAT16 (LBA) 54 OnTrackDM6 a6 OpenBSD ee GPT
0f W95 Ext'd (LBA) 55 EZ-Drive a7 NeXTSTEP ef EFI (FAT-12/16/
10 OPUS 56 Golden Bow a8 Darwin UFS f0 Linux/PA-RISC b
11 Hidden FAT12 5c Priam Edisk a9 NetBSD f1 SpeedStor
12 Compaq diagnost 61 SpeedStor ab Darwin boot f4 SpeedStor
14 Hidden FAT16 <3 63 GNU HURD or Sys af HFS / HFS+ f2 DOS secondary
16 Hidden FAT16 64 Novell Netware b7 BSDI fs f8 EBBR protective
17 Hidden HPFS/NTF 65 Novell Netware b8 BSDI swap fb VMware VMFS
18 AST SmartSleep 70 DiskSecure Mult bb Boot Wizard hid fc VMware VMKCORE
1b Hidden W95 FAT3 75 PC/IX bc Acronis FAT32 L fd Linux raid auto
1c Hidden W95 FAT3 80 Old Minix be Solaris boot fe LANstep
1e Hidden W95 FAT1 81 Minix / old Lin bf Solaris ff BBT
24 NEC DOS
Aliases:
linux - 83
swap - 82
extended - 05
uefi - EF
raid - FD
lvm - 8E
linuxex - 85
Hex code or alias (type L to list all): L
00 Empty 27 Hidden NTFS Win 82 Linux swap / So c1 DRDOS/sec (FAT-
01 FAT12 39 Plan 9 83 Linux c4 DRDOS/sec (FAT-
02 XENIX root 3c PartitionMagic 84 OS/2 hidden or c6 DRDOS/sec (FAT-
03 XENIX usr 40 Venix 80286 85 Linux extended c7 Syrinx
04 FAT16 <32M 41 PPC PReP Boot 86 NTFS volume set da Non-FS data
05 Extended 42 SFS 87 NTFS volume set db CP/M / CTOS / .
06 FAT16 4d QNX4.x 88 Linux plaintext de Dell Utility
07 HPFS/NTFS/exFAT 4e QNX4.x 2nd part 8e Linux LVM df BootIt
08 AIX 4f QNX4.x 3rd part 93 Amoeba e1 DOS access
09 AIX bootable 50 OnTrack DM 94 Amoeba BBT e3 DOS R/O
0a OS/2 Boot Manag 51 OnTrack DM6 Aux 9f BSD/OS e4 SpeedStor
0b W95 FAT32 52 CP/M a0 IBM Thinkpad hi ea Linux extended
0c W95 FAT32 (LBA) 53 OnTrack DM6 Aux a5 FreeBSD eb BeOS fs
0e W95 FAT16 (LBA) 54 OnTrackDM6 a6 OpenBSD ee GPT
0f W95 Ext'd (LBA) 55 EZ-Drive a7 NeXTSTEP ef EFI (FAT-12/16/
10 OPUS 56 Golden Bow a8 Darwin UFS f0 Linux/PA-RISC b
11 Hidden FAT12 5c Priam Edisk a9 NetBSD f1 SpeedStor
12 Compaq diagnost 61 SpeedStor ab Darwin boot f4 SpeedStor
14 Hidden FAT16 <3 63 GNU HURD or Sys af HFS / HFS+ f2 DOS secondary
16 Hidden FAT16 64 Novell Netware b7 BSDI fs f8 EBBR protective
17 Hidden HPFS/NTF 65 Novell Netware b8 BSDI swap fb VMware VMFS
18 AST SmartSleep 70 DiskSecure Mult bb Boot Wizard hid fc VMware VMKCORE
1b Hidden W95 FAT3 75 PC/IX bc Acronis FAT32 L fd Linux raid auto
1c Hidden W95 FAT3 80 Old Minix be Solaris boot fe LANstep
1e Hidden W95 FAT1 81 Minix / old Lin bf Solaris ff BBT
24 NEC DOS
Aliases:
linux - 83
swap - 82
extended - 05
uefi - EF
raid - FD
lvm - 8E
linuxex - 85
Hex code or alias (type L to list all):
Deleting a partition using fdisk#
Command (m for help): d
Selected partition 1
Partition 1 has been deleted.
Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
user1@rhel10-vm2:~$ sudo fdisk -l /dev/sda
[sudo] password for user1:
Disk /dev/sda: 399.36 MiB, 418759680 bytes, 817890 sectors
Disk model: QEMU HARDDISK
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xef2f6a52
user1@rhel10-vm2:~$
using the parted command#
user1@rhel10-vm2:~$ parted /dev/sdb print
WARNING: You are not superuser. Watch out for permissions.
Error: Error opening /dev/sda: Permission denied
Retry/Cancel? C
user1@rhel10-vm2:~$
user1@rhel10-vm2:~$ sudo parted /dev/sdb print
Model: ATA QEMU HARDDISK (scsi)
Disk /dev/sdb: 419MB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:
Number Start End Size Type File system Flags
user1@rhel10-vm2:~$
When a disk has no label, it shows in the output of parted print command. The following output shows that /dev/sda has a label; The partition table is msdos or MBR. The /dev/sdb disk however has no label. This explains the error message in the first line after parted /dev/sdb print:
user1@rhel10-vm2:~$ sudo parted /dev/sda print
Model: ATA QEMU HARDDISK (scsi)
Disk /dev/sda: 429MB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:
Number Start End Size Type File system Flags
user1@rhel10-vm2:~$
user1@rhel10-vm2:~$ sudo parted /dev/sdb print
Error: /dev/sdb: unrecognised disk label
Model: ATA QEMU HARDDISK (scsi)
Disk /dev/sdb: 419MB
Sector size (logical/physical): 512B/512B
Partition Table: unknown
Disk Flags:
user1@rhel10-vm2:~$
As opposed to fdisk, which automatically creates a partition table when it does not detect one on a disk, parted requires manual intervention using the mklabel argument. Also, fdisk seem to support only the MBR (dos) partition type while parted supports both MBR and GPT.
fdisk saves changes in memory and requires a write confirmation before quitting the configuration menu, with w, while parted seem to apply changes immediately.
user1@rhel10-vm2:~$ sudo parted /dev/sda print
Model: ATA QEMU HARDDISK (scsi)
Disk /dev/sda: 429MB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:
Number Start End Size Type File system Flags
user1@rhel10-vm2:~$ sudo parted /dev/sdb mklabel msdos
Information: You may need to update /etc/fstab.
user1@rhel10-vm2:~$ sudo parted /dev/sdb print
Model: ATA QEMU HARDDISK (scsi)
Disk /dev/sdb: 419MB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:
Number Start End Size Type File system Flags
user1@rhel10-vm2:~$
user1@rhel10-vm2:~$ sudo fdisk -l /dev/sdb | grep label
Disklabel type: dos
user1@rhel10-vm2:~$
What if I changed my mind and wanted a GPT disk instead? It seems possible to rewrite the partition table with parted:
user1@rhel10-vm2:~$ sudo parted /dev/sdb mklabel gpt
Warning: The existing disk label on /dev/sdb will be destroyed and all data on this disk will be lost. Do you want to continue?
Yes/No? Y
Information: You may need to update /etc/fstab.
user1@rhel10-vm2:~$ sudo parted /dev/sdb print
Model: ATA QEMU HARDDISK (scsi)
Disk /dev/sdb: 419MB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
user1@rhel10-vm2:~$
Creating partitions with parted#
I created a partition on the sdb disk with a size of 100MB, starting at the first Megabyte of the disk:
[sudo] password for user1:
Information: You may need to update /etc/fstab.
user1@rhel10-vm2:~$
user1@rhel10-vm2:~$ lsblk /dev/sdb
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
sdb 8:16 0 399.4M 0 disk
└─sdb1 8:17 0 95M 0 part
user1@rhel10-vm2:~$
user1@rhel10-vm2:~$ sudo fdisk -l /dev/sdb
Disk /dev/sdb: 399.36 MiB, 418759680 bytes, 817890 sectors
Disk model: QEMU HARDDISK
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x087bebe6
Device Boot Start End Sectors Size Id Type
/dev/sdb1 2048 196607 194560 95M 83 Linux
user1@rhel10-vm2:~$
user1@rhel10-vm2:~$ sudo parted /dev/sdb print
Model: ATA QEMU HARDDISK (scsi)
Disk /dev/sdb: 419MB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:
Number Start End Size Type File system Flags
1 1049kB 101MB 99.6MB primary
user1@rhel10-vm2:~$
user1@rhel10-vm2:~$ cat /proc/partitions
major minor #blocks name
252 0 26214400 vda
252 1 1024 vda1
252 2 1048576 vda2
252 3 25162752 vda3
8 0 408945 sda
8 16 408945 sdb
8 17 97280 sdb1
8 32 419431 sdc
8 48 408945 sdd
11 0 9925440 sr0
253 0 23019520 dm-0
253 1 2142208 dm-1
user1@rhel10-vm2:~$
#QA Why is there a difference in sizes for the same partition with both commands?
What if I relabel the disk after I created a partition on it: This will erase the partition and all data on the disk:
user1@rhel10-vm2:~$ sudo parted /dev/sdb mklabel gpt
Warning: The existing disk label on /dev/sdb will be destroyed and all data on this disk will
be lost. Do you want to continue?
Yes/No?
Yes/No? Y
Information: You may need to update /etc/fstab.
user1@rhel10-vm2:~$
user1@rhel10-vm2:~$ sudo parted /dev/sdb print
Model: ATA QEMU HARDDISK (scsi)
Disk /dev/sdb: 419MB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
user1@rhel10-vm2:~$ lsblk | grep sdb
sdb 8:16 0 399.4M 0 disk
user1@rhel10-vm2:~$
user1@rhel10-vm2:~$ grep sdb /proc/partitions
8 16 408945 sdb
user1@rhel10-vm2:~$
Deleting partitions with parted#
user1@rhel10-vm2:~$ sudo parted /dev/sdb print
Model: ATA QEMU HARDDISK (scsi)
Disk /dev/sdb: 419MB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
1 1049kB 101MB 99.6MB primary
user1@rhel10-vm2:~$
user1@rhel10-vm2:~$ sudo parted /dev/sdb rm 1
Information: You may need to update /etc/fstab.
user1@rhel10-vm2:~$ sudo parted /dev/sdb print
Model: ATA QEMU HARDDISK (scsi)
Disk /dev/sdb: 419MB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
user1@rhel10-vm2:~$
LVM: Physical volumes (PV)#
user1@rhel10-vm2:~$ pvs
WARNING: Running as a non-root user. Functionality may be unavailable.
/run/lock/lvm/P_global:aux: open failed: Permission denied
user1@rhel10-vm2:~$ sudo pvs
[sudo] password for user1:
Sorry, try again.
r[sudo] password for user1:
PV VG Fmt Attr PSize PFree
/dev/vda3 rhel lvm2 a-- <24.00g 0
user1@rhel10-vm2:~$
LVM: Virtual groups (VG)#
user1@rhel10-vm2:~$ sudo vgs
VG #PV #LV #SN Attr VSize VFree
rhel 1 2 0 wz--n- <24.00g 0
user1@rhel10-vm2:~$
LVM: Physical extents (PE)#
user1@rhel10-vm2:~$ sudo vgdisplay
--- Volume group ---
VG Name rhel
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 3
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV 2
Max PV 0
Cur PV 1
Act PV 1
VG Size <24.00 GiB
PE Size 4.00 MiB
Total PE 6143
Alloc PE / Size 6143 / <24.00 GiB
Free PE / Size 0 / 0
VG UUID 2QotKh-8w0L-I3Ns-I15u-nP0O-RigF-REpN5O
user1@rhel10-vm2:~$
References#
- lernme.com/1-2/
- binarytides.com/bios-uefi-and-boot-process-explained
- thewindowsclub.com/difference-between-bios-and-uefi
- redhat.com/en/blog/partitions-fdisk
- docs.redhat.com/en/documentation/red_hat_enterprise_linux/6/html/installation_guide/sect-trouble-during-no-gpt
- docs.redhat.com/en/documentation/red_hat_enterprise_linux/10/html/managing_storage_devices/
- RHCSA Red Hat Enterprise Linux 10: Training and Exam Prep Guide, Asghar Ghori