The purpose of this ducument is to show you the fstab and mount command.
The “/etc/fstab” can be used to define how disk partitions,
or remote filesystems should be mounted into the filesystem. it contains the following fields separated by a space or tab:
<file system> <dir> <type> <options> <dump> <pass>
- file system - the partition or storage device to be mounted.
- dir - the mountpoint where is mounted to.
- type - the file system type of the partition or storage device to be mounted. Examples: ext4, btrfs, reiserfs, xfs, jfs, smbfs, iso9660, vfat, ntfs, swap and auto.
- options the default mount options for the filesystem to be used.
- dump - used by the dump utility to decide when to make a backup. The entries are 0 and 1. If 0, dump will ignore the file system; if 1, dump will make a backup.
- pass - used by fsck to decide which order filesystems are to be checked. The entries are 0, 1 and 2. The file systems you want to have checked should have a 2. File systems with a value 0 will not be checked by the fsck utility.
If you want to mount file systems automatically, you can modify fstab configuration. This assumes the partition(/dev/sdb1) is formated as ext4,
Let`s auto mount it, add the following line to the fstab.
/dev/sdb1 /path/to/mountpoint ext4 defaults 0 0
Howto identify filesystems
All partitions and devices have a unique UUID. They are generated by filesystem utilities, when you create or format a partition.
The general mount command syntax to mount a device:
$sudo mount -t type device destination_dir
Mount a CD-ROM
$sudo mount -t iso9660 -o ro /dev/cdrom /mnt
Checking the mountpoints
You can also use df command to view all the mount points.
[sudo] password for edwin:
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda5 19092180 4361576 13737736 25% /
none 4 0 4 0% /sys/fs/cgroup
udev 1979460 4 1979456 1% /dev
tmpfs 398048 1092 396956 1% /run
none 5120 0 5120 0% /run/lock
none 1990228 144 1990084 1% /run/shm
none 102400 28 102372 1% /run/user
/dev/sda1 463844 36143 399234 9% /boot
/dev/sda6 38314312 2394128 33950832 7% /var
/dev/sda8 93628352 49393896 39455348 56% /opt
Mount all the filesystem saved in “/etc/fstab”
Unmount all the filesystems mentioned in “/etc/mtab”
Mount an iso image into a directory
$sudo mount -t iso9660 -o loop pdf_collections.iso /mnt
- [ January 30, 2018 ] How to install and config Termux on Android 5.x or later
- [ January 30, 2018 ] Automatically enable HTTPS on your website with EFF's Certbot
- [ January 29, 2018 ] Wireless network management in Raspberry Pi
- [ January 28, 2018 ] Install pycharm by Ubuntu make
- [ December 22, 2016 ] Deploying Django Apps with mod_wsgi on Ubuntu 16.04
- [ December 19, 2016 ] Top Things to do after Ubuntu 16.04 Installation
- [ December 19, 2016 ] Setting up Vim for Python
- [ December 19, 2016 ] PHP5.2 Parse error: syntax error, unexpected T_FUNCTION
- [ December 19, 2016 ] Automatically enable HTTPS on your website with EFF's Certbot
- [ December 15, 2016 ] How to install php5.6 on Ubuntu 16.04