3

I'm using a Raspberry with an external hard disk formatted in HFS+ and sometimes, for example after a power failure, the external hd is mounted only in read-only mode. In this case I run manually the following commands to remount in read-write:

sudo umount /dev/sda2 sudo fsck.hfsplus /dev/sda2 sudo mount -a

I'd like to run fsck.hfsplus every time at boot before /dev/sda2 is mounted automatically.

Currently in my /etc/fstab I have this configuration:

/dev/sda2 /media hfsplus force,rw,uid=osmc,gid=osmc 0 0

Which is the best way tu run fsck.hfsplus before mounting an external disk (HFS+)?

1 Answer 1

1

The normal way in Linux is to change the very last number of the fstab line from 0 to 2.

From the man page for fstab(5):

   The sixth field (fs_passno).
          This field is used by the fsck(8) program to determine the order
          in which filesystem checks are done at reboot  time.   The  root
          filesystem  should be specified with a fs_passno of 1, and other
          filesystems should have a fs_passno of 2.  Filesystems within  a
          drive will be checked sequentially, but filesystems on different
          drives will be checked at the same time to  utilize  parallelism
          available in the hardware.  If the sixth field is not present or
          zero, a value of zero is returned and fsck will assume that  the
          filesystem does not need to be checked.

I haven't used HFS, but I would expect it to automatically do an fsck after a sudden power loss, and also periodically. There may be a way to ask it to do an fsck every time, but I don't know what that is. For ext* filesystems you would use the tune2fs utility to do that.

1
  • Beautiful! Changing that 0 to 2 and rebooting fixed it for me. Thanks!
    – Dimitris
    Dec 18, 2017 at 21:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .