# [[AWS]] Volumes
## General
### See used space
```bash
$ df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 7.6G 0 7.6G 0% /dev
tmpfs 7.6G 0 7.6G 0% /dev/shm
tmpfs 7.6G 524K 7.6G 1% /run
tmpfs 7.6G 0 7.6G 0% /sys/fs/cgroup
/dev/nvme0n1p1 64G 11G 54G 16% /
tmpfs 1.6G 0 1.6G 0% /run/user/1000
```
## Expanding volume size
https://aws.amazon.com/premiumsupport/knowledge-center/expand-ebs-root-volume-windows/#:~:text=You%20can%20expand%20the%20root,use%20the%20new%20storage%20capacity.
- Go to Instance
- Select volume from Storage tab
- Actions > Modify
- Change the size in GB
### Extending the Linux filesystem
https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/recognize-expanded-volume-linux.html?icmpid=docs_ec2_console
"For this example, suppose that you have an instance built on the Nitro System, such as an M5 instance. You resized the boot volume from 8 GB to 16 GB and an additional volume from 8 GB to 30 GB. Use the following procedure to extend the file system of the resized volumes."
[[Eutykhia]]
- Tryna increase from 8G to 64G
#### "Verify filesystem with `df -hT`"
```bash
~/tyche » df -hT
Filesystem Type Size Used Avail Use% Mounted on
devtmpfs devtmpfs 482M 0 482M 0% /dev
tmpfs tmpfs 492M 0 492M 0% /dev/shm
tmpfs tmpfs 492M 20M 473M 4% /run
tmpfs tmpfs 492M 0 492M 0% /sys/fs/cgroup
/dev/xvda1 xfs 8.0G 7.0G 1.1G 88% /
tmpfs tmpfs 99M 0 99M 0% /run/user/1000
```
#### `lsblk`
To check whether the volume has a partition that must be extended, use the `lsblk` command to display information about the NVMe block devices attached to your instance:
```bash
[ec2-user ~]$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
nvme1n1 259:0 0 30G 0 disk /data
nvme0n1 259:1 0 16G 0 disk
└─nvme0n1p1 259:2 0 8G 0 part /
└─nvme0n1p128 259:3 0 1M 0 part
```
- The root volume, `/dev/nvme0n1`, has a partition, `/dev/nvme0n1p1`. While the size of the root volume reflects the new size, 16 GB, the size of the partition reflects the original size, 8 GB, and must be extended before you can extend the file system.
- The volume `/dev/nvme1n1` has no partitions. The size of the volume reflects the new size, 30 GB.
[[Eutykhia]]:
```bash
~/tyche(master) » lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
xvda 202:0 0 64G 0 disk
└─xvda1 202:1 0 8G 0 part /
```
#### `growpart`
For volumes that have a partition, such as the root volume shown in the previous step, use the **growpart** command to extend the partition. Notice that there is a space between the device name and the partition number.
Example:
```bash
[ec2-user ~]$ sudo growpart /dev/nvme0n1 1
```
[[Eutykhia]]:
```bash
~/tyche(master) » sudo growpart /dev/xvda 1
CHANGED: partition=1 start=4096 old: size=16773087 end=16777183 new: size=134213599 end=134217695
# Verify with lsblk again
~/tyche(master) » lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
xvda 202:0 0 64G 0 disk
└─xvda1 202:1 0 64G 0 part /
```
**NOTE:**
- The MAJ:MIN column was ignored (or did we base it off the `:MIN` value?)
- I'm assuming `0` corresponds with the volume, `1` corresponds to the first partition (what we want to increase), `2` corresponds with the second partition, etc. At least I know that running `sudo growpart /dev/xvda 1` worked.
#### Verify size of file system is still old size with `df -h`
[[Eutykhia]]:
```bash
~/tyche(master) » df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 482M 0 482M 0% /dev
tmpfs 492M 0 492M 0% /dev/shm
tmpfs 492M 20M 473M 4% /run
tmpfs 492M 0 492M 0% /sys/fs/cgroup
/dev/xvda1 8.0G 7.0G 1.1G 88% /
tmpfs 99M 0 99M 0% /run/user/1000
```
- Still 8G
#### Extend size for `xfs` filesystem using `resize2fs`
"[XFS file system] To extend the file system on each volume, use the `xfs_growfs` command. In this example, `/` and `/data` are the volume mount points shown in the output for `df -hT`."
- There are different instructions for the `xfs` vs `ext4` filesystems
- See which one the volume is using `df -hT`
- The `-T` shows the `t`ype of the volume
- It appears that [[Eutykhia]] uses `xfs`:
```bash
~/tyche(master) » sudo xfs_growfs -d /
meta-data=/dev/xvda1 isize=512 agcount=4, agsize=524159 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=1 spinodes=0
data = bsize=4096 blocks=2096635, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal bsize=4096 blocks=2560, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
data blocks changed from 2096635 to 16776699
```
"If the XFS tools are not already installed, you can install them as follows."
```bash
[ec2-user ~]$ sudo yum install xfsprogs
```
#### Verify size of file system is finally new size with `df -h`
```bash
~/tyche(master) » df -hT
Filesystem Type Size Used Avail Use% Mounted on
devtmpfs devtmpfs 482M 0 482M 0% /dev
tmpfs tmpfs 492M 0 492M 0% /dev/shm
tmpfs tmpfs 492M 20M 473M 4% /run
tmpfs tmpfs 492M 0 492M 0% /sys/fs/cgroup
/dev/xvda1 xfs 64G 7.1G 57G 11% /
tmpfs tmpfs 99M 0 99M 0% /run/user/1000
```
- 64G size, 57G available, finally 🎉