NSLU2-Linux
view · edit · print · history

Due to problems when two native formated drives are connected to the nslu2, I have tried to understand along the forums and the HowTo, how my slug can have this curious behaviour when rebooting.

In fact, two problems are distinct :

1- the 'conf' partition of the first disk on USB 1 is mounted two times :

   /dev/sdb2 on /share/hdd/conf
   /dev/sdb2 on /share/flash/conf

2- the samba server, due to the first problem, find two times the same file 'share.info' in the two mounted directories.

The result of that is to have duplicated shares with '~1' at the end for disk1 and no more shares for disk2...

I have found the begining of an answer here : HowTo.UseSharesOnTwoNativeDisksInUnslung68

But the mis-mounted partitions are already there and the risk to forget updating the backup file is important.

So, I have tried to create a little script to dismount and remount the 'conf' partitions in the good place.

I have wrote this and it make exactly what I want it make, but I do'nt know really where I have to put it to be executed at startup before samba begin to run.

#! /bin/sh
# Essai de rebricolage automatique des partitions mal montées
# try to automaticly repair mis-mounted partitions

# mount result after boot
#/dev/root on /initrd type jffs2 (rw)
#/dev/sdb1 on / type ext3 (rw)
#proc on /proc type proc (rw)
#usbdevfs on /proc/bus/usb type usbdevfs (rw)
#/dev/sda1 on /share/flash/data type ext3 (rw)
#/dev/sdb1 on /share/hdd/data type ext3 (rw)
#/dev/sdb2 on /share/hdd/conf type ext3 (rw,sync)          ]  2 times the same partition -> sharing errors
#/dev/sdb2 on /share/flash/conf type ext3 (rw,sync)        ]  2 fois la même partition -> erreurs de partage

#
# d'abord demonter tout à la barbare
# first all unmounting like Mc GYVER

umount -f /dev/sdb2
umount -f /dev/sdb2


#
# puis remonter ce que l'on a besoin et dans l'ordre
# and remount only what we need and in the good order

mount -t ext3 /dev/sda2 /share/flash/conf
mount -t ext3 /dev/sdb2 /share/hdd/conf

# résultat après lancement de /etc/my_mount
# result after running /etc/my_mount

## /etc/my_mount
#umount: forced umount of /dev/sdb2 failed!
#umount: cannot umount /dev/sdb2: Invalid argument

## mount
#/dev/root on /initrd type jffs2 (rw)
#/dev/sdb1 on / type ext3 (rw)
#proc on /proc type proc (rw)
#usbdevfs on /proc/bus/usb type usbdevfs (rw)
#/dev/sda1 on /share/flash/data type ext3 (rw)
#/dev/sdb1 on /share/hdd/data type ext3 (rw)
#/dev/sda2 on /share/flash/conf type ext3 (rw)   } each partition have its own mounting point
#/dev/sdb2 on /share/hdd/conf type ext3 (rw)     } chaque partition a son propre point de montage

return 1

If a nslu2-linux senior can spend some of his time to implement this in the startup of unslung, this will be wonderfull for everybody...

Alain

Last minute : I've found the good place to include my script ! ! !

It's in '/etc/rc.d/rc.1' just before this line

/bin/echo  "Restore usrgrpshares:"; /etc/rc.d/rc.reset_usrgrpshare; check_status

You put only this :

. /etc/my_mount

So just before '/share/hdd/conf/share.info' and '/share/flash/conf/share.info' are concatened into '/share/hdd/conf/samba/share.info', the mounting points will be OK...

Alain.


Lurch's update: (this is all on Unslung 6.10)

Although Alain doesn't explicitly mention it, his apporach above is much better than UseSharesOnTwoNativeDisksInUnslung68 - it seems to properly fix the 'bad mounts' people are asking about, and as a result the web GUI works perfectly for adding and deleting shares on both disks, and there's no "nnnn~1" shares anywhere.

I've found that all Alain's /etc/my_mount script needs to contain is:

#!/bin/sh
umount /share/flash/conf
mount /share/flash/conf
return 1

which has a kind of beautiful simplicity to it :) (The reason it works is that umount dismounts it from the 'wrong' partition, and mount then reads /etc/fstab which is correct, and so it gets mounted with the correct partition)

It seems like the thing that's doing the 'wrong mount' (I'm making educated guesses) is the binary file /sbin/rc.bootbin which gets called by /etc/rc.d/rc.bootbin which in turn is called by /etc/rc.d/rc.1 So we can't make use of the DiversionScripts because we need to call '. /etc/my_mount' as soon as possible after /sbin/rc.bootbin (and there's no suitable diversion script in /etc/rc.d/rc.1 between /etc/rc.d/rc.bootbin and the /.ext3flash checks.

So IMHO the best place to add

. /etc/my_mount

is in /etc/rc.d/rc.bootbin just above the "return 0"

Maybe Unslung 6.12 could add PostDiversion? scripts that get called at the end of the rc.d scripts in addition to the current Diversion scripts that get called at the start of the rc.d scripts ;-)


Pan - Unslung 6.8

I boiled this down to a single addition of the lines:

umount /share/flash/conf
mount /share/flash/conf

to /etc/rc.d/rc.bootbin just above the "return 0"

NOTE:

You might also want to take a look at http://www.nslu2-linux.org/wiki/HowTo/3orMoreEXT3DrivesWithAUSBHub. SRS 03/01/2010

view · edit · print · history · Last edited by Pan.
Based on work by SRS, Lurch, and maisondouf.
Originally by maisondouf.
Page last modified on September 11, 2013, at 06:05 AM