Bekijk de volledige versie : usb drive switches from part1 to part2 (and vice versa) on reboot
I have 2 usb drives of the same size attached to my wl500g premium.
If I make any changes and have to reboot the box, sometimes one of the drive is mounted under /tmp/harddisk/part1 and other times it's /tmp/harddisk/part2.
Obviously this is wreaking havoc on my mounted shares in the network since they've changed and the mounts are then broken till I fix it.
Is there any way to fix this?
Here's what I get when I run the mount command:
[admin@asus discs]$ mount
/dev/root on / type squashfs (ro)
none on /dev type devfs (rw)
proc on /proc type proc (rw)
ramfs on /tmp type ramfs (rw)
usbfs on /proc/bus/usb type usbfs (rw)
/dev/discs/disc0/part2 on /opt type ext3 (rw)
/dev/discs/disc0/part2 on /tmp/harddisk type ext3 (rw)
/dev/discs/disc0/part3 on /tmp/harddisk/part1 type ext3 (rw,noatime)
/dev/discs/disc0/part3 on /tmp/harddisk type ext3 (rw,noatime)
/dev/discs/disc1/part1 on /tmp/harddisk/part2 type ext3 (rw,noatime)
This is strange... why are the same parts mounted twice?
Here's what I get when I reboot and the mount changes:
[admin@asus harddisk]$ mount
/dev/root on / type squashfs (ro)
none on /dev type devfs (rw)
proc on /proc type proc (rw)
ramfs on /tmp type ramfs (rw)
usbfs on /proc/bus/usb type usbfs (rw)
/dev/discs/disc0/part2 on /opt type ext3 (rw)
/dev/discs/disc0/part3 on /tmp/harddisk type ext3 (rw,noatime)
/dev/discs/disc1/part1 on /tmp/harddisk/part1 type ext3 (rw,noatime)
The last one is how I expect it to look, but that's not always the case. The only mounting I do is in my post-boot file:
#!/bin/sh
dropbear -p 24
# test if USB disc has been attached
# if not - then insert needed modules
#
# uncoment the following 4 lines if using an USB HDD.
if [ ! -d /dev/discs ]
then
insmod scsi_mod && insmod sd_mod && insmod usb-storage && sleep 5s
fi
#Wait for /opt to mount
mount /dev/discs/disc0/part2 /opt
i=0
while [ $i -le 30 ]
do
if [ -d /opt/etc ]
then
break
fi
sleep 1
i=`expr $i + 1`
done
mount /dev/discs/disc0/part3 /tmp/harddisk
# Activate swap
swapon /dev/discs/disc0/part1
# Run all active services - active means starts with S
/opt/etc/init.d/rc.unslung
If I make any changes and have to reboot the box, sometimes one of the drive is mounted under /tmp/harddisk/part1 and other times it's /tmp/harddisk/part2.
This is a consequence of PnP. So, it's normal behavior.
IMHO you can do the following:
I'm not aware of the method how you can avoid automounting, therefore let it go through, after that in post-boot you unmount everything what was automounted (you may simply use all possible combinations of disc/part)
Then make some attempt and analyse result, and mount all the needed in the right places
So, finally you'll get something like this in your post-boot:
#!/bin/sh
dropbear
insmod scsi_mod 2> /dev/null && insmod sd_mod && insmod usb-storage
#Wait for hdd to spin-up
sleep 15s
umount /dev/discs/disc0/part1 2> /dev/null
umount /dev/discs/disc0/part2 2> /dev/null
umount /dev/discs/disc0/part3 2> /dev/null
umount /dev/discs/disc1/part1 2> /dev/null
umount /dev/discs/disc1/part2 2> /dev/null
umount /dev/discs/disc1/part3 2> /dev/null
# Let's make an attempt
if [ swapon /dev/discs/disc0/part1 2> /dev/null ] ;
then
mount /dev/discs/disc0/part2 /opt
mount /dev/discs/disc0/part3 /tmp/harddisk
mount /dev/discs/disc1/part1 /tmp/harddisk/part1
else
swapon /dev/discs/disc1/part1
mount /dev/discs/disc1/part2 /opt
mount /dev/discs/disc1/part3 /tmp/harddisk
mount /dev/discs/disc0/part1 /tmp/harddisk/part1
fi
# Run all active services - active means starts with S
/opt/etc/init.d/rc.unslung
I haven't tested this script, so it might need some tune up.
Especially check that all partitions are really unmounted.
I kind of figured that was the case and I would have to do what you suggested. But it didn't hurt to ask if there was another way.
I'll give it a go later today. Thanks for the input!!
Automounting is a direct consequence of stupid-ftp server.
If you simply disable it in:
Web interface -> USB Application -> Enable FTP Server? NO
your problem is solved, only what you specify in post-boot will be mounted.
But you will need to install another FTP Server, vsftp for example.
Automounting is a direct consequence of stupid-ftp server.
If you simply disable it in:
Web interface -> USB Application -> Enable FTP Server? NO
your problem is solved, only what you specify in post-boot will be mounted.
But you will need to install another FTP Server, vsftp for example.
A curiosity...
how can Asus distinguish during boot between /dev/discs/disc0/part1 and /dev/discs/disc1/part1 ?
Thanks, Max
Automounting is a direct consequence of stupid-ftp server.
Autoloading of usb disk drivers is a consequence of enabling the stupid-ftp server. If you disable it, you should add
insmod scsi_mod && insmod sd_mod && insmod usb-storage
to your post boot file to be able to recognize an usb drive. However, after it has been recognized it is automounted in both cases. So, it is not the way to solve the problem.
how can Asus distinguish during boot between /dev/discs/disc0/part1 and /dev/discs/disc1/part1 ?
Very easily, just put some unique files in the root of the both disks (e.g. disk1 and disk2), then make an attempt to mount disc0/part1 and check for the existence of this file with [ -e /opt/disk1 ]
Very easily, just put some unique files in the root of the both disks (e.g. disk1 and disk2), then make an attempt to mount disc0/part1 and check for the existence of this file with [ -e /opt/disk1 ]
Nice solution... in the next future I'll add to my router a second HDD as Media Storage for WizD server. I'd like to use it only for Media, leaving /opt on original HDD.
Max
Sorry al37919, I don't want to argue with you, but I can't agree with you.
... you should add
insmod scsi_mod && insmod sd_mod && insmod usb-storage
to your post boot file to be able to recognize an usb drive. However, after it has been recognized it is automounted in both cases. So, it is not the way to solve the problem...
First of all, oggie already has insmods in post-boot.
But the partition will be automounted (as /tmp/harddisk...) at boot time, or at USB drive connecting time, only if stupid-ftp is enabled. At least on my configuration...
I have checked this on my router. ;)
@serpent
my configuration were with stupid-ftp enabled to automount my HDD until past week. Then I changed my post-boot file to load 3 usb modules, and now my /opt is automounted correctly with stupid-ftp disabled.
Max
QMax, automount means "a partition which is automatically mounted
without any mount command (in post-boot)".
Your /opt is mounted by this command, from post-boot:
mount /dev/discs/disc0/partX /opt
Isn't true?
Don't the drives also automount when the Samba Demo mode is enabled in Oleg's firmware?
I have the ftp server disabled from the web admin page, and it's always been that way. I do have vsftpd installed however.
So even with the stupidftp disabled, I still get this mounting issue at boot.
QMax, automount means "a partition which is automatically mounted
without any mount command (in post-boot)".
Your /opt is mounted by this command, from post-boot:
mount /dev/discs/disc0/partX /opt
Isn't true?
You're right, I mount manually /opt.
I'll check what happens connecting my second HDD with stupidftp disabled.
Max
/opt is always mounted manually, however, the usb drive is automounted in /tmp/harddisk
Ok, if you say so, but this isn't true for my configuration.
Maybe Samba is also involved (as sebw suggested).
Anyway, this automount issue can be fixed with al37919's script.
Here's my modified post-boot which seems to work after doing a reboot:
#!/bin/sh
dropbear -p 24
# test if USB disc has been attached
# if not - then insert needed modules
#
# uncoment the following 4 lines if using an USB HDD.
if [ ! -d /dev/discs ]
then
insmod scsi_mod && insmod sd_mod && insmod usb-storage && sleep 5s
fi
sleep 10
umount /opt -l
umount /tmp/harddisk -l
swapon /dev/discs/disc0/part1
mount /dev/discs/disc0/part2 /opt
if [ -d /opt/etc ]
then
#looks like we mounted the right one
mount /dev/discs/disc0/part3 /tmp/harddisk
mount /dev/discs/disc1/part1 /tmp/harddisk/part1
else
#looks like we tried the wrong disk, so do the other one
swapon /dev/discs/disc1/part1
mount /dev/discs/disc1/part2 /opt
mount /dev/discs/disc1/part3 /tmp/harddisk
mount /dev/discs/disc0/part1 /tmp/harddisk/part1
fi
# Run all active services - active means starts with S
/opt/etc/init.d/rc.unslung
let's implement a simple check, you should have two files:
/etc/fstab.1 # first possibility
/etc/fstab.2 # second possibility
/usr/local/sbin/pre-mount script:
#!/bin/sh
# enlist disks and partitions
fdisk -l > /tmp/disk_parameters.log
# compare usb1 and usb2
now parse /tmp/disk_parameters.log for usb1 characteristics
if first
# first possibility
ln -s /etc/fstab.1 /etc/fstab
else second
# second possibility
ln -s /etc/fstab.2 /etc/fstab
and exit
I will post a real script when I buy my second USB flash disk.
Seff