need moar ebs
AWS EBS volumes. Yes I know that everything in AWS should be immutable and disposable. But sometimes they aren’t. We don’t need to go into the philosophical rammifcations of that what we need is a fix. First we find the instance, then the volume, then we grow the volume in aws, then we grow the volume on the box
Lets go and describe the instance
$ aws ec2 describe-instances --filters Name=tag:Name,Values='MyMagicServer' | jq '.Reservations[].Instances' |jq 'map({
id: .InstanceId,
ip: (.PrivateIpAddress // "<terminated>"),
enis: [.NetworkInterfaces[].PrivateIpAddress],
devicename: [.BlockDeviceMappings[].DeviceName],
VolumeId: [.BlockDeviceMappings[].Ebs.VolumeId],
tags: (.Tags // [] | map({ key: .Key, value: .Value }) | from_entries)
})'
[
{
"id": "i-not-a-real-id",
"ip": "1.1.5.5.",
"enis": [
"1.1.5.5"
],
"devicename": [
"/dev/xvda"
],
"VolumeId": [
"vol-0notarealvolume"
],
"tags": {
"Name": "MyMagicServer"
}
}
]
great now we have the volumeId so lets see how big it is
$ aws ec2 describe-volumes \
--region us-east-1 \
--filters Name=attachment.instance-id,Values=i-0notarealvolume | jq '.Volumes'| jq 'map({
volumeId: .VolumeId,
size: .Size
})'
[
{
"volumeId": "vol-0notarealvolume",
"size": 100
}
]
Next we will make the volume bigger
$ aws ec2 --region us-east-1 modify-volume --size 1024 --volume-id vol-0enotarealvolume
{
"VolumeModification": {
"TargetIops": 3072,
"TargetSize": 1024,
"Progress": 0,
"ModificationState": "modifying",
"StartTime": "2019-08-20T18:42:21.000Z",
"TargetVolumeType": "gp2",
"OriginalVolumeType": "gp2",
"OriginalSize": 100,
"VolumeId": "vol-0enotarealvolume",
"OriginalIops": 300
}
}
Next we will need to go to the box and grow the volume
ssh in to the box verify the size
$ ssh ec2-user@1.1.5.5
$ sudo su
[root@ip-1-1-5-5 ec2-user]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/xvda1 99G 21G 78G 22% /
devtmpfs 15G 60K 15G 1% /dev
tmpfs 15G 0 15G 0% /dev/shm
issue the command growpart /dev/xvda 1
[root@ip-1-1-5-5 ec2-user]# growpart /dev/xvda 1
CHANGED: disk=/dev/xvda partition=1: start=4096 old: size=209711070,end=209715166 new: size=2147479518,end=2147483614
issue the command resize2fs /dev/xvda1
[root@ip-1-1-5-5 ec2-user]# resize2fs /dev/xvda1
resize2fs 1.42.12 (29-Aug-2014)
Filesystem at /dev/xvda1 is mounted on /; on-line resizing required
old_desc_blocks = 7, new_desc_blocks = 64
The filesystem on /dev/xvda1 is now 268434939 (4k) blocks long.
verify the size
[root@ip-1-1-5-5 ec2-user]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/xvda1 1008G 21G 987G 3% /
devtmpfs 15G 60K 15G 1% /dev
tmpfs 15G 0 15G 0% /dev/shm
profit