Increase or replace an EBS disk
Make a snapshot / backup copy
Stop the service which uses this disk (e.g.
sudo service mysql stop
)Unmount the disk
sudo umount /dev/xvdb
Via AWS console, "detach Volume"
Either "Modify Volume" adding some more space, or "Create" a new one with required size
"Attach" volume back to the AMI via console
Edit
vi /etc/fstab
to allow mount / permanent mount, adding a line like
/dev/nvme1n1 /home/adjesty/mnt auto defaults,noatime,nofail 0 2
7a. For a new volume, create the file system then mount & change the ownership / permissions from 'root'
sudo mkfs.ext4 /dev/xvdg
If there is a need to change the default amount of inodes** (Crawlers case when we create zillions of very small files) then use "-i <bytes-per-node>" flag as per reference
sudo mkfs.ext4 -i 1800 /dev/xvdg
the above will allocate 1800 bytes per an inode, so a 1GB disk will get 596,523 inodes (assuming each file is less than 1,800 bytes)
sudo mount /dev/xvdg sudo chown -R mysql:mysql /db_tmp
7b. For the increased volume, mount & extend the file system
First, check that the device is in /etc/fstab, e.g.:
/dev/xvdg /db_data auto defaults,noatime,nofail 0 2
Next, mount it & then resize
sudo mount /dev/xvdg sudo resize2fs /dev/xvdg
check with df -h
that you have got the designed size:
Filesystem Size Used Avail Use% Mounted on udev 216M 0 216M 0% /dev tmpfs 46M 1.9M 44M 5% /run /dev/nvme0n1p1 9.7G 7.6G 2.1G 79% / tmpfs 230M 0 230M 0% /dev/shm tmpfs 5.0M 0 5.0M 0% /run/lock tmpfs 230M 0 230M 0% /sys/fs/cgroup /dev/loop2 33M 33M 0 100% /snap/amazon-ssm-agent/2996 /dev/loop3 56M 56M 0 100% /snap/core18/2066 /dev/loop1 34M 34M 0 100% /snap/amazon-ssm-agent/3552 /dev/loop5 99M 99M 0 100% /snap/core/11081 /dev/loop6 56M 56M 0 100% /snap/core18/2074 /dev/loop4 100M 100M 0 100% /snap/core/11316 tmpfs 46M 0 46M 0% /run/user/1001 /dev/nvme1n1 492G 14G 458G 3% /home/adjesty/mnt
AWS instructions are here
For machines that already come with disks:
adjesty@ip-172-31-15-45:~$ lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT loop0 7:0 0 89M 1 loop /snap/core/7713 loop1 7:1 0 18M 1 loop /snap/amazon-ssm-agent/1480 loop3 7:3 0 18M 1 loop /snap/amazon-ssm-agent/1455 loop4 7:4 0 89.1M 1 loop /snap/core/8039 nvme0n1 259:0 0 838.2G 0 disk /qt nvme1n1 259:1 0 10G 0 disk └─nvme1n1p1 259:2 0 10G 0 part /
sudo mkfs.ext4 /dev/nvme0n1 sudo mkdir /ext sudo mount /dev/nvme0n1 /ext