Saturday, August 25, 2012

Linux 19 - Mounting and Unmounting Filesystems

–manual mounting
–mounting on bootup
–user mountable file systems
–automount

In order to mount filesystems you must be root unless otherwise specified by /etc/fstab

There are two ways of mounting a filsystem

  • via mount
  • via /etc/fstab

Mount

will mount it once while the system is running but it will not mount it again on the next boot-up

/etc/fstab is like an automount utility, at every bootup the system will search for entries in fstab and attempt to honour them

SNAG-0023

In order to be able to mount you must have an empty directory in the /mnt directory, here hard_drive was created, after the directory is created we would use the mount command, specify the filesystem type, the source device, and the destination to where we would like to access it.

When issuing the mount command we can clearly see on the bottom that /dev/sdb1 has been mounte with read-write permissions and the FS type is ext3

/etc/fstab

This file contains “static information about the filesystems

It’s format is

SNAG-0025

  • <file system>
    1. UUID ( UUID=fd267fa3-83b6-4cda-a705-d567632fb3a7 )
    2. Label
    3. actual block device ( /dev/abc )
  • <mount point>
    • location of device that is mounted
  • <type>
    • what filesystem are we mounting
  • <options> ( separate multiple values with commas )
    1. user
      • if user flag is set then root is not the only authority to mount the filesystem
    2. rw,ro
      • read write or read only or both, if read only not even root can write to the filesystem
    3. auto
      • automatically mount the fs on bootup
    4. noauto
      • dont’t mount the fs on bootup
    5. noexec
      • if specified no one will run binary programs
    6. defaults
      • when in doubt
  • <dump>
    • boolean value
    • if set to 1 it will automatically save files left in cache to harddrive
  • <pass>
    • usually root filesystems will have a value of 1
    • other local mounting points have a 2
    • removable devices have 0
    • this specifies the order in which they are scanned

/media

floppy, cdrom are mounted on /media  and also removable media like sd cards

adding /dev/sdb1

/dev/sdb1 /mnt/hard_drive ext3 rw,user,auto,noexec 0 2
root@debian:~# mount /mnt/hard_drive/
root@debian:~#
root@debian:~# umount /dev/sdb1
root@debian:~#


No comments:

Post a Comment