qubes.ResizeDisk 900 B

12345678910111213141516171819202122232425262728293031323334
  1. #!/bin/sh
  2. read -r 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. if [ "$(stat -Lc %t /dev/mapper/dmroot)" != "ca" ]; then
  14. new_size=$(cat /sys/block/xvda/size)
  15. ro=$(/sys/block/xvda/ro)
  16. if [ "$ro" -eq 1 ]; then
  17. new_table="0 $new_size snapshot /dev/xvda /dev/xvdc2 N 16"
  18. else
  19. new_table="0 $new_size linear /dev/xvda 0"
  20. fi
  21. dmsetup load dmroot --table "$new_table"
  22. dmsetup resume dmroot
  23. fi
  24. resize2fs /dev/mapper/dmroot
  25. ;;
  26. *)
  27. echo "Automatic resize of '$disk_name' not supported" >&2
  28. exit 1
  29. ;;
  30. esac