Raspberry Pi : Auto-Mount USB Stick or SSD Disk

Posted by: Admin

Raspberry Pi : Auto-Mount USB Stick or SSD Disk - 06/05/20 10:56 PM

Raspberry Pi : Auto-Mount USB Stick or SSD Disk
(Be Aware, SSD Disk uses a lot of Amp, so it would need to be on an external powered USB Hub !, but now you can find 64, 128 or 256 Gb Usb Sticks that would be far enough)

root@ubuntu:~# fdisk -l
Disk /dev/sda: 58.9 GiB, 63216549888 bytes, 123469824 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
Disklabel type: dos
Disk identifier: 0x6f20736b

Device Boot Start End Sectors Size Id Type
/dev/sda1 2048 123469823 123467776 58.9G 83 Linux

- blkid
to get the UUID (exemple below, UUID=5C24-1453)

- fdisk
Command fdisk -l to list
Command fdisk /dev/sda to manage the disk
then p and d commands to partition and delete partitions.

with fdisk /dev/sda and command t, then 83 to Linux and w...

Device Boot Start End Sectors Size Id Type
/dev/sda1 2048 489160703 489158656 233.3G 7 HPFS/NTFS/exFAT
to
Device Boot Start End Sectors Size Id Type
/dev/sda1 2048 489160703 489158656 233.3G 83 Linux


- Format partition
mkfs.ext4 /dev/sda1

- Auto-Mounting command in fstab
UUID=5C24-1453 /mnt/mydisk FSTYPE defaults,auto,users,rw,nofail 0 0

If the filesystem type is FAT or NTFS, add ,umask=000 immediately after nofail - this will allow all users full read/write access to every file on the storage device.

Exemples :
/dev/sda1 /media/usb ext4 defaults,auto,users,rw,nofail 0 0
UUID=5C24-1453 /media/usb ext4 defaults,auto,users,rw,nofail 0 0


- UnMount
umount /media/usb

References :
https://www.raspberrypi.org/documentation/configuration/external-storage.md