PDA

Bekijk de volledige versie : disable auto-mounting on boot time



nameless_one
05-01-2008, 16:15
Hi, i am following this http://wl500g.info/showthread.php?t=10307 tutorial to install and configure olegs firmware.

i get to 4b - Startup-scripts

at this point a get a problem - the partitions didnt mount correctly at the startup

i figured out,that somehow the partitons are mounted automaticaly , under /tmp/harddisk/..., first partition at /tmp/harddisk, second partiton at /tmp/harddisk/part1, ... etc

i want to disable this and mount the partitons manualy in post-boot script, but i dont know how to achieve that.

thx for any suggestion or help!

newbiefan
06-01-2008, 00:46
There are 2 ways how to get a storage mounted to a specified folder/directory:

1.) write in your post-boot:

mount /dev/discs/disc0/part1 /tmp/harddisk/somewhere

(provided somewhere exist!)
....where disc0 is your first hdd or stick and part1 up to partx are the
partitions.
But you have to read tutorial to understand what you need to get a
running system:
http://wl500g.info/showthread.php?t=10307 (read 4b)
2.) create file fstab, provided you use olegs 8 (newest fw)
(If you wanna use fstab and don't know how, let me know):cool:

mefi
06-01-2008, 01:23
i am stuck at exactly the same point as nameless_one!

i used wl-hdd for a year and everything was ok, the tutorial was a great help to me. but now i changed to wl-500gp and the show is over for me at point 4b of tutorial :(

--
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/part1 on /tmp/harddisk type vfat (ro,noatime)
--

but fdisk says:

--
fdisk -l

Disk /dev/scsi/host0/bus0/target0/lun0/disc: 40.0 GB, 40007761920 bytes
255 heads, 63 sectors/track, 4864 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/scsi/host0/bus0/target0/lun0/part1 1 63 506016 82 Linux swap
/dev/scsi/host0/bus0/target0/lun0/part2 64 313 2008125 83 Linux
/dev/scsi/host0/bus0/target0/lun0/part3 314 4864 36555907+ 83 Linux
--

system lof says something like:

--
Jan 1 01:00:08 kernel: USB Mass Storage support registered.
Jan 1 01:00:13 kernel: kjournald starting. Commit interval 5 seconds
Jan 1 01:00:13 kernel: EXT3 FS 2.4-0.9.19, 19 August 2002 on sd(8,2), internal journal
Jan 1 01:00:13 kernel: EXT3-fs: recovery complete.
Jan 1 01:00:13 kernel: EXT3-fs: mounted filesystem with ordered data mode.
Jan 1 01:00:14 kernel: Adding Swap: 506008k swap-space (priority -1)
Jan 1 01:00:17 kernel: VFS: Can't find ext3 filesystem on dev sd(8,0).
Jan 1 01:00:17 kernel: MSDOS FS: Using codepage 950
Jan 1 01:00:17 kernel: MSDOS FS: IO charset cp950
Jan 1 01:00:17 kernel: FAT: bogus logical sector size 19781
Jan 1 01:00:17 kernel: VFS: Can't find a valid FAT filesystem on dev 08:00.
Jan 1 01:00:17 kernel: FAT: freeing iocharset=cp950
Jan 1 01:00:17 kernel: FAT: bogus logical sector size 19781
Jan 1 01:00:17 kernel: VFS: Can't find a valid FAT filesystem on dev 08:00.
Jan 1 01:00:17 kernel: VFS: Can't find ext3 filesystem on dev sd(8,1).
Jan 1 01:00:17 kernel: MSDOS FS: Using codepage 950
Jan 1 01:00:17 kernel: MSDOS FS: IO charset cp950
Jan 1 01:00:17 kernel: Directory 1: bad FAT
Jan 1 01:00:17 kernel: attempt to access beyond end of device
--


as i am drunk now i think its no good trying anymore, maaybe later someone solves this damn problem. this seams to be common to many people ,hum?
could it be a bug in WL500gp-1.9.2.7-8 fw while trying to get a external hdd connected?

and once again from me:
wengi you did a great job and also thanks to all the others spending all the hours trying and trying and trying...

newbiefan
06-01-2008, 08:40
I never experienced a problem regarding partitions - the only difference was, that I created all partitions on my pc. I've used paragons partition manager.

al37919
06-01-2008, 09:31
I suggest the following:
1) are you sure that you executed

mkswap /dev/discs/disc0/part1
2) if no then dismount this fake partition and do it; if yes then goto 3)
3) best of all create file /etc/fstab


cat > /etc/fstab < ___eof
/dev/discs/disc0/part1 swap swap
/dev/discs/disc0/part2 /opt ext3 noatime,nodiratime 1 1
/dev/discs/disc0/part3 /home ext3 noatime,nodiratime 1 2
___eof

echo "/etc/fstab" >> /usr/local/.files

flashfs save && ...

If you don't have fstab you have to execute swapon /dev/discs/disc0/part1 on every boot

newbiefan
06-01-2008, 10:36
well, you have to mount with the -a option.

Just to allow you to adjust my fstab and post-boot to your needs, I've attached the two files.

al37919
06-01-2008, 10:41
When using fstab, mount -a and swapon -a are not really needed, as they are executed automatically

The nice thing is that even if you attach some storage later which has correct record in fstab it is automounted in the right place.

newbiefan
06-01-2008, 11:10
When using fstab, mount -a and swapon -a are not really needed, as they are executed automatically

The nice thing is that even if you attach some storage later which has correct record in fstab it is automounted in the right place.

Sounds pretty good, but I got no device mounted without mount -a
Anyhow, I'll try your fstab (adjusted to my network).

Further, I've to mount sometimes up to 5 (and more) Sticks and hdds.
My Problem is, that I do not know at boot-time which stick has which /dev/discs/.... entry.
Or is there a solution I do not know?
For instance: Sales people have stored their orders on sticks (>20pce).
I have to store their database to specific folders like:
/tmp/harddisk/huber_gerhard
If I would be able to store it automatically, it would be a great help!
I know, with some scripting I can read a file on the sticks and......anyhow, I'll do it when I've more time, because you know :), Asus routers are a hobby and need plenty of time. :o

al37919
06-01-2008, 11:26
At least for the very late fw (preview 1.9.2.7-8.7) mount -a is not needed. I can't say for sure about 1.9.2.7-7g/8, because I started to use fstab only very recently after upgrade of hdd.


Or is there a solution I do not know?
Unfortunately by now --- no

newbiefan
06-01-2008, 12:28
Well, thanks for your hint - I had a closer look at my fstab and found a fault.
(Just a "#" at the beginning was missing)
The funny thing is that a mount -a in my post-boot worked well.
But now I got an other fault, do you have any ideas?

[admin@Asus root]$ 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/part1 on /opt type ext3 (rw)
/dev/discs/disc0/part3 on /tmp/harddisk type ext3 (rw)

This is ok, but when I try to unmount:

[admin@Asus root]$ umount /tmp/harddisk
umount: Couldn't umount /tmp/harddisk: Invalid argument
[admin@Asus root]$ umount /dev/discs/disc0/part3
umount: Couldn't umount /dev/scsi/host0/bus0/target0/lun0/part3: Invalid argument
[admin@Asus root]$

Is there no way to umount all like umount -a? (mtab file)
Many thanks!

lutkebab
06-01-2008, 12:35
I had the same problem.

At first my usb-drive would not be mounted, so I added in my post-boot:

insmod scsi_mod
insmod sd_mod
instmod usb-storage

After that my usb-drive mounted, but...

I have two partitions on my usb drive (swap first). It always mounted my swap on /tmp/harddisk, but when I "cleaned" my drive with dd it started to mount my second partition on /tmp/harddisk. So now I first mount my second partition to opt and then umount /tmp/harddisk (and ofcourse activate swap).

Well, it kind of works now with the mount and umount of /tmp/harddisk. I haven't tried with fstab, but my problem is that I have to manually load the modules above (with post-boot).

newbiefan
06-01-2008, 12:50
Ok, but everybody is loading the modules like here:
http://wl500g.info/showpost.php?p=76131&postcount=6
(Have a closer look at post-boot.txt)

My prob is the umount after a proper mount of partitions.

lutkebab
06-01-2008, 13:08
I tried with fstab and it worked, but I have to use swapon -a and mount -a in post-boot, but I no longer need to umount /tmp/harddisk

newbiefan
06-01-2008, 13:32
Ok, now you got the same as I had - maybe it's a copy fault.
Just look at the beginning of your fstab file:
If you have taken my fstab, then insert a "#" in the first description line, right before device
Then you can remove swap and mount -a in post-boot.

al37919
06-01-2008, 13:41
umount was always problem when some services were already started which might use this partition.

However there is another option to do: instead of unmounting perform remounting in read only mode. When done so you can safely disconnect hdd or turn off power. To remount all ext3 partitions based on fstab you can use e.g.:


for i in `awk '/ext3/{print($1)}' /etc/fstab`
do
mount -o remount,ro $i
done

You can have a look on this topic which was discussed recently: http://wl500g.info/showthread.php?t=12221 Despite it is in Russian, still the pieces of the code should be more or less self-explanatory. However, it is describing the situation in the latest preview (version >8), because pre-mount file was introduced only there.

The key finding is that it is strongly recommended to make such remounting into ro-state of all filesystems in pre-shutdown file, as asus itself apparently makes no effort of doing that. So, actually halt or reboot commands have the same effect as taking off power.

To perform routine e2fsck check of all fs on booting is another good idea, and one more suggestion was done about updating of the rc.unslung file so that it can accept start|stop parameter and be also used in pre-shutdown to exit some daemons gracefully.

In overall with these late changes the pre&post files have been largely simplified and obtained more clear meaning.

lutkebab:
use fstab it should solve the problem with wrongly mounted swap

but my problem is that I have to manually load the modules above (with post-boot).
in the next version of the fw there will be a checkbox in web-IF which enables automatic loading of these modules :)

newbiefan
06-01-2008, 14:03
@al37919

Man - many thks, it's exactly what I need!
Now, the pre-shutdown make sense - and the best is, that everything what I want to achieve is running well and stable on my 2 asus routers.
Ok, I've bricked one with (guessing) samba under heavy load, even the serial console was not working any more - but this was solved with nice -n-17.
And now the unclear umount is solved!

Thanks again, maybe I start now my planned project, mc on asus-rs232

lutkebab
06-01-2008, 14:12
Yeah, it now works without swapon -a and mount -a, my fstab is:


/dev/discs/disc0/part1 none swap sw 0 0
/dev/discs/disc0/part2 /opt ext3 noatime,nodiratime 1 1

and my post-boot is:


#!/bin/sh

if [ ! -d /dev/discs ] ; then
insmod scsi_mod && insmod sd_mod && insmod usb-storage
fi

i=0
while [ $i -le 30 ] ; do
if [ -d /opt/etc ] ; then
break
fi

sleep 1
i='expr $i + 1'
done

sleep 10

/opt/etc/init.d/rc.unslung

I had to add sleep 10 before calling rc.unslung, otherwise it would not start samba and xinetd

al37919
06-01-2008, 14:23
you can simplify it even further:

#!/bin/sh

if [ ! -d /dev/discs ] ; then
insmod scsi_mod && insmod sd_mod && insmod usb-storage
fi

sleep 15s

/opt/etc/init.d/rc.unslung

mefi
06-01-2008, 18:04
thx @al37919 and thx @newbiefan

your hints were perfect. with fstab my mount problem is solved.

especially thx for the pre-shutdown hint, what solved following problem:

i formated my hdd with fdisk and edited the fstab file as described and afterwards i made the common "flashfs save && flashfs commit && flashfs enable && reboot"

after booting process was finished i wondered why my just created partition was not able to be mounted, and even the partition seamed not to be formated. and now i am sure it was just the reboot command. some data wasnt written to hdd just in cache i think.


how do you remove usb devices safely btw?

newbiefan
06-01-2008, 21:09
That was exactly my problem, I had to mount a bunch of usb sticks and have not been able to unmount them in a correct way. Several sticks had problems with that (after a while).

When you need to unmount (which means to remove=linux) a usb storage device, you have to remount this device in read only mode as al37919 stated.
http://wl500g.info/showpost.php?p=76188&postcount=15
A regular umount doesn't work proper, maybe fstab handling (process) is one of the reasons.

piezomotor
23-01-2008, 13:04
I have sort of a related problem. During the startup sometimes I can see this mount is shown on my system

/dev/discs/disc0/part1 151705660 20985876 123013576 15% /tmp/mnt/disc0_1

I did not specify this mount and I do not use fstab, this file does not exist on my system.

I would like to know where it comes from and how to get rid of it?

this is what I mount in the post-boot:
mount /dev/scsi/host0/bus0/target0/lun0/part1 /opt

I have this line in my post-mount:

/bin/mount -o bind,sync,noatime,rw /tmp/harddisk/opt /opt

may it be related?

Thanks.

al37919
23-01-2008, 13:57
if you look carefully, you'll find that /dev/discs/disc0/part1 is a symlink to /dev/scsi/host0/bus0/target0/lun0/part1

You can just forget about this junk mounting. It doesn't harm anything.

If you do care about it, create fstab . Then it will disappear.

piezomotor
23-01-2008, 14:23
It doesn't harm anything.


Yes it does in some way...

What is actually happening is that when /tmp/mnt/disc0_1
is mounted the stupid-ftpd would start somehow and as the result all of my files are exposed to WAN! I was trying to run a search to find this stupid-ftpd via Samba (from Windows) on the whole drive and could not find it...

I did not get it where it is located and how it opens the 21 port to the WAN when it is not open in my post-firewall?

Do you know?

al37919
23-01-2008, 14:34
if you have /tmp/mnt/disc0_1 it means that you're using some of the last previews. Install preview 12. There is no stupid-ftpd in it anymore.

piezomotor
23-01-2008, 14:46
if you have /tmp/mnt/disc0_1 it means that you're using some of the last previews. Install preview 12. There is no stupid-ftpd in it anymore.

Thanks, Could you please give me the link?

al37919
23-01-2008, 16:37
http://wl500g.info/showthread.php?t=12200

flim
19-02-2008, 14:00
I have the same problem that the /tmp/harddisk always mount first.

Where should I save the fstab?

newbiefan
24-02-2008, 08:20
I have the same problem that the /tmp/harddisk always mount first.

Where should I save the fstab?

I strongly suggest to search forum........
fstab is stored in /tmp/etc