Auto ext4 usb mount - how?

hi guys!

At each and every update my external usb is disappearing, and have to manually run the commands:
sudo mount /dev/sda1 /mnt/usb

This usually mounts the drive, but could i somehow automate this process? I checked all the related other topics, but it was so different (ntfs, etc.) or complicated, that i cannot really use that information.

Would somebody be able to help me how to simply enable the auto mounting for a drive, that is plugged in permanently to the raspberry pi2? (running latest osmc)

Thank you in advance!

Add it to your fstab.

Yeah, i saw this suggestion in other topics as well, but i have no idea what is this and how this should be done :frowning:

Your external drive should automatically mount itself in /media/DISKLABEL (where disk label is the name of the drive).


hi Sam!

Actually this is not happening. My media folder is empty. That’s why i’m trying to do something with command line, but no luck so far.

If i run this command, my usb is coming back (sudo mount /dev/sda1 /mnt/usb), but i don’t want to run it each and every time after reboot/upgrade.

I think it is more productive to investigate why automount is not working. A full set of logs should give some clues


Thank you. Here is the log: If i should run any other debugging please let me know. Thanks in advance.

How is your drive powered ? Do you hear a clicking noise ?

udisks-glue is not able to detect a valid partition on your disk, and when we automatically run a diagnostic command using blkid and fdisk -l, blkid reports nothing and fdisk reports that it doesn’t have permission to access the drive:

Aug 30 16:17:31 osmc udisks-glue[343]: Device file /dev/mmcblk0 inserted
Aug 30 16:17:31 osmc udisks-glue[343]: Device file /dev/sda inserted
Aug 30 16:17:31 osmc udisks-glue[343]: Device file /dev/sda1 inserted
Aug 30 16:17:31 osmc udisks-glue[343]: Device /dev/sda1 did not match any rules.
Aug 30 16:17:32 osmc udisks-glue[343]: fdisk: cannot open /dev/sda1: Permission denied

Can you provide the output of these commands with the drive connected please ?

ls -al /dev/sda*
blkid /dev/sda
blkid /dev/sda1
fdisk -l /dev/sda

hi @DBMandrake!

This is a single 2.0 usb pendrive (32gb, kingston data traveller), so i don’t hear any clicking noise obviously

Regarding the outputs, here you are:

osmc@osmc:~$ ls -al /dev/sda*
brw-rw---- 1 root disk 8, 0 Aug 30 16:17 /dev/sda
brw-rw---- 1 root disk 8, 1 Aug 30 16:17 /dev/sda1
osmc@osmc:~$ blkid /dev/sda
/dev/sda: PTTYPE="dos"
osmc@osmc:~$ blkid /dev/sda1
/dev/sda1: LABEL="usb" UUID="7b8c8cc4-1c07-43fe-9ecb-05a066880be3" TYPE="ext4"
osmc@osmc:~$ fdisk -l /dev/sda

Disk /dev/sda: 29.1 GiB, 31221153792 bytes, 60978816 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: 0x00000000

Device     Boot Start      End  Sectors  Size Id Type
/dev/sda1           2 60978815 60978814 29.1G 83 Linux


Try this

sudo apt-get install parted partprobe```

Post output of ```parted -s /dev/sda print | paste-log```

Temporarily, add

```/sbin/partprobe``` before exit 0 in /etc/rc.local

reboot and see if behaviour changes


hi Sam!

I did the sudo-apt-get update, but when i tried to run the second command, i got this:

osmc@osmc:~$ sudo apt-get install parted partprobe
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package partprobe


Sorry – partprobe is in parted. So you just need to install the parted package


hi Sam!

I added that to the rc.local file, and rebooted the rpi2, now it is coming up automatically!

Here is the output of the other command:

Should I do any other steps?

This is just a workaround and doesn’t fix the root cause of the problem. I’d like to fix this permanently and for other users too. It would be great if you could:

  • Remove that line from /etc/rc.local and add

perl -e require "sys/; ioctl('/dev/sda', 0x125f, 0)" instead

and report if the issue is still fixed. It will help me confirm the root cause.



Okie, so should it look like this? (sorry just don’t want to screw something)

I updated my post to use single quotes around /dev/sda. I’d recommend you do the same.

Nothing will break if you get the command wrong, it just won’t work.


hi Sam!

I can see the drive is appearing under /media now (/media/usb).

Anything else I should do, or that was it? (thanks for your help)

That is not a complete fix, but it will not break across updates. I need to discuss with @DBMandrake where we embed that ioctl so that we can handle it for all disks dynamically.

I would appreciate it if you kept track of this thread, as I suspect we’ll have something for you to test quite soon.


hi Sam!

Sure thing! Let me know, and i will check it for ya.

Thanks again!

I am encountering the same problem (can manually mount an ext4 disk, but it’s not happening automatically). Should this have been resolved? Are there any updates? :slight_smile: