1. Introduction

Chroot is a powerful tool used in Linux to create a virtualized environment within a running operating system. A chroot environment is created by isolating a directory and its contents from the rest of the system. Once a chroot environment is created, the directory becomes the root directory for any processes that run inside the chroot.

However, once a chroot is no longer needed, it’s important to unmount the chrooted filesystem to ensure the system is returned to its original state.

In this article, we’ll discuss how to unmount a formerly chroot’d filesystem in Linux.

2. Unmounting a Formerly Chroot’d Filesystem

The process of unmounting a chrooted filesystem is straightforward. However, it’s important to understand the steps involved to ensure a smooth unmount process.

2.1. Identify the Mounted Filesystem

Before unmounting a chrooted filesystem, we must first identify the mounted filesystem. To do this, use the mount command with no arguments to display a list of all mounted filesystems on the system:

$ mount
/dev/sda1 on / type ext4 (rw,relatime,errors=remount-ro)
proc on /proc type proc (rw,relatime)
sysfs on /sys type sysfs (rw,relatime)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000)
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev)
/dev/sdb1 on /mnt/data type ext4 (rw,relatime)
/dev/sdb2 on /mnt/archive type ext4 (rw,relatime)
/mnt/archive/chroot on /mnt/archive/chroot type none (rw,bind)

The output will be a list of all the currently mounted filesystems on the system, including any chrooted filesystems.

In this example, the chrooted filesystem that we want to unmount is located at /mnt/archive/chroot.

2.2. Exit the Chrooted Environment

Before we can unmount a chrooted filesystem, we must exit the chrooted environment. To exit the chrooted environment, use the exit command:

$ exit

2.3. Unmount the Filesystem

Now that we’ve exited the chrooted environment, we can unmount the chrooted filesystem using the unmount command:

$ umount /mnt/archive/chroot

If the filesystem is busy, we may need to force the unmount using the -f option.

$ umount -f /mnt/archive/chroot

3. Conclusion

Unmounting a chrooted filesystem is a simple process, but it’s important to understand the steps involved to ensure the process goes smoothly. Following the steps outlined in this article, we can easily unmount a formerly chroot’d filesystem in Linux.

Comments are open for 30 days after publishing a post. For any issues past this date, use the Contact form on the site.