From 2c9fe0803daf49c108053bc13ab9b322a6acff9b Mon Sep 17 00:00:00 2001 From: Marek Marczykowski Date: Fri, 16 Nov 2012 14:03:36 +0100 Subject: [PATCH] vm/core: use mount --bind instead of symlink for /home Many applications doesn't like /home as symlink ($HOME differs from real location). --- misc/fstab | 1 + vm-init.d/qubes_core | 9 +++++++-- vm-init.d/qubes_core_appvm | 6 +++++- vm-systemd/misc-post.sh | 13 +++++++++---- vm-systemd/prepare-dvm.sh | 6 +++++- 5 files changed, 27 insertions(+), 8 deletions(-) diff --git a/misc/fstab b/misc/fstab index b7d0feec..80121207 100644 --- a/misc/fstab +++ b/misc/fstab @@ -8,6 +8,7 @@ # /dev/mapper/dmroot / ext4 defaults,noatime 1 1 /dev/xvdb /rw ext4 noauto,defaults 1 2 +/rw/home /home none noauto,bind,defaults 0 0 /dev/xvdc1 swap swap defaults 0 0 tmpfs /dev/shm tmpfs defaults 0 0 devpts /dev/pts devpts gid=5,mode=620 0 0 diff --git a/vm-init.d/qubes_core b/vm-init.d/qubes_core index 4830587b..b3927fd3 100755 --- a/vm-init.d/qubes_core +++ b/vm-init.d/qubes_core @@ -65,14 +65,19 @@ start() touch /rw/config/rc.local mkdir -p /rw/home - cp -a /home.orig/user /home + cp -a /home.orig/user /rw/home mkdir -p /rw/usrlocal - cp -a /usr/local.orig/* /usr/local + cp -a /usr/local.orig/* /rw/usrlocal touch /var/lib/qubes/first_boot_completed fi fi + if [ -L /home ]; then + rm /home + mkdir /home + fi + mount /home /usr/lib/qubes/qrexec_agent 2>/var/log/qubes/qrexec_agent.log & diff --git a/vm-init.d/qubes_core_appvm b/vm-init.d/qubes_core_appvm index a0cfe062..6e851d17 100755 --- a/vm-init.d/qubes_core_appvm +++ b/vm-init.d/qubes_core_appvm @@ -45,7 +45,11 @@ start() echo -n $"Executing Qubes Core scripts for AppVM:" if xenstore-read qubes_save_request 2>/dev/null ; then - ln -sf /home_volatile /home + if [ -L /home ]; then + rm /home + mkdir /home + fi + mount --bind /home_volatile /home touch /etc/this_is_dvm mount /rw possibly_run_save_script diff --git a/vm-systemd/misc-post.sh b/vm-systemd/misc-post.sh index df4c8a4d..cbd0c633 100755 --- a/vm-systemd/misc-post.sh +++ b/vm-systemd/misc-post.sh @@ -24,18 +24,23 @@ if [ -e /dev/xvdb -a ! -e /etc/this_is_dvm ] ; then touch /rw/config/rc.local-early mkdir -p /rw/home - cp -a /home.orig/user /home + cp -a /home.orig/user /rw/home mkdir -p /rw/usrlocal - cp -a /usr/local.orig/* /usr/local + cp -a /usr/local.orig/* /rw/usrlocal touch /var/lib/qubes/first_boot_completed fi # Chown home if user UID have changed - can be the case on template switch - HOME_USER_UID=`ls -dn /home/user | awk '{print $3}'` + HOME_USER_UID=`ls -dn /rw/home/user | awk '{print $3}'` if [ "`id -u user`" -ne "$HOME_USER_UID" ]; then - find /home/user -uid "$HOME_USER_UID" -print0 | xargs -0 chown user:user + find /rw/home/user -uid "$HOME_USER_UID" -print0 | xargs -0 chown user:user fi + if [ -L /home ]; then + rm /home + mkdir /home + fi + mount /home fi [ -x /rw/config/rc.local ] && /rw/config/rc.local diff --git a/vm-systemd/prepare-dvm.sh b/vm-systemd/prepare-dvm.sh index 2229afc7..ae578296 100755 --- a/vm-systemd/prepare-dvm.sh +++ b/vm-systemd/prepare-dvm.sh @@ -13,7 +13,11 @@ possibly_run_save_script() } if xenstore-read qubes_save_request 2>/dev/null ; then - ln -sf /home_volatile /home + if [ -L /home ]; then + rm /home + mkdir /home + fi + mount --bind /home_volatile /home touch /etc/this_is_dvm mount /rw possibly_run_save_script