Add support for new root volume partition layout to qubes.ResizeDisk
If root filesystem is the last partition (new layout), resize it in-place. Use 'parted' tool because it can resize just one partition, without need to specify the whole new partition table. Since the partition is mounted, parted is unhappy to modify it. Force it by answering to its interactive prompts, and add (apparently not documented) ---pretend-input-tty to use those answers even though stdin is not a tty. Split the operation into multiple parted calls, for more reliable interactive prompts handling. Qubes 3.x disk layout (no partition table) is also supported, but the one that was used in Qubes 4.0 rc1 (root filesystem as the first partition) is not. Fixes QubesOS/qubes-issues#3173 QubesOS/qubes-issues#3143
This commit is contained in:
parent
d84886d477
commit
d8a2b8c375
1
Makefile
1
Makefile
@ -201,6 +201,7 @@ install-common: install-doc
|
|||||||
$(DESTDIR)/usr/share/glib-2.0/schemas/
|
$(DESTDIR)/usr/share/glib-2.0/schemas/
|
||||||
install -g user -m 2775 -d $(DESTDIR)/var/lib/qubes/dom0-updates
|
install -g user -m 2775 -d $(DESTDIR)/var/lib/qubes/dom0-updates
|
||||||
install -D -m 0644 misc/qubes-master-key.asc $(DESTDIR)/usr/share/qubes/qubes-master-key.asc
|
install -D -m 0644 misc/qubes-master-key.asc $(DESTDIR)/usr/share/qubes/qubes-master-key.asc
|
||||||
|
install misc/resize-rootfs $(DESTDIR)$(LIBDIR)/qubes/
|
||||||
|
|
||||||
install misc/close-window $(DESTDIR)$(LIBDIR)/qubes/close-window
|
install misc/close-window $(DESTDIR)$(LIBDIR)/qubes/close-window
|
||||||
|
|
||||||
|
1
debian/qubes-core-agent.install
vendored
1
debian/qubes-core-agent.install
vendored
@ -123,6 +123,7 @@ usr/lib/qubes/qvm-copy-to-vm.gnome
|
|||||||
usr/lib/qubes/qvm-copy-to-vm.kde
|
usr/lib/qubes/qvm-copy-to-vm.kde
|
||||||
usr/lib/qubes/qvm-move-to-vm.gnome
|
usr/lib/qubes/qvm-move-to-vm.gnome
|
||||||
usr/lib/qubes/qvm-move-to-vm.kde
|
usr/lib/qubes/qvm-move-to-vm.kde
|
||||||
|
usr/lib/qubes/resize-rootfs
|
||||||
usr/lib/qubes/tar2qfile
|
usr/lib/qubes/tar2qfile
|
||||||
usr/lib/qubes/update-proxy-configs
|
usr/lib/qubes/update-proxy-configs
|
||||||
usr/lib/qubes/upgrades-installed-check
|
usr/lib/qubes/upgrades-installed-check
|
||||||
|
42
misc/resize-rootfs
Executable file
42
misc/resize-rootfs
Executable file
@ -0,0 +1,42 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
dm_major=$(printf %x "$(grep device-mapper /proc/devices | cut -f 1 -d ' ')")
|
||||||
|
case "$(stat -Lc %t:%T /dev/mapper/dmroot)" in
|
||||||
|
ca:0)
|
||||||
|
# nothing needed, xvda used directly
|
||||||
|
;;
|
||||||
|
ca:3)
|
||||||
|
# resize partition table itself
|
||||||
|
# use undocumented ---pretend-input-tty (yes, three '-') to
|
||||||
|
# force unattended operation, otherwise it aborts on first
|
||||||
|
# prompt, even with '-s' option
|
||||||
|
echo fix | parted ---pretend-input-tty /dev/xvda print >/dev/null
|
||||||
|
# then resize 3rd partition, even though it is mounted
|
||||||
|
echo yes 100% | parted ---pretend-input-tty /dev/xvda resizepart 3
|
||||||
|
# and reload partition table; prefer partprobe over blockdev
|
||||||
|
# --rereadpt, as it works on mounted partitions
|
||||||
|
partprobe /dev/xvda
|
||||||
|
;;
|
||||||
|
ca:*)
|
||||||
|
echo "Unsupported partition layout, resize it manually" >&2
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
$dm_major:*)
|
||||||
|
new_size=$(cat /sys/block/xvda/size)
|
||||||
|
ro=$(cat /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
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Unsupported device type for root volume, resize it manually" >&2
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
resize2fs /dev/mapper/dmroot
|
@ -13,22 +13,10 @@ case $disk_name in
|
|||||||
root)
|
root)
|
||||||
# force some read to refresh device size
|
# force some read to refresh device size
|
||||||
head /dev/xvda > /dev/null
|
head /dev/xvda > /dev/null
|
||||||
if [ "$(stat -Lc %t /dev/mapper/dmroot)" != "ca" ]; then
|
/usr/lib/qubes/resize-rootfs
|
||||||
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
|
|
||||||
fi
|
|
||||||
resize2fs /dev/mapper/dmroot
|
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "Automatic resize of '$disk_name' not supported" >&2
|
echo "Automatic resize of '$disk_name' not supported" >&2
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
@ -604,6 +604,7 @@ rm -f %{name}-%{version}
|
|||||||
/usr/lib/qubes/upgrades-installed-check
|
/usr/lib/qubes/upgrades-installed-check
|
||||||
/usr/lib/qubes/upgrades-status-notify
|
/usr/lib/qubes/upgrades-status-notify
|
||||||
/usr/lib/qubes/qubes-sync-clock
|
/usr/lib/qubes/qubes-sync-clock
|
||||||
|
/usr/lib/qubes/resize-rootfs
|
||||||
/usr/lib/yum-plugins/yum-qubes-hooks.py*
|
/usr/lib/yum-plugins/yum-qubes-hooks.py*
|
||||||
/usr/lib/dracut/dracut.conf.d/30-qubes.conf
|
/usr/lib/dracut/dracut.conf.d/30-qubes.conf
|
||||||
%dir /usr/lib/qubes/init
|
%dir /usr/lib/qubes/init
|
||||||
|
Loading…
Reference in New Issue
Block a user