2

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?

2 Answers 2

4

Try adding this to /etc/fstab:

/dev/nvme0n1 /database xfs defaults 0 0

That should do the trick.

2
  • Can you explain why that's needed? I don't understand what the command does
    – kentor
    Sep 20, 2017 at 23:00
  • 2
    When you mount a device on the command line, it is only persistent for that session, the nature of it is not stored anywhere. By placing the entry in /etc/fstab, this file is read at boot time, and ensures your device(s) are mounted on system start-up. For this reason, be VERY careful when editing this file, don't touch any of the existing content.
    – Soruk
    Sep 20, 2017 at 23:05
0

Steps to mount a disk permanently.
Doing this will mount your disk during boot time.

  1. Attach your disk manually once.
  2. Goto /proc/mounts and /etc/mtab and look for your mount entry.
  3. Copy the entry that you want to be mounted on boot.
  4. Paste it at the end of /etc/fstab. /etc/fstab Contains entries that are mounted during boot.

You can even manually add your entry in /etc/fstab, but copying it from /proc/mounts or /etc/mtab makes sure that you not make any error or mistake in listing your mount point

more helpful links link 1 link 2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.