odroid-xu4:software:ubuntu_nas:02_mount_hdds

Mount HDDs

We use autofs program for preventing from a potential boot problem caused when you turn on your ODROID without the HDDs registered in /etc/fstab.
With autofs, you can detach connected HDDs without any editable settings.

Or you can use usbmount program to mount/un-mount USB connected drives automatically. In an ODROID, including ODROID-HC1, all of the connectable HDDs are connected via USB method.
But sometimes usbmount mounts the drives to different directory unlike previous mount points, so we recommend to use autofs if you connect two or more HDDs into your ODROID.

  • Before proceed, make sure that your HDD has formatted as an EXT4 file system.

Install autofs package.

target
$ sudo apt install autofs

Create based mount directory for the HDDs.

target
$ sudo mkdir -p /media/nas

Edit autofs settings file.

  • We recommend to use vim for edit files.
target
$ sudo apt install vim
target
$ sudo vi /etc/auto.master

Copy below line and paste it under the “#/misc /etc/auto.misc” line:

/media/nas /etc/auto.ext --timeout 20

To use autofs, you need to know your HDD's UUID. Let's find out.

target
$ ls -al /dev/disk/by-uuid
# results 
total 0
drwxr-xr-x 2 root root 100 Oct 10 17:04 .
drwxr-xr-x 7 root root 140 Oct 10 17:04 ..
lrwxrwxrwx 1 root root  15 Oct 10 17:04 52AA-6867 -> ../../mmcblk1p1
lrwxrwxrwx 1 root root  15 Oct 10 17:04 e139ce78-9841-40fe-8823-96a304a09859 -> ../../mmcblk1p2
lrwxrwxrwx 1 root root  10 Oct 10 17:05 fb028ad6-097a-494d-9d87-d055b8f8c359 -> ../../sda1

Remember sda1's UUID. Mine is “fb028ad6-097a-494d-9d87-d055b8f8c359”. If you use two or more HDDs or partitions, remember all of them (sdb1, sdc1 or sda2, … and so on).
Create autofs mapping file.

target
$ sudo vi /etc/auto.ext

Copy and paste below.

hdd1 -fstype=ext4,rw,noatime,data=journal,commit=1 :/dev/disk/by-uuid/your-hdd-uuid-here
 
# If you want to add the other HDDs, just write it referring to the format above.
hdd2 -fstype=ext4,rw,noatime,data=journal,commit=1 :/dev/disk/by-uuid/second-hdd-uuid
hdd3 -fstype=ext4,rw,noatime,data=journal,commit=1 :/dev/disk/by-uuid/third-hdd-uuid

Then restart autofs service.

target
$ sudo service autofs restart

And if you access the directories you set into the auto.ext, you can see the contents.
Remember that autofs mounts the drives when you access the directory.

target
odroid@odroid:~$ ls -al /media/nas/
total 4
drwxr-xr-x 2 root root    0 Oct 10 17:05 .
drwxr-xr-x 4 root root 4096 Oct 10 16:33 ..
odroid@odroid:~$ ls -al /media/nas/hdd1
total 20
drwxr-xr-x 3 root root  4096 Oct 10 16:56 .
drwxr-xr-x 3 root root     0 Oct 10 17:19 ..
drwx------ 2 root root 16384 Oct 10 16:56 lost+found
odroid@odroid:~$ ls -al /media/nas/
total 8
drwxr-xr-x 3 root root    0 Oct 10 17:19 .
drwxr-xr-x 4 root root 4096 Oct 10 16:33 ..
drwxr-xr-x 3 root root 4096 Oct 10 16:56 hdd1
odroid@odroid:~$ df -Th
Filesystem     Type      Size  Used Avail Use% Mounted on
udev           devtmpfs  931M     0  931M   0% /dev
tmpfs          tmpfs     200M  8.7M  191M   5% /run
/dev/mmcblk0p2 ext4       29G  1.2G   28G   5% /
tmpfs          tmpfs     999M     0  999M   0% /dev/shm
tmpfs          tmpfs     5.0M     0  5.0M   0% /run/lock
tmpfs          tmpfs     999M     0  999M   0% /sys/fs/cgroup
/dev/mmcblk0p1 vfat      128M   11M  118M   8% /media/boot
tmpfs          tmpfs     200M     0  200M   0% /run/user/0
/dev/sda1      ext4      917G   72M  871G   1% /media/nas/hdd1

Change NAS directories's ownership.

target
$ sudo chown -R your-user-name:your-group-name /media/nas
  • odroid-xu4/software/ubuntu_nas/02_mount_hdds.txt
  • Last modified: 2017/12/18 17:41
  • by joshua