Google compute engine - shrinking disks

I have a 5TB HD and I want to shrink it to 2TB.

I use Google Compute Engine PaaS.

How can I do that?

Can you suggest any tools to perform this manually if this cannot be solved by Google's tools?


Solution 1:

If the disk is not a boot disk you can do the following:

  1. add a new disk with the required size and format it.
  2. mount the new disk
  3. cp -r --preserve=all /mnt/disk1/. /mnt/disk2/
  4. edit the /etc/fstab to mount the new disk instead the old one

If you have standard disk and you want to shorten the cp time. You can first create new ssd disk from snapshot and copy it to 2T ssd disk. Then make a snapshot from the 2T disk and create a new 2T standard disk.

If your disk is a boot disk, you can use a tool like fsarchiver:

  1. Create an archive from the boot disk. fsarchiver savefs /mnt/backup/boot_disk.fsa /dev/sda
  2. Restore the archive on the new disk fsarchiver restfs /mnt/backup/boot_disk.fsa id=0,dest=/dev/sdb