Saturday, 18 January 2020

AWS EBS mount new volume to the EBS EC2 Instance at Linux level

login to the Linux system using post
then enter below command as sudo user
sudo su -

You can see the new 1gb volume : lsblk

check the file system format if its empty or we have files : files -s /dev/xvdf

format the filesystem using ext4 : mkfs -t ext4 /dev/xvdf
 
Create alias disk name to be mounted :
mkdir /newdisk
ls -ld /newdisk

Mount the new volume to /newdisk using below command
mount /dev/xvdf /newdisk
df -h


Now make permanent in fstab,So that even after reboot we will have to /newdisk with new volume details.
Backcup the /etc/fstab before doing change
cp /etc/fstab /etc/fstab.orig

either edit the file /etc/fstab or append like below
echo "/dev/xvdf       /newdisk   ext4    defaults,nofail        0       0" >> /etc/fstab
then check the file
cat /etc/fstab

Test the Disk:cd /newdisk; touch a; ls -ltr

No comments: