Add qubes.ResizeDisk service to adjust filesystem size

Do this using qubes rpc service, instead of calling resize2fs directly
by dom0.
This commit is contained in:
Marek Marczykowski-Górecki 2016-08-17 21:47:22 +02:00
parent 779414d216
commit b50cba3f2c
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724
3 changed files with 34 additions and 0 deletions

View File

@ -237,6 +237,7 @@ install-common:
install -m 0644 qubes-rpc/qubes.GetImageRGBA $(DESTDIR)/etc/qubes-rpc
install -m 0644 qubes-rpc/qubes.SetDateTime $(DESTDIR)/etc/qubes-rpc
install -m 0755 qubes-rpc/qubes.InstallUpdatesGUI $(DESTDIR)/etc/qubes-rpc
install -m 0755 qubes-rpc/qubes.ResizeDisk $(DESTDIR)/etc/qubes-rpc
install -d $(DESTDIR)/etc/qubes/suspend-pre.d
install -m 0644 qubes-rpc/suspend-pre.README $(DESTDIR)/etc/qubes/suspend-pre.d/README

32
qubes-rpc/qubes.ResizeDisk Executable file
View File

@ -0,0 +1,32 @@
#!/bin/sh
read disk_name
set -e
case $disk_name in
private)
# force some read to refresh device size
head /dev/xvdb > /dev/null
resize2fs /dev/xvdb
;;
root)
# force some read to refresh device size
head /dev/xvda > /dev/null
new_size=$(cat /sys/block/xvda/size)
ro=$(/sys/block/xvda/ro)
if [ $ro -eq 1 ]; then
new_table="0 $new_size snapshot /dev/xvda /dev/xvdc2 N 16"
else
new_table="0 $new_size linear /dev/xvda 0"
fi
dmsetup load dmroot --table "$new_table"
dmsetup resume dmroot
resize2fs /dev/mapper/dmroot
;;
*)
echo "Automatic resize of '$disk_name' not supported" >&2
exit 1
;;
esac

View File

@ -350,6 +350,7 @@ rm -f %{name}-%{version}
%config(noreplace) /etc/qubes-rpc/qubes.GetImageRGBA
%config(noreplace) /etc/qubes-rpc/qubes.SetDateTime
%config(noreplace) /etc/qubes-rpc/qubes.InstallUpdatesGUI
%config(noreplace) /etc/qubes-rpc/qubes.ResizeDisk
%dir /etc/qubes/autostart
/etc/qubes/autostart/README.txt
%config /etc/qubes/autostart/*.desktop.d/30_qubes.conf