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

partition-commands-in-linux-unix
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
Tagged : / / / / / / / / / / / / /
0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x