{"id":838,"date":"2026-11-26T17:04:23","date_gmt":"2026-11-26T23:04:23","guid":{"rendered":"https:\/\/kop.lat\/blog\/?p=838"},"modified":"2026-11-26T17:16:36","modified_gmt":"2026-11-26T23:16:36","slug":"automatically-mount-a-drive-in-linux","status":"publish","type":"post","link":"https:\/\/kop.lat\/blog\/automatically-mount-a-drive-in-linux\/","title":{"rendered":"Automatically mount a drive in linux"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">Automatically mount <code>\/dev\/sda1<\/code> at <code>\/mnt\/ntfs_drives<\/code><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Add an <code>\/etc\/fstab<\/code> entry so Ubuntu mounts the partition during startup. Use its UUID rather than <code>\/dev\/sda1<\/code>, because device names can change between boots. The <code>nofail<\/code> option helps the system continue booting if the drive is disconnected.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Make sure to install ntfs support first:<\/strong><\/p>\n\n\n\n<div class=\"dm-code-snippet dark dm-normal-version default no-background-mobile\" snippet-height=\"\" style=\"background-color:#abb8c3\"><div class=\"control-language\"><div class=\"dm-buttons\"><div class=\"dm-buttons-left\"><div class=\"dm-button-snippet red-button\"><\/div><div class=\"dm-button-snippet orange-button\"><\/div><div class=\"dm-button-snippet green-button\"><\/div><\/div><div class=\"dm-buttons-right\"><a id=\"dm-copy-raw-code\"><span class=\"dm-copy-text\">Copy Code<\/span><span class=\"dm-copy-confirmed\" style=\"display:none\">Copied<\/span><span class=\"dm-error-message\" style=\"display:none\">Use a different Browser<\/span><\/a><\/div><\/div><pre class=\" no-line-numbers\"><code id=\"dm-code-raw\" class=\" no-wrap language-php\">sudo apt install ntfs-3g<\/code><\/pre><\/div><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">1. Find the partition UUID and other details<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Get required details:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>- the UUID of the disk: \n<code>sudo blkid \/dev\/sda1<\/code>\n- user \n<code>id -u<\/code>\n- groupd\n<code>id -g<\/code><\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Copy the value after <code>UUID=<\/code>. Also note the filesystem type shown, such as <code>ntfs<\/code>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">2. Create the mount point<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo mkdir -p \/mnt\/ntfs_drives<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">3. Umount the partition (if required)<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><code>sudo umount \/dev\/sda1<\/code><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">4. back up the fstab file<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><code>sudo cp \/etc\/fstab \/etc\/fstab.bak<\/code><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">5. Add an <code>\/etc\/fstab<\/code> entry (at EOF)<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>\/dev\/disk\/by-uuid\/376B271F13EAED1A \/mnt\/ntfs_drive ntfs3 defaults,nofail,uid=1000,gid=1000,umask=022 0 0<\/code><\/pre>\n\n\n\n<div class=\"dm-code-snippet dark dm-normal-version default no-background-mobile\" snippet-height=\"\" style=\"background-color:#abb8c3\"><div class=\"control-language\"><div class=\"dm-buttons\"><div class=\"dm-buttons-left\"><div class=\"dm-button-snippet red-button\"><\/div><div class=\"dm-button-snippet orange-button\"><\/div><div class=\"dm-button-snippet green-button\"><\/div><\/div><div class=\"dm-buttons-right\"><a id=\"dm-copy-raw-code\"><span class=\"dm-copy-text\">Copy Code<\/span><span class=\"dm-copy-confirmed\" style=\"display:none\">Copied<\/span><span class=\"dm-error-message\" style=\"display:none\">Use a different Browser<\/span><\/a><\/div><\/div><pre class=\" no-line-numbers\"><code id=\"dm-code-raw\" class=\" no-wrap language-php\">\/dev\/disk\/by-uuid\/376B271F13EAED1A \/mnt\/ntfs_drive ntfs3 defaults,nofail,uid=1000,gid=1000,umask=022 0 0<\/code><\/pre><\/div><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">6. Test before restarting<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code><code>sudo systemctl daemon-reload<\/code>\nsudo mount -a<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">then see if you find it:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><code>findmnt \/mnt\/ntfs_drives<\/code><\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>If <code>mount -a<\/code> reports an error, correct or remove the new <code>fstab<\/code> line before rebooting.<\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Qwe!<\/p>\n","protected":false},"author":1,"featured_media":258,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[20,4,8],"tags":[5,22],"class_list":["post-838","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-bash","category-linux","category-terminal","tag-linux","tag-terminal"],"_links":{"self":[{"href":"https:\/\/kop.lat\/blog\/wp-json\/wp\/v2\/posts\/838","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kop.lat\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kop.lat\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kop.lat\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kop.lat\/blog\/wp-json\/wp\/v2\/comments?post=838"}],"version-history":[{"count":11,"href":"https:\/\/kop.lat\/blog\/wp-json\/wp\/v2\/posts\/838\/revisions"}],"predecessor-version":[{"id":850,"href":"https:\/\/kop.lat\/blog\/wp-json\/wp\/v2\/posts\/838\/revisions\/850"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/kop.lat\/blog\/wp-json\/wp\/v2\/media\/258"}],"wp:attachment":[{"href":"https:\/\/kop.lat\/blog\/wp-json\/wp\/v2\/media?parent=838"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kop.lat\/blog\/wp-json\/wp\/v2\/categories?post=838"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kop.lat\/blog\/wp-json\/wp\/v2\/tags?post=838"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}