
{"id":43979,"date":"2023-05-09T14:10:50","date_gmt":"2023-05-09T14:10:50","guid":{"rendered":"https:\/\/ubuntuhandbook.org\/?p=43979"},"modified":"2023-06-22T12:39:31","modified_gmt":"2023-06-22T12:39:31","slug":"auto-mount-external-disk-partitions","status":"publish","type":"post","link":"https:\/\/ubuntuhandbook.org\/index.php\/2023\/05\/auto-mount-external-disk-partitions\/","title":{"rendered":"How to Auto Mount External Disk Partitions in Ubuntu 22.04 | Fedora 37\/38"},"content":{"rendered":"<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/02\/disk-icon.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"alignleft size-thumbnail wp-image-43665\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/02\/disk-icon-250x250.webp\" alt=\"\" width=\"250\" height=\"250\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/02\/disk-icon-250x250.webp 250w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/02\/disk-icon-300x300.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/02\/disk-icon-600x600.webp 600w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/02\/disk-icon-768x768.webp 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/02\/disk-icon.webp 1200w\" sizes=\"auto, (max-width: 250px) 100vw, 250px\" \/><\/a><\/p>\n<p>This tutorial shows how to automatically mount external disk partitions on startup of Ubuntu, Fedora, Debian, and most other Linux.<\/p>\n<p>I bought a new SSD recently. Now, I have 2 solid-state drives (SSDs) connected on my computer. Ubuntu 22.04 is installed on one SSD drive, while another one contains VirtualBox Virtual Machine files.<\/p>\n<p>As result, I have to click open the external SSD partition in file manager every time on startup to mount it. So the files on that SSD are accessible via mount point (usually &#8220;<code>\/media\/username\/xxx<\/code>&#8220;). Or, all virtual machines in VirtualBox will be marked as &#8220;Inaccessible&#8221;.<\/p>\n<p>To make life easier, it&#8217;s possible to auto-mount the external file partition. So user doesn&#8217;t have to make one more mouse click in file manager every time on startup. And, here&#8217;s what I did in Ubuntu 22.04.<\/p>\n<p>&nbsp;<\/p>\n<p><strong>UPDATE: For most desktop Linux, there&#8217;s an easier way to auto-mount disk driver or partitions on startup. See <a href=\"https:\/\/fostips.com\/tip-auto-mount-ubuntu-fedora\/\" target=\"_blank\" rel=\"noopener\">this tutorial<\/a> for details.<\/strong><\/p>\n<p>&nbsp;<\/p>\n<h3>Step 1: Get Device Name or ID of External Disk Partition<\/h3>\n<p>First, search for and open the &#8220;<b>Disks<\/b>&#8221; tool from system app launcher.<\/p>\n<div id=\"attachment_43980\" style=\"width: 610px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/05\/open-disks.webp\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-43980\" class=\"size-large wp-image-43980\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/05\/open-disks-600x288.webp\" alt=\"\" width=\"600\" height=\"288\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/05\/open-disks-600x288.webp 600w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/05\/open-disks-300x144.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/05\/open-disks.webp 715w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><p id=\"caption-attachment-43980\" class=\"wp-caption-text\">Launch Disk<\/p><\/div>\n<p>When it opens, select the disk in left pane, and highlight the desired file partition in right. There, copy or write down the Device name (usually \/dev\/xxx), and UUID.<\/p>\n<p>In my case, I need to get the info about:<\/p>\n<ul>\n<li>UUID: 428E68968EE68846F<\/li>\n<li>Device name: \/dev\/nvme0n1p2<\/li>\n<li>file system type: NTFS (optional)<\/li>\n<\/ul>\n<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/05\/mount-disk-info.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-43981\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/05\/mount-disk-info-600x358.webp\" alt=\"\" width=\"600\" height=\"358\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/05\/mount-disk-info-600x358.webp 600w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/05\/mount-disk-info-300x179.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/05\/mount-disk-info-768x459.webp 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/05\/mount-disk-info-1536x917.webp 1536w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/05\/mount-disk-info-1320x788.webp 1320w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/05\/mount-disk-info.webp 1904w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><\/p>\n<p>In case, your Linux Distro does not have &#8220;Disks&#8221; utility or you&#8217;re running a Linux server. Open terminal and run command:<\/p>\n<pre>df -h<\/pre>\n<p>Then find out the disk partition name you want to auto-mount on startup. (NOTE: You need to mount the external disk first).<\/p>\n<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/05\/df-h.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-43983\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/05\/df-h-600x279.webp\" alt=\"\" width=\"600\" height=\"279\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/05\/df-h-600x279.webp 600w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/05\/df-h-300x139.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/05\/df-h-768x357.webp 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/05\/df-h-1320x613.webp 1320w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/05\/df-h.webp 1512w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><\/p>\n<h3>Step 2: Get the user\/group ID for current user<\/h3>\n<p>To auto-mount the external partition by using current user ownership, you also need to get the user ID and group ID.<\/p>\n<p>For the default user that created while installing Linux, the ID is usually <b>1000<\/b>. Just in case, open terminal and run command to get it:<\/p>\n<pre>id<\/pre>\n<div id=\"attachment_43982\" style=\"width: 610px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/05\/get-id.webp\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-43982\" class=\"size-large wp-image-43982\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/05\/get-id-600x362.webp\" alt=\"\" width=\"600\" height=\"362\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/05\/get-id-600x362.webp 600w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/05\/get-id-300x181.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/05\/get-id-768x463.webp 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/05\/get-id-1320x796.webp 1320w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/05\/get-id.webp 1436w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><p id=\"caption-attachment-43982\" class=\"wp-caption-text\">get user id<\/p><\/div>\n<h3>Step 3: Enable Auto-Mount Disk Partition via \/etc\/fstab<\/h3>\n<p>Now, you can edit the &#8220;<b>\/etc\/fstab<\/b>&#8221; file to do the auto-mount configuration that works in most Linux!<\/p>\n<p>To do so, open terminal and run command:<\/p>\n<pre>sudo gedit \/etc\/fstab<\/pre>\n<p><i>For Ubuntu 22.10+ and Fedora workstation, replace <code>gedit<\/code> with <code>gnome-text-editor<\/code>. For other Linux, either use your system text editor or <code>nano<\/code> that works in most Linux.<\/i><\/p>\n<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/05\/edit-fstab.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-43984\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/05\/edit-fstab-600x196.webp\" alt=\"\" width=\"600\" height=\"196\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/05\/edit-fstab-600x196.webp 600w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/05\/edit-fstab-300x98.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/05\/edit-fstab-768x251.webp 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/05\/edit-fstab-1536x503.webp 1536w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/05\/edit-fstab-1320x432.webp 1320w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/05\/edit-fstab.webp 1644w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><\/p>\n<p>When the file opens, <strong>add the new line in the bottom<\/strong>:<\/p>\n<pre>UUID_or_Device_Name  Mount_Point  File_system_type  Options\u00a0 0\u00a0 0<\/pre>\n<p>In my case, I can use:<\/p>\n<pre>\/dev\/nvme0n1p2 \/media\/ji\/sandisk  ntfs  defaults,uid=1000,gid=1000,umask=022  0  0<\/pre>\n<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/05\/fstab.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-43985\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/05\/fstab-600x383.webp\" alt=\"\" width=\"600\" height=\"383\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/05\/fstab-600x383.webp 600w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/05\/fstab-300x191.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/05\/fstab-768x490.webp 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/05\/fstab-1536x980.webp 1536w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/05\/fstab-1320x842.webp 1320w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/05\/fstab.webp 1922w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><\/p>\n<p><b>There are 6 parts in the new line separated with spaces. They are:<\/b><\/p>\n<ul>\n<li>Part 1: the device name or UUID. See yours via Step 1.<\/li>\n<li>Part 2: the mount point to access the external disk files. If you&#8217;ve associated your apps with the external disk files, it&#8217;s better to use the previous mount point (See screenshot in Step1).<\/li>\n<li>Part 3: the file system type of disk partition (e.g., ext4, fat, ntfs). Get it in step 1, or use &#8220;<b>auto<\/b>&#8221; to auto-detect.<\/li>\n<li>Part 4: mount options <b>separated with commas but NO space between them<\/b>. Here I use:\n<ul>\n<li>defaults &#8211; means rw (read &amp; write), auto (auto mount), exec, dev, etc. Run <code>man mount<\/code> to see more about it.<\/li>\n<li>uid &#8211; specify the owner.<\/li>\n<li>gid &#8211; specify the group<\/li>\n<li>umask &#8211; specify the permissions. The first 0 means read, write and execute permission for user, and the two number 2 mean read and execute permission for group\/others.<\/li>\n<\/ul>\n<\/li>\n<li>Part 5: Either to backup. Set 0 to not backup.<\/li>\n<li>Part 6: Either to check and repair file system. 0 for No.<\/li>\n<\/ul>\n<p>When done, save the file. For <code>nano<\/code> text editor, press <b>Ctrl+X<\/b>, type <b>y<\/b> and hit Enter to save it. And, the change will apply in next boot.<\/p>\n<h3>In addition<\/h3>\n<p>The <code>uid=1000,gid=1000,umask=022<\/code> section specify the ownership and permissions, but it only works for non-Linux file systems, such as NTFS, FAT, etc, disk partitions.<\/p>\n<p>If you&#8217;re going to auto-mount external partition with Linux file-system, such as Ext2\/3\/4, XFS, JFS, try to change the ownership manually after mount.<\/p>","protected":false},"excerpt":{"rendered":"<p>This tutorial shows how to automatically mount external disk partitions on startup of Ubuntu, Fedora, Debian, and most other Linux. I bought a new SSD recently. Now, I have 2 solid-state drives (SSDs) connected on my computer. Ubuntu 22.04 is installed on one SSD drive, while another one contains VirtualBox Virtual Machine files. As result, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":43665,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[2080],"class_list":["post-43979","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-howtos","tag-file-system"],"_links":{"self":[{"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/posts\/43979","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/comments?post=43979"}],"version-history":[{"count":0,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/posts\/43979\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/media\/43665"}],"wp:attachment":[{"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/media?parent=43979"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/categories?post=43979"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/tags?post=43979"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}