How to Mount and Unmount Filesystem in Linux

In daily server maintenance, we may need to add another disks to our server. This tutorial will walk you through how to mount and unmount filesystem in Linux.

The directories where filesystems are mounted on are called mount points, you can access files in mount points by entering to that directory.

Mount Filesystem

If you want to mount disk /dev/sdb on /backup directory, just run the following command:

# mount /dev/sdb /backup

Mount command automatically detects the file system on disk. But in some cases, you need specify the file system type manually.

# mount -t ext4 /dev/sdb /backup

If you want to mount filesystems on system boot, edit /etc/fstab and append the following line at the end of file, change /dev/sdb with your own disk.

/dev/sdb /backup ext4 defaults 0 0

Now, run mount -a to mount all disks defined in /etc/fstab file.

Unmount Filesystem

You can use umount command to unmount filesystems, just run umount command with disk name or mount point name to unmount currently mounted disk.

# umount /backup
# umount /dev/sdb