LOGIN
Sign In or Register
Avatar
Not Registered Yet?

Join Now! It's FREE. Get full access and benefit from this site

Reset My password - Remind Me My username

Username
Password
Remember me

20 Mount and Unmount Filesystem / Partition commands in Linux / UNIX

Once you create a partition, you should use mount command to mount the partition into a mount point (a directory), to start using the filesystem.
 
You need to add the -t FILESYSTEMTYPE argument to the command, replacing FILESYSTEMTYPE with your filesystem type.valid filesystem types are:
 
auto - this is a special one. It will try to guess the fs type when you use this.
ext4 - this is probably the most common Linux fs type of the last few years
ext3 - this is the most common Linux fs type from a couple years back
ntfs - this is the most common Windows fs type or larger external hard drives
vfat - this is the most common fs type used for smaller external hard drives
 
The general mount command syntax to mount a device:
> mount -t type device destination_dir
 
Mount a CD-ROM
> mount -t iso9660 -o ro /dev/cdrom /mnt
 
In the above example, the option “-o ro” indicates that the cdrom should be mounted with read-only access. Also, make sure that the destination directory (in the above example, /mnt) exist before you execute the mount command.
 
View All Mounts
> mount
 
You can also use df command to view all the mount points.
 
Mount all the filesystem mentioned in /etc/fstab
The filesystems listed in /etc/fstab gets mounted during booting process. After booting, system administrator may unmount some of the partitions for various reasons. If you want all the filesystems to be mounted as specified in /etc/fstab, use -a option with mount as shown below:
 
> cat /etc/fstab
> mount -a
 
Access contents from new mount point
> mount -M /mydata /mnt/
 
Mount an iso image into a directory
> mount -t iso9660 -o loop pdf_collections.iso /mnt
 
Unmount
The same -a option can be used with umount to unmount all the filesystems mentioned in /etc/mtab

Example
# mount –t ext2 /dev/hda3 /oracle A empty directory must be made before mounting in linux
# unmounts /oracle 
# unmounts /dev/hda3   Linux
# mount –a   This run when system boot
# unmont –a     This runs when shutdown sequence runs
# mount –t vfat /dev/hda1 /windows     Windows Partition - Linux           
 
# mount configuration file - /etc/fstab
# default file system for mount in Linux is ext2
 
Reference
http://www.thegeekstuff.com/2013/01/mount-umount-examples/
Rate this item
(0 votes)
Rajesh Kumar

.

Total, Over 12 years of extensive experience in the Software Configuration Management domain having depth knowledge of DevOps, Continuous Integration and Delivery, Configuration Management, Build and Installer, Release Management and Application Management.

What corporate management say about us?

Very well covered all the topics like Git, Nexus, Jenkins, Chef, Dockers. Study materials & hands on done was also having excellent quality.

SUMIT KUMAR
I am working as Senior Project Manager in HCL, Noida India
Sep 02, 2016