How to Mount and Unmount Filesystem in Linux
Abstract: Now run mount -a command to immediate mount all disk defined in /etc/fstab file. $ mount -a
Mount is to access a filesystem in Linux. You can mount a filesystem on any directory and access content by entering to that directory. In Linux terms, these directories are called mount points. This tutorial will help you to mount and unmount filesystem in Linux system.
2. Use mount CommandMostly, each Linux/Unix operating systems provides mount command. This command is used to mounting any file system on any directory. After that you can access the filesystem content.
Syntax:
$ mount [-t fstype] filesystem mountpoint
For example, you have added a disk /dev/sdb
on on your system. Now you want to mount this on /data directory. Use following command to mount it.
# mount /dev/sdb /data
Mount command automatically detects the file system on disk. But in some cases, you need specify the file system type with command.
$ mount -t ext4 /dev/sdb /data3. Unmount Filesystem
Use umount
command to unmount any mounted filesystem on your system. Run umount command with disk name or mount point name to unmount currently mounted disk.
$ umount /dev/sdb $ umount /data4. Mount Disk on System Boot
You also required to mount disk on system boot. So that partitions will be available on system boot. /etc/fstab file is used to mount disks. You need to edit /etc/fstab and make new entry to mount the partitions automatically.
Edit /etc/fstab and append below line at end of file. Change /dev/sdb with your disk name.
/dev/sdb /data ext4 defaults 0 0
Now run mount -a
command to immediate mount all disk defined in /etc/fstab file.
$ mount -a