I am trying to create an automated mount for an external hard drive, but it keeps failing. I am a little newbiew at linux.

I have googled and searched in StackExchange and I tried a lot of things, but I did not find a solution for my problem.

OS: Raspbian Stretch

Those are the steps I did:

Format external drive to ext4

sudo mkfs.ext4 /dev/sda1 -L hdd_moc
mke2fs 1.43.4 (31-Jan-2017)
/dev/sda1 contains a ext4 file system labelled 'hdd_owncloud'
    last mounted on Mon Feb 12 09:34:38 2018
Proceed anyway? (y,N) y
Creating filesystem with 244181760 4k blocks and 61046784 inodes
Filesystem UUID: b9b47e44-db76-40de-a0ed-940c9699799a
Superblock backups stored on blocks:
    32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
    4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968,
    102400000, 214990848

Allocating group tables: done
Writing inode tables: done
Creating journal (262144 blocks): done
Writing superblocks and filesystem accounting information: done   

Create directory for mounted external usb drive

sudo mkdir /mnt/hdd_moc

Create the www-data user to the group

sudo groupadd www-data
sudo usermod -a -G www-data www-data

Give permissions

sudo chown -R www-data:www-data /mnt/hdd_moc
sudo chmod -R 775 /mnt/hdd_moc
ls -l /mnt
total 4
drwxrwxr-x 2 www-data www-data 4096 Feb 12 10:06 hdd_moc

Get the gid, uid and uuid

id -g www-data
id -u www-data
ls -l /dev/disk/by-uuid
total 0
lrwxrwxrwx 1 root root 15 Feb 12 09:49 9a7608bd-5bff-4dfc-ac1d-63a956744162 -> ../../mmcblk0p2
lrwxrwxrwx 1 root root 15 Feb 12 09:49 B60A-B262 -> ../../mmcblk0p1
lrwxrwxrwx 1 root root 10 Feb 12 10:12 b9b47e44-db76-40de-a0ed-940c9699799a -> ../../sda1

Give the instruction to fstab

sudo nano /etc/fstab

proc            /proc           proc    defaults          0       0
PARTUUID=ed7ab5b3-01  /boot           vfat    defaults          0       2
PARTUUID=ed7ab5b3-02  /               ext4    defaults,noatime  0       1
UUID=b9b47e44-db76-40de-a0ed-940c9699799a /mnt/hdd_moc auto nofail,uid=33,gid=33,umask=0027,dmask=0027,noatime 0 0

Automated mount test

sudo mount -a
mount: wrong fs type, bad option, bad superblock on /dev/sda1,
   missing codepage or helper program, or other error

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

Normal mount test

sudo mount /dev/sda1 /mnt/hdd_moc -> It works, I can do a "ls".

So I think my problem is in the 4th line of fstab. I readed fstab info but I can not understand what I should do. (https://wiki.debian.org/fstab)

Thank you :)

  • 2
    Have you tried mounting the drive with all of the options that you provided to fstab? Checking the mount(5) and ext4(5) man pages, I'm not sure that all of the options are applicable to an ext4 partition (uid, gid, umask and dmask); as well, since you know what the filesystem is, why are you using auto as the filesystem type?
    – ErikF
    Feb 12, 2018 at 11:14
  • @ErikF yep, that's right. uid, gid, umask, and dmask are not valid options for ext4. The /etc/fstab entry should be UUID=b9b47e44-db76-40de-a0ed-940c9699799a /mnt/hdd_moc ext4 defaults,nofail,noatime 0 0. You should write up your comment as an answer.
    – cas
    Feb 12, 2018 at 11:23

1 Answer 1


You're overcomplicating things. The fact that the command

sudo mount /dev/sda1 /mnt/hdd_moc

works correctly shows you that your system is able to mount a ext4 filesystem without specific options. In fact, ext4 is one of the most common fs for Linux (if not the most one).

The mount options you're trying to use don't exist for ext4 fs. All you need to do is to rewrite the relevant /etc/fstab line as such:

UUID=b9b47e44-db76-40de-a0ed-940c9699799a  /mnt/hdd_moc  ext4  defaults,nofail,noatime  0 0

You must log in to answer this question.

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