Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to create snapshot smaller than its original size on AWS? No bootable device error or Grub Error 15

For example I have an image its snapshot sized 20 GiB (Total size of EBS Volumes: 20 GiB) and it has 15 GiB free space. I want to create new image having 10 GiB from the instance.

When I do: Image => Create Image and entered 10 GiB for the volume, I do face with following error message:

Volume size must be at least the size of the snapshot (20 GiB)

[Q] Is it possible to prevent this error and create an Image having smaller volume than the snapshot's EBS volume?

Thank you for your valuable time and help.


Please note that following two approaches that based on answers did not work, and the owner of the answer did not guide me further! I don't what anyone with same problem lose time with those approaches since copy paste operations takes a long time in between volumes. I would be grateful if someone guide me further.

Approach 1: (target volume is a single EBS volume)

I have followed following guide based on the @EFeit's answer, which links to: https://serverfault.com/a/718441

First I stopped the instance I want to resize. Than I have created smaller EBS volume as 5 GiB and attached it into my instance as /dev/xvdf. Start the instance and log onto the new instance via SSH; and did the followings:

sudo mkdir /source /target
sudo mkfs.ext4 /dev/xvdf
sudo mount -t ext4 /dev/xvdf /target
sudo e2label /dev/xvdf /
sudo mount -t ext4 /dev/xvda1 /source
sudo rsync -aHAXxSP /source/ /target
sudo umount /target
sudo umount /source

Back in AWS Console: Stop the instance, and detach all the volumes. Attach the new sized volume into the instance as: "/dev/sda1" Start the instance, and it should boot up.

Error message:

enter image description here

Approach 2: (target volume is obtained from newly created smaller instance)

I have followed following guide. I have also faced with Error 15 on the boot menu :(

enter image description here

like image 278
alper Avatar asked Sep 05 '17 14:09

alper


People also ask

Can we reduce disk size in AWS?

To modify an EBS volume using the AWS CLIUse the modify-volume command to modify one or more configuration settings for a volume. For example, if you have a volume of type gp2 with a size of 100 GiB, the following command changes its configuration to a volume of type io1 with 10,000 IOPS and a size of 200 GiB.

What is the minimum size of an EBS volume as per AWS?

gp2 is designed to offer single-digit millisecond latency, deliver a consistent baseline performance of 3 IOPS/GB (minimum 100 IOPS) to a maximum of 16,000 IOPS, and provide up to 250 MB/s of throughput per volume. gp2 volumes smaller than 1 TB can also burst up to 3,000 IOPS.

What is a snapshot size in AWS?

So the first full snapshot will take 1GB of snapshot storage space, and then every daily incremental will also take 1GB.


3 Answers

There's no simple way to do this, but I think this tutorial will give you the outcome you're looking for.

like image 86
EFeit Avatar answered Sep 23 '22 10:09

EFeit


You think the disk space is allocated contiguously? You may think only the first 5GB is used. But the allocation can be all over the disk. It is your responsibility to copy the data to a smaller disk, attach it to your instance and discard the old disk. There are many tutorials on how to do it.

like image 40
helloV Avatar answered Sep 25 '22 10:09

helloV


check this answer here, I has the same issue, and asked this question.

I haven't tried the solution mentioned as I don't need this volume anymore and I was only concerned about the snapshot size, but it has been brought to my attention that the snapshot is stored as data based not block based so it won't reserve the same capacity as if it was live.

like image 38
Mahmoud Khateeb Avatar answered Sep 26 '22 10:09

Mahmoud Khateeb