Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reduce Persistent Disk Size

I have a persistent disk of 100GB attached to a VM instance. But I don't need all that space, and thus don't want to be billed for it. It has some data as well. I took a snapshot of the disk, and tried to create another one.

While trying to create a new one, it wouldn't take a value less that 100GB and says, since the snapshot is also of 100GB, the new disk should have a minimum size of 100GB.

How can I make a smaller persistent disk from a snapshot? Or reduce the size of the existing one?

like image 502
Kumar Bibek Avatar asked Jul 31 '15 04:07

Kumar Bibek


Video Answer


2 Answers

This is not possible TMK. You'll need to create another disk and copy the data over, though you can expand a snapshot to a larger disk.

like image 105
pnovotnak Avatar answered Oct 05 '22 16:10

pnovotnak


I had to recently just do this. I originally created a disk 500GB, but quickly realized that was a mistake as the disk is only using 20GB.

The high-level process involves creating a new instance with the desired smaller disk size. Stopping all services that write to the larger disk (think MySQL/MongoDB, NGINX/Apache, etc). Then, using rsync copy over all files from the larger disk to the smaller disk excluding a subset of instance specific data.

like image 45
Justin Avatar answered Oct 05 '22 18:10

Justin