How can I specify the mount-point of my volume when I attach it to my Linode?

Linode Staff

How can I specify the mount-point of my Block Storage filesystem when I attach a volume to my Linode?

4 Replies

You can do this by using the mount command to target the filesystem and the path of where you would like it mounted to.

For example, if I wanted to mount the volume "test" to /var/www/html/, I could run the command below:

mount /dev/disk/by-id/scsi-0Linode_Volume_test /var/www/html

If you want the volume to automatically mount on a boot, you can add the following line to your Linode's /etc/fstab entry:

/dev/disk/by-id/scsi-0Linode_Volume_test /var/www/html ext4 defaults,noatime,nofail 0 2

The nofail flag will allow you to reboot normally without having to remove or comment-out the /etc/fstab entry if the volume is not attached.

If i have attactched the disk at at a specified location such as "/var/www/html". When I store a file at that location, how do i know and how do i determine which disk will get used, the original linode disk or the attatched volume?

If the volume is mounted to that directory, then everything saved there will be saved to the volume. I just tested these myself. At first I expected to see something of a symbolic link with the output of ls -la /var/www/html, but that didn't work. There are a couple ways you can verify this:

  • The first is less obtrusive to the files:

    • Run mountpoint /path/to/directory
      • You should see something like /var/www/html/ is a mountpoint for confirmation.
    • Run df -P /path/to/direcoty | tail -1 | cut -d' ' -f 1
      • This will list the device it's on, hopefully similar to /dev/sdd. If you're seeing sda, then that's most likely stored locally on the Linode, not the volume.
  • This way is more obtrusive, as it may interfere with your website if it is stored on the volume:

    • Run umount /var/www/html
      • Check the files with ls -la /var/www/html. Anything still listed is being saved on the local SSD disk.
    • To remount the volume: mount /dev/disk/by-id/scsi-0Linode_Volume_test /var/www/html
      • this is using the same volume name as in the example above, so make sure you're using the correct path for your volume.
      • Once the volume is mounted again, look for files that were not present when you just recently ran ls -la /var/www/html. Those are the files that are being saved on the volume.

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct