Mounting Directories

Before reading or writing to a Linux partition, you need to mount it. For this you need to specify the partition, directory being mounted, and the format associated with partition syntax for mount command is:-

#mount -t format partition directory

format          - Way the partition is configured such as ext2, ext3 or vfat.
partition       - hard drive being mounted such as /dev/sda1
directory /    - part of the Linux directory structure such as /boot, /home or /var
mount point

So now you could mount /home/mj directory on the /dev/sda1 partition which is formatted to ext3 filesystem as follows:-

# mount -t ext3 /dev/sda1 /home/mj

This is the proper mount format but in real application it can be simpler as with list in /etc/filesystems configuration file, mount command can look for this file format so all you need is

# mount  /dev/sda1 /home/mj

TRICK:-
You can make it even more simpler by adding the following line to /etc/fstab configuration file

/dev/sda1 /home/mj ext3 defaults 1 2

So you now have to specify

#mount /dev/sda1
#mount /home/mj

TIP:-
Sometimes you need to unmount a directory. For example: Linux locks a CD Drive until you unmount the relevant directory with command as

# umount  /mnt/cdrom

NOTE:- It is spelled as umount and not unmount.

Comments

0 Responses to "Mounting Directories"

Post a Comment

 

Managing Shell And its Secrets

Subscribe To Get Update On Mobile

Subscribe
Get updates of latest post on your mobile free