qubes.ResizeDisk 783 B

1234567891011121314151617181920212223242526272829303132
  1. #!/bin/sh
  2. read disk_name
  3. set -e
  4. case $disk_name in
  5. private)
  6. # force some read to refresh device size
  7. head /dev/xvdb > /dev/null
  8. resize2fs /dev/xvdb
  9. ;;
  10. root)
  11. # force some read to refresh device size
  12. head /dev/xvda > /dev/null
  13. new_size=$(cat /sys/block/xvda/size)
  14. ro=$(/sys/block/xvda/ro)
  15. if [ $ro -eq 1 ]; then
  16. new_table="0 $new_size snapshot /dev/xvda /dev/xvdc2 N 16"
  17. else
  18. new_table="0 $new_size linear /dev/xvda 0"
  19. fi
  20. dmsetup load dmroot --table "$new_table"
  21. dmsetup resume dmroot
  22. resize2fs /dev/mapper/dmroot
  23. ;;
  24. *)
  25. echo "Automatic resize of '$disk_name' not supported" >&2
  26. exit 1
  27. ;;
  28. esac