LPIC 104.3 Control mounting and unmounting of filesystems

Weight: 3

Description: Candidates should be able to configure the mounting of a filesystem.

Key Knowledge Areas:

  • Manually mount and unmount filesystems
  • Configure filesystem mounting on bootup
  • Configure user mountable removable filesystems

Terms and Utilities:

  • /etc/fstab
  • /media/
  • mount
  • umount

Manually mount and unmount filesystems

  • mount
    Syntax: mount –t type –o option device mountpoint
root@myhost:/mnt# mkdir cdrom  
root@myhost:/mnt# mount -t iso9660 -o exec /dev/cdrom /mnt/cdrom  
# `exec` option make files on this mount point can be executed
# (when there's a software installation file)
  • unmount
    Syntax: umount device|mountpoint
root@myhost:~# umount /dev/cdrom  
#or
root@u1604:~# umount /mnt/cdrom  

One limitation for umount is it not allow you un-mount any device which currently in use. So, to find out which process is access device, need use fuser tool.

root@myhost:~# fuser -m /mnt/cdrom  
/mnt/cdrom:           1157c

Configure filesystem mounting on bootup

  1. List block device id
root@myhost:~$ blkid  
/dev/sda1: UUID="d504b412-7b66-45a5-9ad7-dca56f240efa" TYPE="ext4" PARTUUID="c374284f-01"
/dev/sda5: UUID="1e952800-3633-46e3-94cd-a9d82ac068c5" TYPE="swap" PARTUUID="c374284f-05"
/dev/sr0: UUID="2016-07-19-17-20-59-00" LABEL="CDROM" TYPE="iso9660" PTUUID="6ed628c0" PTTYPE="dos"
  1. Add new entry to /etc/fstab
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
# / was on /dev/sda1 during installation
UUID=d504b412-7b66-45a5-9ad7-dca56f240efa /  ext4   errors=remount-ro 0       1  
/dev/cdrom  /mnt/cdrom  iso9660 exec,noauto  0 0
# noauto is necessary for removable device