Mount volume permanently

List volumes

2
3
/dev/xvda1: LABEL="cloudimg-rootfs" UUID="ef263917-4ffc-4c36-880c-ae41d52b0d8e" TYPE="ext4"
4
/dev/xvdf: UUID="2c21a384-9e0e-4b44-b8d1-ceb452e8cc5c" TYPE="ext4"
5
6
[email protected]:/home/ubuntu# lsblk
7
8
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
9
xvda 202:0 0 32G 0 disk
10
└─xvda1 202:1 0 32G 0 part /
11
xvdf 202:80 0 32G 0 disk
Copied!

Permanently mount

Mount volume xvdf to /var/lib/mysql
1
[email protected]:/# mount /dev/xvdf /var/lib/mysql
Copied!
Recheck after mount
2
3
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
4
xvda 202:0 0 32G 0 disk
5
└─xvda1 202:1 0 32G 0 part /
6
xvdf 202:80 0 32G 0 disk /var/lib/mysql
Copied!
Mount volume permanently - even after rebooting
1
[email protected]:/# vim /etc/fstab
2
3
UUID="2c21a384-9e0e-4b44-b8d1-ceb452e8cc5c" /data ext4 defaults 0 0
4
5
[email protected]:/# mount -fav
6
/ : ignored
7
/var/lib/mysql : already mounted
Copied!
We must config fstab (permanent mount) based on UUID or LABEL like this
1
LABEL=cloudimg-rootfs / ext4 defaults,discard 0 0
2
UUID="c46cf311-d31b-41ce-bce5-5d8ad0a6b109" /var/lib/elasticsearch ext4 defaults,nofail 0 2
3
UUID="2c21a384-9e0e-4b44-b8d1-ceb452e8cc5c" /data ext4 defaults 0 0
Copied!
DON'T config based on device name like this fuck
1
LABEL=cloudimg-rootfs / ext4 defaults,discard 0 0
2
/dev/nvme1n1p1 /var/lib/elasticsearch ext4 defaults,nofail 0 2
3
/dev/xvdf /data ext4 defaults 0 0
Copied!

Mountfuck

Entire fucking dir in fuckin /var/lib/elasticsearch
EBS uses single-root I/O virtualization (SR-IOV) to provide volume attachments on Nitro-based instances using the NVMe specification.These devices rely on standard NVMe drivers on the operating system.These drivers typically discover attached devices by scanning the PCI bus during instance boot, and create device nodes based on the order in which the devices respond, not on how the devices are specified in the block device mapping.In Linux, NVMe device names follow the pattern /dev/nvme<x>n<y>, where <x> is the enumeration order, and, for EBS, <y> is 1.Occasionally, devices can respond to discovery in a different order in subsequent instance starts, which causes the device name to change.
So, if we use NVMe disk for some new types of AWS EC2, please note that the device name is nearly randomize after each reboot. It means if we have 2 NVMe disks on one EC2 vm, so we cannot know which device name delegate to which real disk.
1
/dev/nvme1n1p1
2
/dev/nvme0n1p1
Copied!

Reference

Last modified 2yr ago