Announcement

Collapse
No announcement yet.

Mounting filesystem in Linux

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Mounting filesystem in Linux

    Mounting filesystem

    Once the filesystem has created on a partition the next step is mount the filesystem into the system using mount in order to get access to files and directories on the filesystem :

    Code:
    $ mount partition mountpoint -t filesystemtype -o options
    
    $ mount /dev/hda3 /mnt -t ext4 -o rw,noexec
    It mounts /dev/hda3 partition which contains an ext4 filesystem in /mnt in read-write mode (rw). Binary files executions are not allowed on this filesystem (noexec).
    Code:
    $ mount
    ...
    /dev/hda3 on /tmp type ext4 (rw,noexec)
    ...
    Typing just mount lists all mounted partitions on the system.

    Code:
    $ umount /mnt
    Just in case to umount the partition execute umount mountpoint|partition : that means that 'umount /dev/hda3' also works.

    Mount options (-o option1,option2 ) control the way the filesystem is acceded by the system. This options can be the following :

    atime
    File inode is updated each time the file is accessed. With noatime option the file inode is not updated when the file is acceded.

    auto
    Searches through /etc/filesystems for the appropriate filesystem type. With noauto option en explicit mount execution is required.

    defaults
    Default mount options : rw, exec, suid, dev, auto, nouser, and async.

    dev
    Allows access to character devices and block access to devices such as drives. With nodev option access to the character devices is not allowed.

    exec
    Allows binaries to be executed on the filesystem. With noexec option binaries executions are not allowed.

    remount
    Re-mounts a currently mounted filesystem.

    ro
    Mounts the filesystem in read-only mode.

    rw
    Mounts the filesystem in read/write mode.

    suid
    Allows setuid or setgid file permissions on this filesystem. With nosuid setuid or setgid permission are not allowed on the filesystem.

    sync
    Writes and reads are done synchronously on this filesystem. With async read-write process is done asynchronously.

    user
    Allows nonroot users to mount this filesystem. Options noexec, nosuid, and nodev are included in this option. With nouser option only root is allowed to mount the filesystem.
    /etc/fstab

    Linux automates the filesystem mounting via /etc/fstab file which contains the information used on the boot process to mount the appropriate filesystems on system directories as /, /boot, /tmp, etc. :

    Code:
    $ cat /etc/fstab
    
    /dev/hda2     /                   ext4 defaults 1 1
    /dev/hda1     /boot          ext4 defaults 1 2
    tmpfs            /dev/shm   tmpfs defaults 0 0
    devpts         /dev/pts      devpts gid=5,mode=620 0 0
    sysfs           /sys              sysfs defaults 0 0
    proc             /proc            proc defaults 0 0
    /dev/hda3    swap          swap defaults 0 0
    The following are the six fields beginning on left

    Label
    Device to be mounted. It can be set up with LABEL (for example LABEL=/) if the physical partition has been labelled with e2label command.

    Mount Point
    System directory where the filesystem will be mounted.

    Filesystem Type
    Valid filesystem types are ext, ext2, ext3, ext4, msdos, vfat, devpts, proc, tmpfs, udf, iso9660, nfs, smb, and swap.

    Mount Options
    The same options as -o in mount command.

    Dump Value
    0 or 1. 1 means that data is automatically saved to disk by the dump command when you exit Linux.

    Filesystem Check Order
    Defines the order that filesystems are checked by fsck during the boot process. The root directory (/) filesystem should be set to 1, and other filesystems should be set to 2.

    When the command 'mount -a' is executed the system verifies that all mount points on /etc/fstab are mounted as described on this file. If any mounting is missing then the system automatically mounts it :

    Code:
    $ mount -a
    Last edited by kuldeep; 02-21-2015, 02:39 AM.
Working...
X