Optimized umount procedures

This commit is contained in:
Kevin Veen-Birkenbach 2020-06-11 11:41:51 +02:00
parent e8ffc4d756
commit aa2eb62e77
3 changed files with 14 additions and 10 deletions

View File

@ -50,6 +50,18 @@ mount_partitions(){
error error
} }
umount_everything(){
info "Unmounting everything..." &&
(umount -lv "$chroot_dev_pts_mount_path" || warning "Umounting $chroot_dev_pts_mount_path failed!") &&
(umount -lv "$chroot_dev_mount_path" || warning "Umounting $chroot_dev_mount_path failed!" ) &&
(umount -v "$chroot_proc_mount_path" || warning "Umounting $chroot_proc_mount_path failed!" ) &&
(umount -v "$chroot_sys_mount_path" || warning "Umounting $chroot_sys_mount_path failed!") &&
(umount -v "$root_mount_path""boot/" || warning "Umounting $root_mount_path""boot/ failed!") &&
(umount -v "$root_mount_path" || warning "Umounting $root_mount_path failed!") &&
(umount -v "$boot_mount_path" || warning "Umounting $boot_mount_path failed!") ||
warning "Failed."
}
mount_chroot_binds(){ mount_chroot_binds(){
info "Mount chroot environments..." && info "Mount chroot environments..." &&
chroot_sys_mount_path="$root_mount_path""sys/" && chroot_sys_mount_path="$root_mount_path""sys/" &&

View File

@ -5,9 +5,7 @@
source "$(dirname "$(readlink -f "${0}")")/base.sh" || (echo "Loading base.sh failed." && exit 1) source "$(dirname "$(readlink -f "${0}")")/base.sh" || (echo "Loading base.sh failed." && exit 1)
destructor(){ destructor(){
info "Unmount everything" && umount_everything
umount "$root_mount_path"{dev/pts,dev,sys,proc,boot,} $boot_mount_path||
warning "Failed."
} }
info "Starting chroot..." info "Starting chroot..."

View File

@ -10,13 +10,7 @@ info "Setupscript for images started..."
info "Define functions..." info "Define functions..."
destructor(){ destructor(){
info "Cleaning up..." info "Cleaning up..."
umount -v "$chroot_dev_pts_mount_path" || warning "Umounting $chroot_dev_pts_mount_path failed!" umount_everything
umount -v "$chroot_dev_mount_path" || warning "Umounting $chroot_dev_mount_path failed!"
umount -v "$chroot_proc_mount_path" || warning "Umounting $chroot_proc_mount_path failed!"
umount -v "$chroot_sys_mount_path" || warning "Umounting $chroot_sys_mount_path failed!"
umount -v "$root_mount_path""boot/" || warning "Umounting $root_mount_path""boot/ failed!"
umount -v "$root_mount_path" || warning "Umounting $root_mount_path failed!"
umount -v "$boot_mount_path" || warning "Umounting $boot_mount_path failed!"
rmdir -v "$root_mount_path" || warning "Removing $root_mount_path failed!" rmdir -v "$root_mount_path" || warning "Removing $root_mount_path failed!"
rmdir -v "$boot_mount_path" || warning "Removing $boot_mount_path failed!" rmdir -v "$boot_mount_path" || warning "Removing $boot_mount_path failed!"
rmdir -v "$working_folder_path" || warning "Removing $working_folder_path failed!" rmdir -v "$working_folder_path" || warning "Removing $working_folder_path failed!"