Reading Time: 2 minutes
Wanna use USB HDD with Raspberry Pi 4!
I guess microSD is less reliability…
With this article you can automatically use USB HDD to Raspberry Pi 4 when system starts!
Perhaps you will face obstacle when you want to store some data.
Usually Raspberry Pi OS is installed on microSD but microSD is less reliability than HDD.
You can replace “reliability” as 2 words.
- Highly fault torelant Data or storage device will work even if sudden power cut happens. - Durability You can read/write in long period.
I have done some stuff so my USB HDD is automatially mounted when system starts.
Let me share how to do it.
Thing is very simple, you just need to add USB HDD information and where to mount to /etc/fstab.
Let’s take a look last line which I added.
$ vim /etc/fstab proc /proc proc defaults 0 0 PARTUUID=0d91114b-01 /boot vfat defaults 0 2 PARTUUID=0d91114b-02 / ext4 defaults,noatime 0 1 a swapfile is not a swap partition, no line here use dphys-swapfile swap[on|off] for that /dev/disk/by-uuid/680204DA0204AEDE /mnt/usb-hdd ntfs uid=1001,gid=1001 0 0 # Added
You can find verious styles/options how to write/update fstab file.
In my case I use this format.
<UUID> <where to mount> <file system> <mount option> <dump option> <fsck option>
UUID is unique ID which is assigned each device/partition.
You can find UUID when USB HDD is connected.
You need to ignore case with “mmcblk” because they are microSD.
In this example 680204DA0204AEDE is UUID of sda1 which is the first partition of USB HDD.
$ ls -l /dev/disk/by-uuid/ total 0 lrwxrwxrwx 1 root root 9 Apr 26 18:48 66504944-69e7-30a5-b103-10dc818d1b50 -> ../../sda lrwxrwxrwx 1 root root 10 Apr 26 18:48 680204DA0204AEDE -> ../../sda1 lrwxrwxrwx 1 root root 15 Apr 26 18:48 b3ce35cd-ade9-4755-a4bb-1571e37fc1b9 -> ../../mmcblk0p2 lrwxrwxrwx 1 root root 15 Apr 26 18:48 EBBA-157F -> ../../mmcblk0p1
It is easy to fill till file system.
<mount option> is option when you specify, let’s say.
I input user ID/group ID because I want to read/write from my user.
I haven’t used <dump option> , so let me skip…
System will add check by fsck if you activate <fsck option>.
If description is okay then reboot system.
Then you should see USB HDD is automatically mounted with your UID/GID.
yasu@raspberrypi:~ $ ls -l /mnt/ total 4 drwxrwxrwx 1 yasu yasu 4096 Mar 21 19:58 usb-hdd
How was it?
HDD/SDD is neccessary when you want to use Raspberry Pi as server.
I look forward to be helpful for you!