4
Oct

Although my migration attempt cross different regions failed,
I successfully shrink the os volume from 8G to 4G. Here is how:

  1. snapshot the running os volume
  2. create a new volume use the snapshot, and attach to /dev/big
  3. create an empty volume with smaller size, and attach to /dev/small
  4. operate on the big volume
    e2fsck -f /dev/big
    
    resize2fs -M -p /dev/big
    # the command above shrink the volume
  5. mirror the content from the big to the small volume
    dd if=/dev/big ibs=16M of=/dev/small obs=16M count=128
    # count needs to be adjusted; mine was 415315 4k block, which was about 101 16M block
    
    resize2fs -p /dev/small
    # the command above expand the volume to full space
    
    e2fsck -f /dev/small
  6. stop the running instance, replace the os volume with the small and all set

Leave a Reply