Skip to content

Lightsail attached disk has wrong (and varying) disk path

0

I have added an attached disk to a lightsail VPS. The lightsail interface shows "Disk path: /dev/xvdf" for this disk, both when I look at it under "Storage" as when I look at the server instance (under the storage tab).

In other servers where I have done the same in the past, the reported disk path has always been correct. This time it isn't: when I issue the command "lsblk" (as per the documentation at https://lightsail.aws.amazon.com/ls/docs/en_us/articles/create-and-attach-additional-block-storage-disks-linux-unix), there is no xvdf device. There is a different device (/dev/nvme1n1), by which I can access the attached disk. So I set up everything in /etc/fstab to use /dev/nvme1n1 instead of /dev/xvdf, and it works.

The problem arose when I rebooted today, and my new disk was no longer found, as after the reboot it had suddenly become /dev/nvme0n1 instead of /dev/nvme1n1. Rebooting again fixed this, and the disk received its old identifier again. Apparently, I cannot know in advance which identifier will be used for the disk after a reboot, hence I cannot be sure if the system will work correctly after I reboot it.

Does anyone know if there is a way to fix this and get a stable identifier (preferably the one reported by the lightsail interface, /dev/xvdf)?

asked 3 years ago527 views

3 Answers
0
Accepted Answer

The /dev/nvme0n1 (and so on) naming convention is dictated by the storage device driver, which can be different across different instance families https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/nvme-ebs-volumes.html

It's possible that previously you have worked with instances that are not Nitro instances, and so the /dev/xvdf convention would have been used on those.

You can hard-code the disk's UUID entry in to /etc/fstab, meaning that as long as the device is never replaced it will always be able to be referenced by the same name https://www.cyberciti.biz/faq/linux-finding-using-uuids-to-update-fstab/

EXPERT

answered 3 years ago

EXPERT

reviewed 2 years ago

0

This worked perfectly, thank you!

answered 3 years ago

0

For those that may find this, I wanted to be explicit-- in your fstab file, refer to the drive by its UUID. Don't use the "disk path" that Lightsail gives you.

Ex:

lsblk -f 

Look for the storage disk (ex: nvme1n1), but you want to copy its UUID. Ex: 9b39294-4932baf30-b34ba...etc.

Now, to make sure it always mounts correctly on boot, refer to it by its UUID, not it's "disk path" at /dev/whatever.

sudo nano /etc/fstab
 (add to the bottom:)
UUID=my_uuid_here /data ext4 defaults,nofail 0 2

This would mount the drive at /data. Replace that with whatever directory you want to mount it at.

answered 5 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.