{"id":1510,"date":"2022-09-28T01:16:39","date_gmt":"2022-09-28T04:16:39","guid":{"rendered":"https:\/\/blog.abratel.com.br\/?p=1510"},"modified":"2022-09-28T01:16:40","modified_gmt":"2022-09-28T04:16:40","slug":"mount-drive-in-linux-and-set-auto-mount-at-boot","status":"publish","type":"post","link":"https:\/\/blog.abratel.com.br\/?p=1510","title":{"rendered":"Mount drive in linux and set auto-mount at boot"},"content":{"rendered":"<p>Mount drive<br \/>\nMake a folder (will be mount point)<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\nsudo mkdir \/media\/data\nsudo mount \/dev\/sdb1 \/media\/data\n<\/pre>\n<p>Now you can access the drive at \/media\/data.<\/p>\n<p>Auto-mount at boot<br \/>\nWe want the drive to auto-mount at boot.  This usually means editing \/etc\/fstab.<\/p>\n<p>Firstly, it&#8217;s always best to use the drives UUID.  To find the drive&#8217;s UUID do<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\nls -al \/dev\/disk\/by-uuid\/\n<\/pre>\n<p>Copy the resultant UUID (for your disk) and then open fstab for editing (note I&#8217;m using vim here but use whatever editor you prefer):<\/p>\n<p>sudo vim \/etc\/fstab<br \/>\nYou want to add an entry for the UUID and mount point.  Below is an example of an fstab file with an entry added for the mount above:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n# \/etc\/fstab: static file system information.\n#\n# Use 'blkid' to print the universally unique identifier for a\n# device; this may be used with UUID= as a more robust way to name devices\n# that works even if disks are added and removed. See fstab(5).\n#\n# &lt;file system=&quot;&quot;&gt; &lt;mount point=&quot;&quot;&gt;   &lt;type&gt;\n&lt;options&gt;       &lt;dump&gt;  &lt;pass&gt;\n# \/ was on \/dev\/sdb1 during installation\nUUID=63a46dce-b895-4c1f-9034-b1104694a956 \/               ext4    errors=remount-ro 0       1\n# swap was on \/dev\/sdb5 during installation\nUUID=b9b9ee49-c69c-475b-894b-1279d44034ae none            swap    sw              0       0\n# data drive\nUUID=19fa40a3-fd17-412f-9063-a29ca0e75f93 \/media\/data   ext4    defaults        0       0\nNote: the entry added is the last line.\n<\/pre>\n<p>Test fstab<br \/>\nWe always want to test the fstab before rebooting (an incorrect fstab can render a disk unbootable).  To test do:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\nmount -a\n<\/pre>\n<p>check the last line for errors.  Warnings can help in improving your fstab.<\/pass><\/dump><\/options><\/type><\/mount><\/file><\/p>\n<p>Unmounting drive with umount<br \/>\nYou can unmount drives using umount.  For example, to unmount the data drive above mount at \/media\/data you would do:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\nsudo umount \/media\/data\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Mount drive Make a folder (will be mount point) Now you can access the drive at \/media\/data. Auto-mount at boot We want the drive to auto-mount at boot. This usually means editing \/etc\/fstab. Firstly, it&#8217;s always best to use the drives UUID. To find the&#8230;<\/p>\n","protected":false},"author":1,"featured_media":1512,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[7],"tags":[],"_links":{"self":[{"href":"https:\/\/blog.abratel.com.br\/index.php?rest_route=\/wp\/v2\/posts\/1510"}],"collection":[{"href":"https:\/\/blog.abratel.com.br\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.abratel.com.br\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.abratel.com.br\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.abratel.com.br\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1510"}],"version-history":[{"count":2,"href":"https:\/\/blog.abratel.com.br\/index.php?rest_route=\/wp\/v2\/posts\/1510\/revisions"}],"predecessor-version":[{"id":1514,"href":"https:\/\/blog.abratel.com.br\/index.php?rest_route=\/wp\/v2\/posts\/1510\/revisions\/1514"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.abratel.com.br\/index.php?rest_route=\/wp\/v2\/media\/1512"}],"wp:attachment":[{"href":"https:\/\/blog.abratel.com.br\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1510"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.abratel.com.br\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1510"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.abratel.com.br\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1510"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}