Sunday, April 27, 2014

How to mount and unmount - in Linux

Here are some simple commands that you can use for mounting a device in Linux.

To mount something to the filesystem - general mount syntax
# mount -t ext4 /dev/sda2 /home

Remount syntax is
# mount -o remount /home

To make all the mount options persistent to reboot edit the /etc/fstab file. Once you have edited the fstab file you can run the the following option, which will mount all the things /etc/fstab contains.
# mount -a

To unmount the filesystem
# umount /home
# umount -a

To add permissions to the filesystem
# mount -rw -o remount /

To list all the mountpoint options you run the following
# mount
or
# mount |grep home - for individual mount points

Following command also will show all the mounted systems
# df or df -h (-h for human readable)

Forcefully unmount the system
# umount -f /mnt

You can run the fuser command to see which process is holding the mount point
# fuser -cu /mnt
# ps -ajx | grep /mnt

Mounting a cd rom device
# mount  -t iso9660 -o ro /dev/cdrom /mnt 

No comments:

Post a Comment