How To Automatically mount hfsplus drives as read/write on Centos 7

With the hfsplus utils package installed, external hfsplus drives (eg USB sticks) are mounted automatically on my Centos 7 box, which is very nice. However it would be super useful to have the mount read/write instead of read only. I can’t seem to find any definitive help on google, it’s usually people wanting to mount the same drive so they get told to put an entry in fstab. However the use case is a collaborative/creative media environment and many different drives will be coming in and out.

Presumably there’s some way of telling the kernel to force read/write mount of hfsplus drives…how do I do this? Unfortunately my extensive googling hasn’t got me anywhere on this one. Thanks in advance.

From Linux kernel message:

hfsplus: write access to a journaled filesystem is not supported, use the force option at your own risk, mounting read-only.

This is risky and hence not supported. So you need to do it manually (this might damage the files):

df -t hfsplus

You will something as follows:

Filesystem     1K-blocks   Used Available Use% Mounted on
/dev/sda1       15982592 218456  15764136   2% /media/vivek/mac

Then you do the following to mount all in rewrite mode:

sudo mount --all -o remount,rw,force,user,auto -t hfsplus

However, root user must be used to write again:

cd /media/vivek/mac
sudo mkdir foo
sudo cp /some/dir/file.mp4 foo/

Linux kernel option

Typically all options are set in /etc/modprobe.d/hfsplus.conf file. Create a new file

sudo vim /etc/modprobe.d/hfsplus.conf

Append:

options hfsplus force

Then reboot it. It may or may not work as this is a very risky operation (hence read-only by default). I never tried out. See all options Macintosh HFSPlus Filesystem for Linux — The Linux Kernel documentation

Thanks for your reply. I created the hfsplus.conf file in /etc/modprobe.d with “options force” line. /var/log/messages reports

libkmod: kmod_config_parse: /etc/modprobe.d/hfsplus.conf line 1: ignoring bad line starting with 'options'

I changed the hfsplus.conf file to read

options hfsplus force

And then the error message changes to

kernel: hfsplus: unknown paramater 'force' ignored

Which doesn’t seem to agree with the hfsplus manual page you posted, or using the mount -o command to force rw. Is it just the syntax that’s wrong?

Looking in the /sys/module/hfsplus folder, I can see that no parameter folder exists, as it does in other loaded kernel objects. So I’m guessing that the force option can’t be called by the kernel when it tries to load the hfsplus ko for some reason.

I fixed the options line. The docs says for Linux kernel version 5.14.0. Are you using the Linux kernel version 5.14.0? These things are depends upon kernel version a lot.

Ahh, we’re using 5.4.112-1. I wonder if that’s it?

As per my earlier reply, I already tried the line

options hfsplus force

and it returns

kernel: hfsplus: unknown paramater 'force' ignored

I get the same error using kernel 4.4.239-1.

It’s possible the hfsplus driver was installed and the kernel updated afterwards. Is it worth uninstalling/reinstalling?

I don’t think so it is worth it, but YMMV (there is a good reason why they disable writing by default). Just use the mount command as explained earlier. CentOS 7 is a long-term (LTS) release, and installing an updated kernel means two things:

  1. You have to compile and keep kernel updated to fix security issues manually, instead of running ‘yum update’
  2. Second, other things might break due to your custom kernel.

I hope this helps.


Linux sysadmin blog - Linux/Unix Howtos and Tutorials - Linux bash shell scripting wiki