The original MBR (Master Boot Record) partition table has space to define only 4 primary partitions per drive.
To allow more than four partitions on a single disk, extended partition can be created.
User can create multiple logical partitions (typically up to 15) in the extended partition.
Open VM and check existing storage setup.
lsblk
Example 1: sda2
sd : SCSI and SATA disk
a : 1st hard disk
2 : 2nd partition on 1st hard disk
Example 2: sdb1
sd : SCSI and SATA disk
b : 2nd hard disk
1 : 1st partition on 2nd hard disk
Shutdown the VM
Open Oracle VM VirtualBox Manager --> Settings.
From the left side menu, click Storage.
Under <Devices>, select your storage controller (typically named Controller: SATA or Controller: SCSI).
Click the Adds Hard Disk icon.
In new window <Hard Disk Selector>, select Create.
Input settings
Disk Size: [Any number, exp: 10GB]
Hard Disk File Type and Format: VDI (VirtualBox Disk Image)
Uncheck Pre-allocate Full Size
Click Finish
Double click the new hard disk to attach to VM.
Click OK.
Open VM and check new hard disk.
lsblk
Opens fdisk for the target disk
fdisk /dev/sd[Disk]
Example: fdisk /dev/sdb
Displays the current partition table
p
Displays help
m
Create new partition
n
Selects primary partition type.
p
Select partition number
Press Enter to select default partition number
Example: 1 or Enter
Select starting sector
Press Enter to select default starting sector
Example: 2048 or Enter
Select ending sector
Press Enter to select default starting sector if need
Example: +1G
Verify the 1GB partition was created.
p
Saves all changes to the physical disk and exits fdisk.
Changes made before existing only in RAM and can be undone.
w (Write)
Verify new partition
lsblk
Result
student@localhost:~$ sudo fdisk /dev/sdb
[sudo] password for student:
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 0x520e6b00.
Command (m for help): p
Disk /dev/sdb: 10 GiB, 10737418240 bytes, 20971520 sectors
Disk model: VBOX 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: 0x520e6b00
Command (m for help): m
Help:
DOS (MBR)
a toggle a bootable flag
b edit nested BSD disklabel
c toggle the dos compatibility flag
Generic
d delete a partition
F list free unpartitioned space
l list known partition types
n add a new partition
p print the partition table
t change a partition type
v verify the partition table
i print information about a partition
e resize a partition
Misc
m print this menu
u change display/entry units
x extra functionality (experts only)
Script
I load disk layout from sfdisk script file
O dump disk layout to sfdisk script file
Save & Exit
w write table to disk and exit
q quit without saving changes
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): 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):
First sector (2048-20971519, default 2048):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-20971519, default 20971519): +1G
Created a new partition 1 of type 'Linux' and of size 1 GiB.
Command (m for help): p
Disk /dev/sdb: 10 GiB, 10737418240 bytes, 20971520 sectors
Disk model: VBOX 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: 0x520e6b00
Device Boot Start End Sectors Size Id Type
/dev/sdb1 2048 2099199 2097152 1G 83 Linux
Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
student@localhost:~$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
sda 8:0 0 25G 0 disk
├─sda1 8:1 0 1M 0 part
├─sda2 8:2 0 1G 0 part /boot
└─sda3 8:3 0 24G 0 part
├─rhel-root 253:0 0 21.5G 0 lvm /
└─rhel-swap 253:1 0 2.5G 0 lvm [SWAP]
sdb 8:16 0 10G 0 disk
└─sdb1 8:17 0 1G 0 part
sr0 11:0 1 1024M 0 rom
Opens fdisk for the target disk
fdisk /dev/sd[Disk]
Example: fdisk /dev/sdb
Displays the current partition table
p
Create new partition - Extended Partition
n
Selects extended partition type.
e
Select partition number
Press Enter to select default partition number
Example: 2 or Enter
Select starting sector
Press Enter to select default starting sector
Select ending sector
Press Enter to select default starting sector to occupy all remaining disk space for the extended container.
Create new partition - Logical Partition 1
Since all space in primary partition is used, logical partition is created automatically.
n
Select starting sector
Press Enter to select default starting sector
Select ending sector
Press Enter to select default starting sector if needed
Example: +2G
Create 3rd new partition - Logical Partition 2
n
Select starting sector
Press Enter to select default starting sector
Select ending sector
Press Enter to select default starting sector if needed
Example: +1G
Verify the partitions was created.
1 extended + 2 logical partitions are created
p
Saves all changes to the physical disk and exits fdisk.
Changes made before existing only in RAM and can be undone.
w (Write)
Verify new partition
lsblk
Result
student@localhost:~$ sudo fdisk /dev/sdb
[sudo] password for student:
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): p
Disk /dev/sdb: 10 GiB, 10737418240 bytes, 20971520 sectors
Disk model: VBOX 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: 0x520e6b00
Device Boot Start End Sectors Size Id Type
/dev/sdb1 2048 2099199 2097152 1G 83 Linux
Command (m for help): n
Partition type
p primary (1 primary, 0 extended, 3 free)
e extended (container for logical partitions)
Select (default p): e
Partition number (2-4, default 2):
First sector (2099200-20971519, default 2099200):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2099200-20971519, default 20971519):
Created a new partition 2 of type 'Extended' and of size 9 GiB.
Command (m for help): n
All space for primary partitions is in use.
Adding logical partition 5
First sector (2101248-20971519, default 2101248):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2101248-20971519, default 20971519): +2G
Created a new partition 5 of type 'Linux' and of size 2 GiB.
Command (m for help): n
All space for primary partitions is in use.
Adding logical partition 6
First sector (6297600-20971519, default 6297600):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (6297600-20971519, default 20971519): +1G
Created a new partition 6 of type 'Linux' and of size 1 GiB.
Command (m for help): p
Disk /dev/sdb: 10 GiB, 10737418240 bytes, 20971520 sectors
Disk model: VBOX 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: 0x520e6b00
Device Boot Start End Sectors Size Id Type
/dev/sdb1 2048 2099199 2097152 1G 83 Linux
/dev/sdb2 2099200 20971519 18872320 9G 5 Extended
/dev/sdb5 2101248 6295551 4194304 2G 83 Linux
/dev/sdb6 6297600 8394751 2097152 1G 83 Linux
Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
student@localhost:~$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
sda 8:0 0 25G 0 disk
├─sda1 8:1 0 1M 0 part
├─sda2 8:2 0 1G 0 part /boot
└─sda3 8:3 0 24G 0 part
├─rhel-root 253:0 0 21.5G 0 lvm /
└─rhel-swap 253:1 0 2.5G 0 lvm [SWAP]
sdb 8:16 0 10G 0 disk
├─sdb1 8:17 0 1G 0 part
├─sdb2 8:18 0 1K 0 part
├─sdb5 8:21 0 2G 0 part
└─sdb6 8:22 0 1G 0 part
sr0 11:0 1 1024M 0 rom
student@localhost:~$
Opens fdisk for the target disk
fdisk /dev/sd[Disk]
Example: fdisk /dev/sdb
Displays the current partition table
p
Run Delete command
d
Select partition number to delete
Example: 6
Verify the partition is deleted in memory
p
Save the changed
w
Verify the partition is deleted permanently
lsblk
Result
student@localhost:~$ sudo fdisk /dev/sdb
[sudo] password for student:
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): p
Disk /dev/sdb: 10 GiB, 10737418240 bytes, 20971520 sectors
Disk model: VBOX 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: 0x520e6b00
Device Boot Start End Sectors Size Id Type
/dev/sdb1 2048 2099199 2097152 1G 83 Linux
/dev/sdb2 2099200 20971519 18872320 9G 5 Extended
/dev/sdb5 2101248 6295551 4194304 2G 83 Linux
/dev/sdb6 6297600 8394751 2097152 1G 83 Linux
Command (m for help): d
Partition number (1,2,5,6, default 6): 6
Partition 6 has been deleted.
Command (m for help): p
Disk /dev/sdb: 10 GiB, 10737418240 bytes, 20971520 sectors
Disk model: VBOX 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: 0x520e6b00
Device Boot Start End Sectors Size Id Type
/dev/sdb1 2048 2099199 2097152 1G 83 Linux
/dev/sdb2 2099200 20971519 18872320 9G 5 Extended
/dev/sdb5 2101248 6295551 4194304 2G 83 Linux
Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
student@localhost:~$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
sda 8:0 0 25G 0 disk
├─sda1 8:1 0 1M 0 part
├─sda2 8:2 0 1G 0 part /boot
└─sda3 8:3 0 24G 0 part
├─rhel-root 253:0 0 21.5G 0 lvm /
└─rhel-swap 253:1 0 2.5G 0 lvm [SWAP]
sdb 8:16 0 10G 0 disk
├─sdb1 8:17 0 1G 0 part
├─sdb2 8:18 0 1K 0 part
└─sdb5 8:21 0 2G 0 part
sr0 11:0 1 1024M 0 rom
Shutdown the VM
Open Oracle VM VirtualBox Manager --> File --> Tools --> Media.
Under <Hard disks> tab, right click the new hard disk --> Release --> Release.
Right click the new hard disk --> Remove --> Remove --> Delete.
Open VM and check new hard disk already delete.
lsblk