Mount read-write HFS+ drive in OpenWRT

hfs+mountopenwrt

I attached an 'old' SSD drive that I removed from my Mac, to my Turris Omnia via one of its two USB 3 ports.

While I've been able to mount the device, it's in read-only mode. I can't seem to mount it in read/write mode.

Steps:

identifying the drive:

root@turris:/# fdisk -l

Disk /dev/mtdblock0: 1 MiB, 1048576 bytes, 2048 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/mtdblock1: 7 MiB, 7340032 bytes, 14336 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/mmcblk0: 7.3 GiB, 7818182656 bytes, 15269888 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: 0x77f5941d

Device         Boot Start      End  Sectors  Size Id Type
/dev/mmcblk0p1       2048 15269887 15267840  7.3G 83 Linux

Disk /dev/mmcblk0boot1: 4 MiB, 4194304 bytes, 8192 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/mmcblk0boot0: 4 MiB, 4194304 bytes, 8192 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: 465.9 GiB, 500277790720 bytes, 977105060 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: gpt 
Disk identifier: 6FD6A401-727C-43A0-92A5-XXXXXXXXXX

Device      Start       End   Sectors   Size Type
/dev/sda1      40    409639    409600   200M EFI System
/dev/sda2  409640 976842879 976433240 465.6G Apple HFS/HFS+

mounting the drive:

root@turris:/# mount -t hfsplus /dev/sda2 /mnt/jetdrive

listing drive's contents:

root@turris:/# ls -al /mnt/jetdrive
drwxrwxr-x    1 root     root            13 Nov 13 10:07 .
drwxr-xr-x    1 root     root            44 Nov 13 20:37 ..
-rw-r--r--    1 99       99           10244 Nov 13 10:10 .DS_Store
dr-xr-xr-t    1 root     root             2 Nov 13 10:06 .HFS+ Private Directory Data?
drwx------    1 99       99               5 Nov 13 10:06 .Spotlight-V100
drwx------    1 99       99               5 Nov 13 10:11 .fseventsd
----------    1 root     root      41943040 Nov 13 10:06 .journal
----------    1 root     root          4096 Nov 13 10:06 .journal_info_block
drwxr-xr-x    1 99       99               5 Nov 13 10:10 Music
drwxr-xr-x    1 99       99               4 Nov 13 10:09 Pictures

create a file:

root@turris:/mnt# touch /mnt/jetdrive foobar
touch: /mnt/jetdrive: Read-only file system

I tried the approach listed in this answer, but that causes problems:

root@turris:/mnt# mount -t hfsplus -o remount,rw /dev/sda2 /mnt/jetdrive
mount: /mnt/jetdrive not mounted or bad option

       In some cases useful info is found in syslog - try
       dmesg | tail or so.

What am I doing wrong? Can a HFS+ drive be mounted in a read/write manner?

Best Answer

My HFS+ drive would only remount as read-only (ro) after a power-loss. You can see this in the boot logs:

dmesg | grep hfsplus
# [    8.421832] hfsplus: Filesystem was not cleanly unmounted, running fsck.hfsplus is recommended.  mounting read-only.

I resolved this by adding a small script to /etc/rc.local to unmount, run fsck.hfsplus and remount on startup. Works like a charm.

{
    echo "*** Mounted dirs *************************"
    ls /mnt
    echo "*** Unmounting disk **********************"
    umount /mnt/samsungT5
    echo "*** Performing fsck **********************"
    fsck.hfsplus /dev/sda1
    echo "*** Remounting disk **********************"
    mount -t hfsplus -o rw /dev/sda1 /mnt/samsungT5
    echo "*************************"
} 2>&1 > /tmp/rc.local.log
Related Question