Monday 18 March 2019

Automatically Mount an Attached Volume After Reboot by Raj Gupta

The mount point is not automatically preserved after rebooting your instance.To mount an attached EBS volume on every system reboot, add an entry for the device to the /etc/fstab file.


(Optional) Create a backup of your /etc/fstab file that you can use if you accidentally destroy or delete this file while editing it.


[root@ip-172-31-88-83 ~]# sudo cp /etc/fstab /etc/fstab.orig


Use the blkid command to find the UUID(universally unique identifier) of the device.

[root@ip-172-31-88-83 ~]# sudo blkid

/dev/xvda1: LABEL="/" UUID="8a9e0fcb-f415-4a3f-931d-919fadf8e22c" TYPE="xfs" PARTLABEL="Linux" PARTUUID="0460b53b-6702-4a24-bcc4-0c63e5436ad1"
/dev/xvdf: UUID="9ac2a386-7e38-414a-af92-1bbd46e5a8ff" TYPE="xfs"


Open the /etc/fstab file

[root@ip-172-31-88-83 ~]# sudo vi /etc/fstab

Add the following entry to /etc/fstab to mount the device at the specified mount point

UUID=9ac2a386-7e38-414a-af92-1bbd46e5a8ff  /data  xfs  defaults,nofail  0  2

To verify that your entry works, run the following commands to unmount the device and then mount all file systems in /etc/fstab. If there are no errors, the /etc/fstab file is OK and your file system will mount automatically after it is rebooted.

[root@ip-172-31-88-83 ~]# sudo umount /data
[root@ip-172-31-88-83 ~]# sudo mount -a


No comments:

Post a Comment