How To Add A Virtual NVMe Disk On CentOS 8 With Virtual Box

First of all, why did I choose a Virtual NVMe Disk and not e.g. LsiLogic SAS or others. The main reason for that, is that a lot of adapters have been removed from Red Hat 8.

To get a full list of all removed adapters, take a look at the following Red Hat documentation.

https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html/considerations_in_adopting_rhel_8/hardware-enablement_considerations-in-adopting-rhel-8#removed-adapters_hardware-enablement

So I have choosen the NVMe Adapter because this one is coming out of the box with Red Hat 8 / CentOS 8.

Lets get started by adding a new PostgreSQL Virtual Disk (PGDisk01.vdi) with a fixed size 12GB.

Now add the disk to the NVMe Controller

After a reboot, you should see now the NVMe controller and the new NVMe Disk (nvme0n8).

1
2
[root@ocm199 ~]# lspci -nn | grep Non-Volatile
00:0e.0 Non-Volatile memory controller [0108]: InnoTek Systemberatung GmbH Device [80ee:4e56]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
[root@ocm199 ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 64G 0 disk
├─sda1 8:1 0 1G 0 part /boot
└─sda2 8:2 0 63G 0 part
├─cl-root 253:0 0 48G 0 lvm /
└─cl-swap 253:1 0 12G 0 lvm [SWAP]
sdb 8:16 0 128G 0 disk
└─sdb1 8:17 0 128G 0 part
└─oravg-oralv 253:2 0 112G 0 lvm /u01
sr0 11:0 1 1024M 0 rom
nvme0n1 259:0 0 8G 0 disk
nvme0n2 259:1 0 8G 0 disk
nvme0n3 259:2 0 8G 0 disk
nvme0n4 259:3 0 8G 0 disk
nvme0n5 259:4 0 8G 0 disk
nvme0n6 259:5 0 8G 0 disk
nvme0n7 259:6 0 8G 0 disk
nvme0n8 259:7 0 12G 0 disk

After the disk is visible, we can create the volume group, logical volume and the XFS filesystem.

1
2
[root@ocm199 ~]# pvcreate /dev/nvme0n8
Physical volume "/dev/nvme0n8" successfully created.
1
2
3
4
5
[root@ocm199 ~]# pvs
PV VG Fmt Attr PSize PFree
/dev/nvme0n8 pgvg lvm2 a-- <12.00g <12.00g
/dev/sda2 cl lvm2 a-- <63.00g <3.00g
/dev/sdb1 oravg lvm2 a-- <128.00g <16.00g
1
2
[root@ocm199 ~]# vgcreate pgvg /dev/nvme0n8
Volume group "pgvg" successfully created
1
2
3
4
5
[root@ocm199 ~]# vgs
VG #PV #LV #SN Attr VSize VFree
cl 1 2 0 wz--n- <63.00g <3.00g
oravg 1 1 0 wz--n- <128.00g <16.00g
pgvg 1 0 0 wz--n- <12.00g <12.00g
1
2
[root@ocm199 ~]# lvcreate --size 10G --name pglv pgvg
Logical volume "pglv" created.
1
2
3
4
5
6
[root@ocm199 ~]# lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
root cl -wi-ao---- 48.00g
swap cl -wi-ao---- 12.00g
oralv oravg -wi-ao---- 112.00g
pglv pgvg -wi-a----- 10.00g
1
2
3
4
5
6
7
8
9
10
11
[root@ocm199 ~]# mkfs.xfs /dev/pgvg/pglv
meta-data=/dev/pgvg/pglv isize=512 agcount=4, agsize=655360 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=1, sparse=1, rmapbt=0
= reflink=1
data = bsize=4096 blocks=2621440, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0, ftype=1
log =internal log bsize=4096 blocks=2560, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
1
2
[root@ocm199 /]# mkdir ptdb
[root@ocm199 /]#
1
2
[root@ocm199 ~]# cat /etc/fstab | tail -1
/dev/pgvg/pglv /ptdb xfs defaults 0 0

# After editing this file, run 'systemctl daemon-reload' to update systemd units generated from this file.

1
2
[root@ocm199 ~]# systemctl daemon-reload
[root@ocm199 ~]#
1
2
[root@ocm199 /]# mount -a
[root@ocm199 /]#
1
2
[root@ocm199 /]# df -h | grep ptdb
/dev/mapper/pgvg-pglv 10G 104M 9.9G 2% /ptdb

That’s it.

Cheers

William