{"id":8497,"date":"2020-08-17T21:55:52","date_gmt":"2020-08-17T21:55:52","guid":{"rendered":"http:\/\/putridparrot.com\/blog\/?p=8497"},"modified":"2020-08-17T21:55:52","modified_gmt":"2020-08-17T21:55:52","slug":"mounting-a-usb-hdd-on-ubuntu-server","status":"publish","type":"post","link":"https:\/\/putridparrot.com\/blog\/mounting-a-usb-hdd-on-ubuntu-server\/","title":{"rendered":"Mounting a USB HDD on Ubuntu server"},"content":{"rendered":"<p>I&#8217;m running up my latest Raspberry Pi with a connected USB SSD and forgot how to mount the thing. So this post is a little reminder. Ofcourse the instruction are not exclusive to Raspberry Pi&#8217;s or Ubuntu, but hey I just wanted a back story to this post.<\/p>\n<p>So you&#8217;ve connected your USB drive and you&#8217;ve got a SSH terminal (i.e. via PuTTY) session connected to you Ubuntu server, what&#8217;s next?<\/p>\n<p><strong>Where&#8217;s my drive<\/strong><\/p>\n<p>The first thing you need to figure out is where your drive is, i.e. what \/dev\/ location it&#8217;s assigned to.<\/p>\n<ul>\n<li>Try running <em>df<\/em>, which reports disk space and usage, from this you might be able to spot your drive, in my case it&#8217;s \/dev\/sda1 and its obvious by the size of the drive<\/li>\n<li>If this is not conclusive then run <em>sudo fdisk -l<\/em> this may help locate the disk<\/li>\n<\/ul>\n<p><strong>Mounting the drive<\/strong><\/p>\n<p>Assuming we&#8217;ve located the device, and for this example it is on \/dev\/sda1, how do we mount this drive?<\/p>\n<ul>\n<li>Create a folder that will get mapped to our mounted drive, for example <em>mkdir \/media\/external<\/em> or whatever you want to name it<\/li>\n<li>To mount the drive we now use\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">\r\nsudo mount -t ntfs-3g \/dev\/sda1 \/media\/external\r\n<\/pre>\n<p>Obviously this drive I&#8217;m mounting is an NTFS formatted drive, you might be using <em>vfat<\/em> or something else instead, so check. Then we simply have the source (\/dev\/sda1) mapping to the destination (\/media\/external) that we created.<\/p>\n<p><em>Note: without the mount taking place, <em>ls<\/em> the destination and you&#8217;ll see no files (if they exist on your drive). After you mount the drive. <em>ls<\/em> the destination to see the files on the USB drive.<\/em>\n<\/li>\n<\/ul>\n<p>As it currently stands, when you reboot you&#8217;ll have to mount the drive again.<\/p>\n<p><strong>Auto-mounting the drive<\/strong><\/p>\n<p>In scenarios where we&#8217;re not removing the drive and simply want the OS to automount our drive, we need to do a couple of things.<\/p>\n<ul>\n<li>Find the UUID for the drive by running <em>sudo blkid<\/em>, next to the device, i.e. \/dev\/sda1 should be a UUID, copy or note down the string.<\/li>\n<li>Run <em>sudo nano fstab<\/em><\/li>\n<li>Add a new line to the bottom of the file along these lines\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">\r\nUUID=ABCDEFGHIJK \/media\/external auto nosiud,nodev,nofail 0 0\r\n<\/pre>\n<p>and save the file<\/li>\n<li>Run <em>sudo mount -a<\/em> to check for errors<\/li>\n<\/ul>\n<p>Now when you reboot the machine the USB drive should be mounted automatically.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;m running up my latest Raspberry Pi with a connected USB SSD and forgot how to mount the thing. So this post is a little reminder. Ofcourse the instruction are not exclusive to Raspberry Pi&#8217;s or Ubuntu, but hey I just wanted a back story to this post. So you&#8217;ve connected your USB drive and [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[59,140],"tags":[],"class_list":["post-8497","post","type-post","status-publish","format-standard","hentry","category-raspberry-pi","category-ubuntu"],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts\/8497","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/comments?post=8497"}],"version-history":[{"count":3,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts\/8497\/revisions"}],"predecessor-version":[{"id":8500,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts\/8497\/revisions\/8500"}],"wp:attachment":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/media?parent=8497"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/categories?post=8497"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/tags?post=8497"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}