Centos – Mounted disk disappears after reboot

centoscentos7mountnvme

I've got a Centos 7 dedicated server with a SSD + a nvme ssd with 400gb. I followed a tutorial to mount + format (as xfs filesystem) the nvme disk so that I could setup my NoSQL databases on that drive. However every time I reboot my server the disk disappears and the mounted folder is empty again.

What commands I ran to mount the disk:

fdisk -l

Returned:

Disk /dev/nvme0n1: 400.1 GB, 400088457216 bytes, 781422768 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/sda: 275.1 GB, 275064201216 bytes, 537234768 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 label type: dos Disk identifier: 0x000b09ac

Device Boot Start End Blocks Id System
/dev/sda1 * 2048 2050047 1024000 83 Linux
/dev/sda2 2050048 528844799 263397376 83 Linux
/dev/sda3 528844800 537233407 4194304 82 Linux swap /
Solaris

mkfs.xfs /dev/nvme0n1 -f (-f was required after the first time)
mkdir /database
mount /dev/nvme0n1 /database

Afterwards it lists the drive when I run df -h, but once I restart it also disappears from that list. What am I doing wrong?

Best Answer

Try adding this to /etc/fstab:

/dev/nvme0n1 /database xfs defaults 0 0

That should do the trick.