Reduce Persistent Disk Size

2019-04-04 14:04发布

问题:

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?

回答1:

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.



回答2:

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.