Mount Points

Even after formatting the partition, we can not add the data into the partition. In order to add the data into the partition it is requited to be mounted.

Mounting a partition

Mounting is the attaching of an additional file system to the currently accessible file system of a computer. There are two types of mounting which will be used in Linux.

  • Temporary Mounting
  • Permanent Mounting

Temporary Mounting

In a temporary mount point we will create a directory and mount it, but this mount point will last only till the system is up, once it is rebooted the mounting will be lost.

Syntax : # mount device directory

# mkdir /data1
# mount /dev/sda4 /data1

To view all the mounted partitions, use below command.

# mount

Once we successfully mounted the partition we can access it and can store the data.

# cd /data1

Unmounting a partition

Removing the connection between the mounted device and the rest of the file system is referred to as unmounting.

# umount /dev/sda4 /data1

Once unmounted, verify with mount command.

Permanent Mounting.

Permanent mounting procedure is exactly same like temp mounting, but here we will update the /etc/fstab file with the mounting details. So that it will be mounted even after system is reboot.

Steps to make a permemant mount point.

  • Make a directory or use an existing directory
  • Add entry in /etc/fstab file
  • Use mount -a command to check it is mounting. ( mount -a will mount all the entries placed in /etc/fstab)

Here we will be using our existing /data1 directory as mount point which is created previously.

Entry : /dev/sda4 /data1 ext4 defaults 0 0

Device Name – Mount point – Type of File system – Mount options – Dumping – Check Sequence

# vi /etc/fstb

After added the above entry, use mount -a command to mount and use mount command to verify it.

Now you can access the directory and add,delete or modify the contents and also unmount the file system at any time.

Some times a directory reflects error while unmounting, the possible causes for it are

  • You are the same directory and trying to unmount it. Check with pwd command.
  • Some users are present in the directory and using the contents in it.
  • Check with fuser -cu /dev/sda4
  • Check for the files which are open with lsof /dev/sda4
  • Kill open connections using fuser -ck /data1/export where export is the file which is open
  • Now you can use umount command to unmount the file system.

To view usage information of mounted partition use the command df -h
To view the size od the file or directory use the command du -h file or directory

Assigning label to the partition

Assigning the label is giving some name to the partition. To assign label to the partition use e2label command.

# e2label /dev/sda4 data

To list the all mounted partitions along with thier labels, use mount -l command

# mount -l

Mounting a partition using its label

Mounting a /dev/sda4 partition with its label data

# mount LABEL=data /data1

Verify it with mount command

# mount

Making a permanent mount point using label.

As we now that to make a permanent mount point, an entry has to be made in /etc/fstab.

# vi /etc/fstab

entry : LABEL=data /data1 ext4 defaults 0 0

Now use mount -a command and verify it with mount command whether it is mounted or not.

Mounting a partition permanently with its block id (UUID)

  • To check the uuid of a partion use blkid /dev/sda4
  • Copy the uuid
  • Make an entry in /etc/fstab using UUID
  • Verify it with mount -a option.
# blkid /dev/sda4
/dev/sda4: LABEL=data UUID="cb87e43f-f72c-405e-a282-f6b7d29e3d81" TYPE="ext4"
# vi /etc/fstab

Entry :
UUID=cb87e43f-f72c-405e-a282-f6b7d29e3d81 /data1 ext4 defaults 0 0

Now mount it with mount -a command and verify it with mount command.

# mount -a