Page 1 of 2 12 LastLast
Results 1 to 15 of 17

Thread: usb drive switches from part1 to part2 (and vice versa) on reboot

  1. #1

    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
    Last edited by oggie; 05-12-2007 at 15:03.

  2. #2
    Join Date
    Feb 2007
    Location
    Moscow, Russia
    Posts
    3,805
    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:
    PHP Code:
    #!/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.
    Last edited by al37919; 05-12-2007 at 20:14.

  3. #3
    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!!

  4. #4
    Join Date
    Nov 2007
    Location
    EU's border...
    Posts
    71
    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.

  5. #5
    Join Date
    Mar 2007
    Location
    Milano - Italy
    Posts
    164
    Quote Originally Posted by Serpent View Post
    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

  6. #6
    Join Date
    Feb 2007
    Location
    Moscow, Russia
    Posts
    3,805
    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 ]
    Last edited by al37919; 05-12-2007 at 20:13.

  7. #7
    Join Date
    Mar 2007
    Location
    Milano - Italy
    Posts
    164
    Code:
    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

  8. #8
    Join Date
    Nov 2007
    Location
    EU's border...
    Posts
    71
    Sorry al37919, I don't want to argue with you, but I can't agree with you.
    Quote Originally Posted by al37919 View Post
    ... 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.
    Last edited by Serpent; 05-12-2007 at 21:19.

  9. #9
    Join Date
    Mar 2007
    Location
    Milano - Italy
    Posts
    164
    @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

  10. #10
    Join Date
    Nov 2007
    Location
    EU's border...
    Posts
    71
    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?

  11. #11
    Don't the drives also automount when the Samba Demo mode is enabled in Oleg's firmware?

  12. #12
    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.

  13. #13
    Join Date
    Mar 2007
    Location
    Milano - Italy
    Posts
    164
    Quote Originally Posted by Serpent View Post
    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

  14. #14
    Join Date
    Feb 2007
    Location
    Moscow, Russia
    Posts
    3,805
    /opt is always mounted manually, however, the usb drive is automounted in /tmp/harddisk

  15. #15
    Join Date
    Nov 2007
    Location
    EU's border...
    Posts
    71
    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.

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •