I wanted to shrink the GCP persistent disk size 100GB disk to 40 GB.
So I added a new 40 GB disk and made it ext4 format using sudo mkfs.ext4 /dev/sdb
and copied all the files from the main disk sda1 to sdb1 using sudo rsync -avxHAX --info=progress2 --exclude={"/lost+found"} / /mnt/newmountpoint
command since weresync doesn't work. But the new disk is still not booting up. Any idea what to do to make it work?
A bootable disk has more than just a file system. There are two formats (MBR, EFI), boot code, boot loaders, partition tables, mount tables, etc. There are also potential license issues for some operating systems.
The
rsync
command does not support that level of copy. There are commercial tools thatclone
disks, but I have not tested any in Google Cloud.The cost savings to reduce the size of a boot disk are not worth the effort or data corruption risk. I recommend creating a new system and copying your data from the old system to the new system. Do not copy system files, just the user data you added to the system. Install applications fresh on the new system - do not copy them from the old system.