{"id":461,"date":"2015-12-12T11:32:45","date_gmt":"2015-12-12T11:32:45","guid":{"rendered":"http:\/\/www.scmgalaxy.com\/tutorials\/2015\/12\/12\/20-mount-and-unmount-filesystem-partition-commands-in-linux-unix\/"},"modified":"2022-04-24T04:24:23","modified_gmt":"2022-04-24T04:24:23","slug":"20-mount-and-unmount-filesystem-partition-commands-in-linux-unix","status":"publish","type":"post","link":"https:\/\/www.devopsschool.com\/blog\/20-mount-and-unmount-filesystem-partition-commands-in-linux-unix\/","title":{"rendered":"Linux Tutorials: mount &#038; unmount commands examples"},"content":{"rendered":"<div><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-3177 size-full\" src=\"http:\/\/www.scmgalaxy.com\/tutorials\/wp-content\/uploads\/2015\/12\/mount-and-unmount-filesyste.png\" alt=\"partition-commands-in-linux-unix\" width=\"600\" height=\"400\" srcset=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2015\/12\/mount-and-unmount-filesyste.png 600w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2015\/12\/mount-and-unmount-filesyste-300x200.png 300w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/div>\n<div>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.<\/div>\n<div><\/div>\n<div>You need to add the -t FILESYSTEMTYPE argument to the command, replacing FILESYSTEMTYPE with your filesystem type.valid filesystem types are:<\/div>\n<div><\/div>\n<div>auto &#8211; this is a special one. It will try to guess the fs type when you use this.<\/div>\n<div>ext4 &#8211; this is probably the most common Linux fs type of the last few years<\/div>\n<div>ext3 &#8211; this is the most common Linux fs type from a couple years back<\/div>\n<div>ntfs &#8211; this is the most common Windows fs type or larger external hard drives<\/div>\n<div>vfat &#8211; this is the most common fs type used for smaller external hard drives<\/div>\n<div><\/div>\n<div><strong>The general mount command syntax to mount a device:<\/strong><\/div>\n<div>&gt; mount -t type device destination_dir<\/div>\n<div><\/div>\n<div><strong>Mount a CD-ROM<\/strong><\/div>\n<div>&gt; mount -t iso9660 -o ro \/dev\/cdrom \/mnt<\/div>\n<div><\/div>\n<div>In the above example, the option \u201c-o ro\u201d 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.<\/div>\n<div><\/div>\n<div><strong>View All Mounts<\/strong><\/div>\n<div>&gt; mount<\/div>\n<div><\/div>\n<div>You can also use df command to view all the mount points.<\/div>\n<div><\/div>\n<div><strong>Mount all the filesystem mentioned in \/etc\/fstab<\/strong><\/div>\n<div>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:<\/div>\n<div><\/div>\n<div>&gt; cat \/etc\/fstab<\/div>\n<div>&gt; mount -a<\/div>\n<div><\/div>\n<div><strong>Access contents from new mount point<\/strong><\/div>\n<div>&gt; mount -M \/mydata \/mnt\/<\/div>\n<div><\/div>\n<div>Mount an iso image into a directory<\/div>\n<div>&gt; mount -t iso9660 -o loop pdf_collections.iso \/mnt<\/div>\n<div><\/div>\n<div><strong>Unmount<\/strong><\/div>\n<div>\n<p>The same -a option can be used with umount to unmount all the filesystems mentioned in \/etc\/mtab<\/p>\n<p><strong>Example<\/strong><\/p>\n<div># mount \u2013t ext2 \/dev\/hda3 \/oracle A empty directory must be made before mounting in linux<\/div>\n<div># unmounts \/oracle<\/div>\n<div># unmounts \/dev\/hda3 \u00a0 Linux<\/div>\n<div># mount \u2013a \u00a0 This run when system boot<\/div>\n<div># unmont \u2013a \u00a0 \u00a0 This runs when shutdown sequence runs<\/div>\n<div># mount \u2013t vfat \/dev\/hda1 \/windows \u00a0 \u00a0 Windows Partition &#8211; Linux<\/div>\n<div><\/div>\n<div># mount configuration file &#8211; \/etc\/fstab<\/div>\n<div># default file system for mount in Linux is ext2<\/div>\n<\/div>\n<div><\/div>\n<div><strong>Reference<\/strong><\/div>\n<div><a href=\"http:\/\/www.thegeekstuff.com\/2013\/01\/mount-umount-examples\/\" target=\"_blank\" rel=\"noopener\">http:\/\/www.thegeekstuff.com\/2013\/01\/mount-umount-examples\/<\/a><\/div>\n","protected":false},"excerpt":{"rendered":"<p>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 &#8211; this is a special one. It will try&#8230;<\/p>\n","protected":false},"author":1,"featured_media":3177,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_kad_post_transparent":"","_kad_post_title":"","_kad_post_layout":"","_kad_post_sidebar_id":"","_kad_post_content_style":"","_kad_post_vertical_padding":"","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"_kad_post_classname":"","_joinchat":[],"footnotes":""},"categories":[4957],"tags":[378,1262,460,1267,536,1269,1264,1263,1266,1268,169,1261,1270,1265],"class_list":["post-461","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-linux","tag-commands","tag-filesystem","tag-linux","tag-linux-unix","tag-mount","tag-mount-command","tag-mount-filesystem","tag-partition","tag-partition-commands","tag-system","tag-unix","tag-unmount","tag-unmount-command","tag-unmount-filesystem"],"_links":{"self":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/461","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/comments?post=461"}],"version-history":[{"count":4,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/461\/revisions"}],"predecessor-version":[{"id":29693,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/461\/revisions\/29693"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media\/3177"}],"wp:attachment":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media?parent=461"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/categories?post=461"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/tags?post=461"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}