Auto Mount External Drive at Startup in Ubuntu Server 22.04
I AM NOT TAKING ANY CHANCES OF MOUNTING ANYTHING. THERE IS A 2TB HARDWARE RAID-1 MIRROR THAT IS MOUNTED, AND I DON'T WANT THE 4TB USB SSD DRIVE TO CONFLICT WITH THAT WHEN THE SYSTEM REBOOTS. IT APPEARS THAT UBUNTU IS SWITCHING THE MOUNTS OF THE /SDA AND THE /SDB AFTER A REBOOT.
However, I will keep the documentation below until such time as I figure out how to do this without any conflicts, and amend the entire process accordingly.
See: https://developerinsider.co/auto-mount-drive-in-ubuntu-server-22-04-at-startup/
sudo mkdir /media/usbssd
~$ lsblk -o NAME,FSTYPE,UUID,MOUNTPOINTS NAME FSTYPE UUID MOUNTPOINTS loop1 squashfs /snap/core20/1950 loop2 squashfs /snap/lxd/24322 loop3 squashfs /snap/snapd/19361 loop4 squashfs /snap/snapd/19457 loop5 squashfs /snap/core20/1974 sda ├─sda1 ├─sda2 ext4 94e62aba-77a5-45db-a9ba-ca358fa589df /boot └─sda3 LVM2_member hXjBKC-htj8-a0Zn-El2e-C3Jk-Y24f-e3S0bN └─ubuntu--vg-ubuntu--lv ext4 0d6b481f-ec40-4951-b6d7-76ba4cde2dfb / sdb ├─sdb1 └─sdb2 sr0
How to Mount an External Drive on Ubuntu 22.04 Server
See: https://brightwhiz.com/how-to-mount-an-external-drive-on-ubuntu-22-04-server/
sudo fdisk -l
Disk /dev/loop1: 63.45 MiB, 66527232 bytes, 129936 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk /dev/loop2: 111.95 MiB, 117387264 bytes, 229272 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk /dev/loop3: 53.26 MiB, 55844864 bytes, 109072 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk /dev/loop4: 53.26 MiB, 55844864 bytes, 109072 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk /dev/loop5: 63.45 MiB, 66531328 bytes, 129944 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk /dev/sda: 1.82 TiB, 1999844147200 bytes, 3905945600 sectors Disk model: Virtual Disk Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disklabel type: gpt Disk identifier: 299F1292-7D64-4846-83BD-CF8BD5034D74 Device Start End Sectors Size Type /dev/sda1 2048 4095 2048 1M BIOS boot /dev/sda2 4096 4198399 4194304 2G Linux filesystem /dev/sda3 4198400 3905943551 3901745152 1.8T Linux filesystem Disk /dev/mapper/ubuntu--vg-ubuntu--lv: 1.82 TiB, 1997692469248 bytes, 3901743104 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes The backup GPT table is corrupt, but the primary appears OK, so that will be used. Disk /dev/sdb: 3.81 TiB, 4194304000000 bytes, 1024000000 sectors Disk model: UDisk Units: sectors of 1 * 4096 = 4096 bytes Sector size (logical/physical): 4096 bytes / 4096 bytes I/O size (minimum/optimal): 4096 bytes / 4096 bytes Disklabel type: gpt Disk identifier: AB3F7F29-78F9-46D2-90C7-B2FC88C5E922 Device Start End Sectors Size Type /dev/sdb1 6 4095 4090 16M Microsoft reserved /dev/sdb2 4096 1023999993 1023995898 3.8T Microsoft basic data
How to mount an exFAT drive on Ubuntu - Article from Year 2019
See: https://www.fosslinux.com/17725/how-to-mount-an-exfat-drive-on-ubuntu.htm
Ubuntu by default does not provide support for the exFAT filesystem. But what about the latest LTS Ubuntu version 22.04? Does it already have exFAT utils?
Enabling exFAT support on Ubuntu 22.04
See: https://unixcop.com/enabling-exfat-support-on-ubuntu-22-04/
Previously, installing the exfat-utils package on Ubuntu was enough. But now it is not. This package is no longer maintained and has been replaced by another one.
First, open a terminal or connect via ssh and update the server
sudo apt update sudo apt upgrade
After that, you can install the exfatprogs package, which is maintained by Samsung engineers.
So, install the package:
sudo apt install exfatprogs
So, this is the new way to add exFAT support to Ubuntu 22.04. It is more robust, stable and with better results than the previous one.
Here are the results of running the installation of exfatprogs
sudo apt install exfatprogs Reading package lists... Done Building dependency tree... Done Reading state information... Done The following NEW packages will be installed: exfatprogs 0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded. Need to get 40.3 kB of archives. After this operation, 151 kB of additional disk space will be used. Get:1 http://us.archive.ubuntu.com/ubuntu jammy/universe amd64 exfatprogs amd64 1.1.3-1 [40.3 kB] Fetched 40.3 kB in 0s (171 kB/s) Selecting previously unselected package exfatprogs. (Reading database ... 156168 files and directories currently installed.) Preparing to unpack .../exfatprogs_1.1.3-1_amd64.deb ... Unpacking exfatprogs (1.1.3-1) ... Setting up exfatprogs (1.1.3-1) ... Processing triggers for man-db (2.10.2-1) ... Scanning processes... Scanning processor microcode... Scanning linux images... Running kernel seems to be up-to-date. The processor microcode seems to be up-to-date. No services need to be restarted. No containers need to be restarted. No user sessions are running outdated binaries. No VM guests are running outdated hypervisor (qemu) binaries on this host.
To make sure that the whole process went well, reboot the server
sudo reboot now
Run the Fdisk again:
sudo fdisk -l
Disk /dev/loop0: 111.95 MiB, 117387264 bytes, 229272 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/loop1: 53.26 MiB, 55844864 bytes, 109072 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/loop2: 53.26 MiB, 55844864 bytes, 109072 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/loop3: 63.45 MiB, 66527232 bytes, 129936 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/loop4: 63.45 MiB, 66531328 bytes, 129944 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes The backup GPT table is corrupt, but the primary appears OK, so that will be used.
Disk /dev/sda: 3.81 TiB, 4194304000000 bytes, 1024000000 sectors Disk model: UDisk Units: sectors of 1 * 4096 = 4096 bytes Sector size (logical/physical): 4096 bytes / 4096 bytes I/O size (minimum/optimal): 4096 bytes / 4096 bytes Disklabel type: gpt Disk identifier: AB3F7F29-78F9-46D2-90C7-B2FC88C5E922
Device Start End Sectors Size Type /dev/sda1 6 4095 4090 16M Microsoft reserved /dev/sda2 4096 1023999993 1023995898 3.8T Microsoft basic data
Disk /dev/sdb: 1.82 TiB, 1999844147200 bytes, 3905945600 sectors Disk model: Virtual Disk Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disklabel type: gpt Disk identifier: 299F1292-7D64-4846-83BD-CF8BD5034D74
Device Start End Sectors Size Type /dev/sdb1 2048 4095 2048 1M BIOS boot /dev/sdb2 4096 4198399 4194304 2G Linux filesystem /dev/sdb3 4198400 3905943551 3901745152 1.8T Linux filesystem
Disk /dev/mapper/ubuntu–vg-ubuntu–lv: 1.82 TiB, 1997692469248 bytes, 3901743104 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes </code>
So, this part of the above results looks like the external USB SSD drive we want to mount, and automount:
Disk /dev/sda: 3.81 TiB, 4194304000000 bytes, 1024000000 sectors Disk model: UDisk Units: sectors of 1 * 4096 = 4096 bytes Sector size (logical/physical): 4096 bytes / 4096 bytes I/O size (minimum/optimal): 4096 bytes / 4096 bytes Disklabel type: gpt Disk identifier: AB3F7F29-78F9-46D2-90C7-B2FC88C5E922 Device Start End Sectors Size Type /dev/sda1 6 4095 4090 16M Microsoft reserved /dev/sda2 4096 1023999993 1023995898 3.8T Microsoft basic data
It does not specify that this USB SSD Drive is exFat, but I know it to exFat by connecting it to a Windows system and looking at its format.
I believe that we need to mount /dev/sda2 which is the 4TB (3.8TB) external USB SSD drive. And it appears that the Disk Identifier is:
AB3F7F29-78F9-46D2-90C7-B2FC88C5E922
BEWARE THERE ARE MIXED READINGS NOW! LOOK AT THIS BELOW AND COMPARE
lsblk -o NAME,FSTYPE,UUID,MOUNTPOINTS
Results:
NAME FSTYPE UUID MOUNTPOINTS loop0 squashfs /snap/lxd/24322 loop1 squashfs /snap/snapd/19457 loop2 squashfs /snap/snapd/19361 loop3 squashfs /snap/core20/1950 loop4 squashfs /snap/core20/1974 sda ├─sda1 └─sda2 sdb ├─sdb1 ├─sdb2 ext4 94e62aba-77a5-45db-a9ba-ca358fa589df /boot └─sdb3 LVM2_member hXjBKC-htj8-a0Zn-El2e-C3Jk-Y24f-e3S0bN └─ubuntu--vg-ubuntu--lv ext4 0d6b481f-ec40-4951-b6d7-76ba4cde2dfb / sr0
I AM NOT TAKING ANY CHANCES OF MOUNTING ANYTHING. THERE IS A 2TB HARDWARE RAID-1 MIRROR THAT IS MOUNTED, AND I DON'T WANT THE 4TB USB SSD DRIVE TO CONFLICT WITH THAT WHEN THE SYSTEM REBOOTS. IT APPEARS THAT UBUNTU IS SWITCHING THE MOUNTS OF THE /SDA AND THE /SDB AFTER A REBOOT.