The One Liner
?? Mount the partition (if disk is partitioned):
sudo mount /dev/xvdf1 /vol -t ext4
Mount the disk (if not partitioned):
sudo mount /dev/xvdf /vol -t ext4
where:
/dev/xvdf
is changed to the EBS Volume device being mounted
/vol
is changed to the folder you want to mount to.
ext4
is the filesystem type of the volume being mounted
Common Mistakes How To:
?? Attached Devices List
Check your mount command for the correct EBS Volume device name and filesystem type. The following will list them all:
sudo lsblk --output NAME,TYPE,SIZE,FSTYPE,MOUNTPOINT,UUID,LABEL
If your EBS Volume displays with an attached partition
, mount the partition
; not the disk.
?? If your volume isn't listed
If it doesn't show, you didn't Attach
your EBS Volume in AWS web-console
?? Auto Remounting on Reboot
These devices become unmounted again if the EC2 Instance ever reboots.
A way to make them mount again upon startup is to add the volume to the server's /etc/fstab
file.
?? Caution:??
If you corrupt the /etc/fstab
file, it will make your system unbootable. Read AWS's short article so you know to check that you did it correctly.
https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ebs-using-volumes.html#ebs-mount-after-reboot
First:
With the lsblk
command above, find your volume's UUID
& FSTYPE
.
Second:
Keep a copy of your original fstab
file.
sudo cp /etc/fstab /etc/fstab.original
Third:
Add a line for the volume in sudo nano /etc/fstab
.
The fields of fstab
are 'tab-separated' and each line has the following fields:
<UUID> <MOUNTPOINT> <FSTYPE> defaults,discard,nofail 0 0
Here's an example to help you, my own fstab
reads as follows:
LABEL=cloudimg-rootfs / ext4 defaults,discard,nofail 0 0
UUID=e4a4b1df-cf4a-469b-af45-89beceea5df7 /var/www-data ext4 defaults,discard,nofail 0 0
That's it, you're done. Check for errors in your work by running:
sudo mount --all --verbose
You will see something like this if things are ??:
/ : ignored
/var/www-data : already mounted