Include /proc in chroot mounts

This commit is contained in:
Joshua Boniface 2022-10-20 15:00:10 -04:00
parent 2608f38d64
commit fcadde057e
1 changed files with 13 additions and 0 deletions

View File

@ -558,6 +558,15 @@ def create_vm(
f"Failed to mount sysfs onto {temp_dir}/sys for chroot: {stderr}"
)
# Bind mount /proc to the chroot location /proc
retcode, stdout, stderr = pvc_common.run_os_command(
f"mount --bind --options rw /proc {temp_dir}/proc"
)
if retcode:
raise ProvisioningError(
f"Failed to mount procfs onto {temp_dir}/proc for chroot: {stderr}"
)
print("Chroot environment prepared successfully")
def general_cleanup():
@ -576,6 +585,10 @@ def create_vm(
retcode, stdout, stderr = pvc_common.run_os_command(
f"umount {temp_dir}/sys"
)
# Unmount bind-mounted procfs on the chroot
retcode, stdout, stderr = pvc_common.run_os_command(
f"umount {temp_dir}/proc"
)
# Unmount bind-mounted tmpfs on the chroot
retcode, stdout, stderr = pvc_common.run_os_command(
f"umount {temp_dir}/tmp"