Hotplug USB? Which command?

Hi guys,
i'm running my media server over openwrt. Minidlna.

I'm very satisfied. My usb drive is mounted and it works. But when i unplug it and plug it again it wont detect it anymore. I need to restart openwrt and force a reboot to scan and detect my mediafiles again.

Is there any way to type a command to detect plugged in Usb drives while everything is working?

Hope someone can give me a helpfull answer.

Try this command:

service fstab boot

what does this excatly do ? Reboot or detect immediatly new sda?

# grep -A2 boot /etc/init.d/fstab 
boot() {
	/sbin/block mount

# uci show fstab

There's also

# cat /etc/hotplug.d/block/10-mount 
/sbin/block hotplug

thanks but a little bit hard to understand.

my usb is called GREENDISK

could you help me to paste the right command?

do i have to paste the command every time when i hotplug it onto my router? before plugging or after plugging it ? I formated NTFS. Will it work?

Follow the guide to create fstab entry for your drive:

No, use f2fs

NTFS has some sort of issues which make it harder for the USB/Drive to get mounted at boot properly. For me even adding the entry to fstab did not work and I always need to mount it through /etc/rc.local. I am not really sure why this happens but ext4 works flawlessly without any problem. @trendy Can Windows detect f2fs if I plug my external drive into Windows?

I have my media for minidlna on a ntfs drive too and do the same thing as @ahmar16, mount it through /etc/rc.local, once minidlna has scanned all the files i disable minidlna (system>startup>minidlna>disable) and add /etc/init.d/minidlna start to /etc/rc.local under the mount command for the ntfs drive, that way when the router is rebooted the drive mounts and then minidlna starts and should see all the files without having to rescan. It's not as convenient as hot plug, but better than nothing if you have to use ntfs.

1 Like

I am now little bit confused. Everthing works well and flawlessly. But if i unplug it and plug it soon it wont detect anymore.I need to reboot the openwrt Os. What is the most easiest way to perform this?

According to wikipedia, no.

However you could transfer the files over the network and not worry about that.

Yes the whole point of setting up a file server is so you no longer need to physically "sneakernet" your disks around.

1 Like

Yes only if transferring files didn't depend on the power of cpu and so wifi could actually provide 30 mb/s to transfer a file as large as 60 Gbs as quickly as possible.

Because right now I only get 3 mb/s on my BT HH5A.

A lot of that is because the format is NTFS. The Linux NTFS driver is very slow. A Linux-native filesystem will be a lot faster. Use ext4 if it's a mechanical disk or f2fs for a flash-based drive.

1 Like

Yes I was using ext4 before but I was only able to transfer files at 3/4 mb/s via wifi and 5 mb/s through lan cable. But then I had to transfer a 60 Gbs file and it was taking ages so I physically connected the drive, couldn't copy the file because windows does not understand ext4 file system so then after a long search on internet I found a software that was able to transfer files.
In the end I just switched to ntfs because it seemed right. While the 200mb partition on the drive for ExtRoot is still ext4 because I don't need to access it in my pc.

You can also use vfat (FAT32) to access the device both from openwrt or windows.

The main drawback of this filesystem is not be able to create files which are bigger than 3 Gbs.

I would not expect more from a 500MHz CPU that has to route traffic and write on USB at the same time.
You have a router there, not a NAS.


Please be more specific, provide some logs. What exactly can you see in the syslog after connecting hard drive for the first time? What do you see after disconnecting it? What do you see after connecting it again?

Which OpenWrt release do you use?

Also be careful with unplugging. I unplugged a few times (without mounting) and the NTFS of the HDD got partially corrupted (had to fix it with chkdsk).