PDA

Bekijk de volledige versie : controlling where harddisks is mounted



zalaam
20-08-2007, 18:11
Hi!
First i wanna shout out a thx to oleg for a great software:) Now on to my quuestion:
I have 2 external hd's connected to wl550gp formatted this way
hd 1:


Device Boot Start End Blocks Id System
part1 1 63 506016 82 Linux swap
part2 64 30401 243689985 83 Linux

and hd2:


Device Boot Start End Blocks Id System
part1 1 63 506016 82 Linux swap
part2 64 188 1004062+ 83 Linux
part3 189 30401 242685922+ 83 Linux


I get both swaps on at boot, but hd2 gets mounted inside /tmp/harddisk/part* nomather what i write in /usr/local/sbin/post-boot

On startup I want hd1 part2 mounted to /tmp/harddisk/, hd2 part3 mounted to /tmp/harddisk2/, hd2 part2 mounted to /opt/. Is this possible? and also if i connected a 3d hd it would automatically be mounted to /tmp/harddisk3/?

I know someone got this figured out, but my lack of linux skills makes it hard :)

zalaam
22-08-2007, 14:37
ok, i cant get the hd's to be mounted to /tmp/harddisk*/ but it much better nonetheless.

df:

Filesystem 1K-blocks Used Available Use% Mounted on
rootfs 2880 2880 0 100% /
/dev/root 2880 2880 0 100% /
/dev/discs/disc1/part2
988244 76920 861124 9% /opt
/dev/discs/disc0/part2
239864864 215374272 12306096 95% /tmp/harddisk
/dev/discs/disc1/part3
238877248 185963508 40779444 83% /tmp/harddisk/part1
hd2 part 3 get mounted to /tmp/harddisk/part1/ instead of /tmp/harddisk2/ but i can live with it. Swap is mounted and turned on and hd2 part2 is mounted to /opt :)

my /usr/local/sbin/post-boot still looks liket this:

#!/bin/shautomatically be mounted to /tmp/harddisk3/
dropbear
# 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/disc1/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/disc1/part3 /mnt/harddisk/
mount /dev/discs/disc0/part2 /mnt/harddisk2/

# Activate swap
swapon /dev/discs/disc1/part1

# Run all active services - active means starts with S
/opt/etc/init.d/rc.unslung
/usr/sbin/smbd -D
/usr/sbin/nmbd -D

Why the router doesnt follow me on this line i don't know, i've created the dir and everything(the dir gets deleted after i've saved&rebooted):

mount /dev/discs/disc0/part2 /mnt/harddisk2/
If i connect a third hd i guess it's mounted to /tmp/harddisk/part3 so it's not that bad :)

zalaam
25-08-2007, 11:46
new problem, one of my disk is mounted as read-only :(
output of '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/disc1/part2 on /opt type ext3 (rw)
/dev/discs/disc0/part2 on /tmp/harddisk type ext3 (ro,noatime)
/dev/discs/disc1/part3 on /tmp/harddisk/part1 type ext3 (rw,noatime)


how do i get it mounted as read-write?

newbiefan
26-08-2007, 09:38
Well, I had exactly the same probs, except: just one hdd with 3 partitions.
I got just random mounts or wrong mounts.
Finally, the solution was easy:
It seems, that my Asus needs at least 1 second (depending on CPU clock speed, up to 3) to mount a present partition.
Therefore, I added after each mount a sleep 2 - and now it works stable on my asus wl500gp.
Hope, it helps.......

Just as hint my post-boot:

#!/bin/sh
dropbear

# test if USB disc has been attached
# if not - then insert needed modules
#
# Die folgenden 4 Rauten entfernen, wenn eine USB-Platte angeschlossen ist. #Beim WL-HDD nicht notwendig, da IDE.
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/part1 /opt
i=0
while [ $i -le 30 ]
do
if [ -d /opt/etc ]
then
break
fi
sleep 1
i=`expr $i + 1`
done

#Version 0.11, network heli.lan
#Attention - it takes at least 1 second to perform a mount on my Asus
#post-boot needs to be improved, taken into list #03
# Activate swap, wait a bit
swapon /dev/discs/disc0/part2
sleep 2
# Mount the rest and wait a bit until mount is performed proper
mount /dev/discs/disc0/part3 /tmp/harddisk
sleep 2
#start new http server at port 8080 for my private website
#considering perl start script at /opt/wwwp/cgi-bin (list #6)
busybox_httpd -p 8080 -h /opt/wwwp
sleep 2
# Run all active services - active means starts with S
/opt/etc/init.d/rc.unslung

bakablah
26-08-2007, 13:33
ok, i cant get the hd's to be mounted to /tmp/harddisk*/ but it much better nonetheless.

df:

Filesystem 1K-blocks Used Available Use% Mounted on
rootfs 2880 2880 0 100% /
/dev/root 2880 2880 0 100% /
/dev/discs/disc1/part2
988244 76920 861124 9% /opt
/dev/discs/disc0/part2
239864864 215374272 12306096 95% /tmp/harddisk
/dev/discs/disc1/part3
238877248 185963508 40779444 83% /tmp/harddisk/part1
hd2 part 3 get mounted to /tmp/harddisk/part1/ instead of /tmp/harddisk2/ but i can live with it. Swap is mounted and turned on and hd2 part2 is mounted to /opt :)

my /usr/local/sbin/post-boot still looks liket this:

#!/bin/shautomatically be mounted to /tmp/harddisk3/
dropbear
# 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/disc1/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/disc1/part3 /mnt/harddisk/
mount /dev/discs/disc0/part2 /mnt/harddisk2/

# Activate swap
swapon /dev/discs/disc1/part1

# Run all active services - active means starts with S
/opt/etc/init.d/rc.unslung
/usr/sbin/smbd -D
/usr/sbin/nmbd -D

Why the router doesnt follow me on this line i don't know, i've created the dir and everything(the dir gets deleted after i've saved&rebooted):

mount /dev/discs/disc0/part2 /mnt/harddisk2/
If i connect a third hd i guess it's mounted to /tmp/harddisk/part3 so it's not that bad :)
First of all:
You need to use this code in between different mounts


i=0
while [ $i -le 30 ]
do
if [ -d /opt/etc ]
then
break
fi
sleep 1
i=`expr $i + 1`
done

Second of all:
/mnt is a read-only filesystem, you cannot add any directory inside of /mnt when nothing is mounted to /mnt
what you can do, is to have a partition mounted to /mnt itself

mount /dev/discs/disc1/part3 /mnt
For the other partition, you can create a new directory under /tmp (one of the few directories where you have write access to)


mkdir /tmp/harddisk2
mount /dev/discs/disc0/part2 /tmp/harddisk2

zalaam
27-08-2007, 09:55
Thx for the reply!
ok, seems like i'm confusing /mnt with /tmp, sorry :)

it works find mkdir /tmp/harddisk2 and mounting it but after reboot it still gets mounted to /tmp/harddisk/part1 and /tmp/harddisk2/ is gone. i've set up post-boot like this now:

#!/bin/sh
dropbear
# 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/disc1/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/disc /tmp/harddisk

i=0
while [ $i -le 30 ]
do
if [ -d /opt/etc ]
then
break
fi
sleep 1
i=`expr $i + 1`
done

mount /dev/discs/disc1/part3 /tmp/harddisk2

# Activate swap
swapon /dev/discs/disc1/part1

# Run all active services - active means starts with S
/opt/etc/init.d/rc.unslung


i gonna try putting in "sleep 2" now, and will see

edit:
doesn't work, any clues guys?

bakablah
27-08-2007, 13:12
add a:


mkdir /tmp/harddisk2
before

mount /dev/discs/disc1/part3 /tmp/harddisk2
so it becomes


mkdir /tmp/harddisk2
mount /dev/discs/disc1/part3 /tmp/harddisk2

and it'll work.
trust me on this one :p

you had:

mount /dev/discs/disc0/disc /tmp/harddisk
shouldn't it be /dev/discs/disc0/part1 /tmp/harddisk?

zalaam
27-08-2007, 16:55
add a:


mkdir /tmp/harddisk2
before

mount /dev/discs/disc1/part3 /tmp/harddisk2
so it becomes


mkdir /tmp/harddisk2
mount /dev/discs/disc1/part3 /tmp/harddisk2

and it'll work.
trust me on this one :p

:D :D It works:


[admin@barricade lun0]$ df -h
Filesystem Size Used Avail Use% Mounted on
rootfs 2.9M 2.9M 0 100% /
/dev/root 2.9M 2.9M 0 100% /
/dev/discs/disc1/part2
966M 93M 824M 11% /opt
/dev/discs/disc1/part3
228G 186G 31G 86% /tmp/harddisk2
/dev/discs/disc0/disc
230G 190G 29G 87% /tmp/harddisk



Thanx bakablah :)


you had:

mount /dev/discs/disc0/disc /tmp/harddisk
shouldn't it be /dev/discs/disc0/part1 /tmp/harddisk?
I reformated and change it so the first hd only have 1 part:) :


[admin@barricade /]$ cd /dev/discs/disc0/
[admin@barricade lun0]$ ls -a
. .. disc