Flash disk / initrd problems *HELP PLEASE!*

Flash disk / initrd problems *HELP PLEASE!*

Post by Jem » Wed, 31 Jan 2001 00:48:21



Hi Guys,

I am just finishing off development of an embedded system but I'm having
a bit of a problem with an ATA Flash disk that I'm trying to use.

Everything is fine with it, except I want to mount it in Read Only mode
to prevent killing the flash media. I have read a few articles on this
and they seem to imply the following sequence of events:

(1)     Use initrd to load a small kernel image
(2)     Write a linuxrc script to zcat a root file system onto a ram disk
        with links to the permanent files on the flash disk
(3)     mount the flash disk as read only, say in the /mnt directory
(4)     unmount the ram disk and exit the linuxrc script so initrd can
        remount it and continue the boot sequence.

All sounds relatively easy and, to this end, I did the following:

(1)     Made up a small kernel image (mkinitrd) and used zcat to unpack it
        onto a ram disk
(2)     Edited the /etc/fstab to mount /dev/ram as root file system
(3)     Edited linuxrc to the following:
                #!/bin/sash
                aliasall

                # This mounts the flash card into /mnt
                mount -t minix /dev/hdc1 /mnt

                # This is unnecessary but I'm doing it just to make sure
                mkfs.minix /dev/ram 2000

                # Extract the new root file system to the ram disk
                zcat /mnt/boot/rootfs.img.gz >/dev/ram

                # Now unmount the flash disk
                umount /dev/hdc1

                # Just for testing purposes mount the ram disk and do
                # a directory listing
                mount -t minix /dev/ram /mnt
                ls /mnt

                # unmount the ram disk (as initrd will re-mount it)
                umount /dev/ram

(4)     Copied extra executables / libraries into /bin and /lib as
        determined using ldd

I have traced this every step of the way and cannot work out what is
going wrong. The final "ls /mnt" command shows me that the ram disk is
empty... despite having unpacked a file into it.
I am 99.9% sure that the zcat line is not doing anything although I
can't determine why it doesn't report any errors (yes, tried 2>
error.file).

Things I have checked:
(1)     "zcat -h" in linuxrc DOES produce help text on screen so its not
        simply that it can't find the executable.
(2)     rootfs.img.gz IS a valid zcat file system, i.e. from a command
        line I CAN type "zcat rootfs.img.gz >/dev/ram" and it WILL create
        the file system.
(3)     I've tried simply copying the file "rootfs.img.gz" from the flash
        to the ram disk just to check I have made a valid ram disk and the
        mount is valid and that works just fine.

PLEASE PLEASE PLEASE! If anyone's done this I need an answer asap...I've
spent 3 days already trying to work out what's gone wrong!

Jeremy

 
 
 

Flash disk / initrd problems *HELP PLEASE!*

Post by Philip Armstro » Wed, 31 Jan 2001 03:12:23




>Things I have checked:
>(1) "zcat -h" in linuxrc DOES produce help text on screen so its not
>    simply that it can't find the executable.
>(2) rootfs.img.gz IS a valid zcat file system, i.e. from a command
>    line I CAN type "zcat rootfs.img.gz >/dev/ram" and it WILL create
>    the file system.
>(3) I've tried simply copying the file "rootfs.img.gz" from the flash
>    to the ram disk just to check I have made a valid ram disk and the
>    mount is valid and that works just fine.

(3) seems wrong. If you copy over a compressed filesystem without
uncompressing it first then I'd expect the mount to fail. Or have
I misinterpreted what you're saying here?

But other than that I can't see anything wrong with what you're trying
to do I'm afraid :(

Phil

--
http://www.kantaka.co.uk/ .oOo. public key: http://www.kantaka.co.uk/gpg.txt

 
 
 

Flash disk / initrd problems *HELP PLEASE!*

Post by Chri » Wed, 31 Jan 2001 05:23:35



> Hi Guys,

> I am just finishing off development of an embedded system but I'm having
> a bit of a problem with an ATA Flash disk that I'm trying to use.
>                 #!/bin/sash
>                 aliasall

>                 # This mounts the flash card into /mnt
>                 mount -t minix /dev/hdc1 /mnt

>                 # This is unnecessary but I'm doing it just to make sure
>                 mkfs.minix /dev/ram 2000

>                 # Extract the new root file system to the ram disk
>                 zcat /mnt/boot/rootfs.img.gz >/dev/ram

Errm.

I get the impression that /dev/ram is already
mounted at this stage, since you unmount it
later. Randomly scribbling over a mounted
filesystem (even if you are replacing it with
a new valid filesystem) sounds like a bad
move to me.

What happens if you umount /dev/ram before this
step, then remount it afterwards?

    [...]

Quote:>                 # unmount the ram disk (as initrd will re-mount it)
>                 umount /dev/ram

--
Chris Lightfoot -- chris at ex dash parrot dot com -- www.ex-parrot.com/~chris/
  "Life is like a sewer.  What you get out of it
   depends on what you put in to it." (Tom Lehrer)
 
 
 

Flash disk / initrd problems *HELP PLEASE!*

Post by Luca Fin » Wed, 31 Jan 2001 16:54:30



> Hi Guys,

> I am just finishing off development of an embedded system but I'm having
> a bit of a problem with an ATA Flash disk that I'm trying to use.

 [snip]

Quote:> All sounds relatively easy and, to this end, I did the following:

> (1)        Made up a small kernel image (mkinitrd) and used zcat to unpack it
>    onto a ram disk
> (2)        Edited the /etc/fstab to mount /dev/ram as root file system
> (3)        Edited linuxrc to the following:
>            #!/bin/sash
>            aliasall

>            # This mounts the flash card into /mnt
>            mount -t minix /dev/hdc1 /mnt

>            # This is unnecessary but I'm doing it just to make sure
>            mkfs.minix /dev/ram 2000

>            # Extract the new root file system to the ram disk
>            zcat /mnt/boot/rootfs.img.gz >/dev/ram

>            # Now unmount the flash disk
>            umount /dev/hdc1

>            # Just for testing purposes mount the ram disk and do
>            # a directory listing
>            mount -t minix /dev/ram /mnt
>            ls /mnt

>            # unmount the ram disk (as initrd will re-mount it)
>            umount /dev/ram

> (4)        Copied extra executables / libraries into /bin and /lib as
>    determined using ldd

  [snip]

The entire procedure shown above seems to me a little odd. You are
actually trying to do by means of a script what the boot loader can do
better.

The usual boot process, in fact, first loads a kernel, then it can
optionally load a root filesystem possibly into a ram disk. The boot
device is not mounted in this process, so if you want it available when
the system is running, you must explicitly mount it (so you can mount it
readonly or even keep it unmounted for better protection).

You can find a lot of information on the entire process in the
Bootdisk-HOWTO, which is intended to give direction for booting from
diskettes, but can be applied to booting from other means, too.

Cheers,
                                                        l.f.
--------------------------------------------------------------------------
       -- )     Luca Fini                            Tel: +39 055 2752 307
 ___    |\      Osservatorio Astrofisico di Arcetri  Fax: +39 055 2752 292
/   |   | |-_   L.go E.Fermi, 5 +-----------------------------------------
(___|___//___)  50125 Firenze  /   WWW: http://www.arcetri.astro.it/~lfini

-----------------------------+--------------------------------------------

 
 
 

Flash disk / initrd problems *HELP PLEASE!*

Post by Jem » Wed, 31 Jan 2001 19:22:41





> >Things I have checked:
> >(1)    "zcat -h" in linuxrc DOES produce help text on screen so its not
> >       simply that it can't find the executable.
> >(2)    rootfs.img.gz IS a valid zcat file system, i.e. from a command
> >       line I CAN type "zcat rootfs.img.gz >/dev/ram" and it WILL create
> >       the file system.
> >(3)    I've tried simply copying the file "rootfs.img.gz" from the flash
> >       to the ram disk just to check I have made a valid ram disk and the
> >       mount is valid and that works just fine.

> (3) seems wrong. If you copy over a compressed filesystem without
> uncompressing it first then I'd expect the mount to fail. Or have
> I misinterpreted what you're saying here?

> But other than that I can't see anything wrong with what you're trying
> to do I'm afraid :(

> Phil

Yes, item (3) wasn't meant to expand the root file system, I know that
wouldn't work. What I was doing here was just checking that the ram disk
had formatted OK (mkfs.minix) and that the file system was capable of
copying a file to it (could have been any old file).

That was successful, I have interspersed regular "ls -l /" lines into my
linuxrc file to watch what the file system is doing from step to step of
my script and everything but the zcat was (is) working.

Jeremy

 
 
 

Flash disk / initrd problems *HELP PLEASE!*

Post by Jem » Wed, 31 Jan 2001 19:29:20




> > Hi Guys,

> > I am just finishing off development of an embedded system but I'm having
> > a bit of a problem with an ATA Flash disk that I'm trying to use.

> >                 #!/bin/sash
> >                 aliasall

> >                 # This mounts the flash card into /mnt
> >                 mount -t minix /dev/hdc1 /mnt

> >                 # This is unnecessary but I'm doing it just to make sure
> >                 mkfs.minix /dev/ram 2000

> >                 # Extract the new root file system to the ram disk
> >                 zcat /mnt/boot/rootfs.img.gz >/dev/ram

> Errm.

> I get the impression that /dev/ram is already
> mounted at this stage, since you unmount it
> later. Randomly scribbling over a mounted
> filesystem (even if you are replacing it with
> a new valid filesystem) sounds like a bad
> move to me.

> What happens if you umount /dev/ram before this
> step, then remount it afterwards?

>     [...]
> >                 # unmount the ram disk (as initrd will re-mount it)
> >                 umount /dev/ram

Ah, no... afraid not. If you hadn't snipped the line before you would
see:

                # Just for testing purposes mount the ram disk and do
                # a directory listing
                mount -t minix /dev/ram /mnt
                ls /mnt

                # unmount the ram disk (as initrd will re-mount it)
                umount /dev/ram

The umount you are referring to is simply the unmount of the ram disk
that I "ls" to test if the file system had been built correctly. I know
the /dev/ram isn't mounted because if it was I would get an error at the
"mount -t minix /dev/ram /mnt" statement along the lines of "device
busy".

I will try a umount prior to the unpack... Nope, sorry no difference.

It's a bit of a problem that the sash mount command is unable to list
the currently mounted drives. I tried swapping to the full-blown mount
command but it requires mtab / fstab and other bits & pieces which I
didn't want to get into.

More suggestions guys?

Jem

 
 
 

Flash disk / initrd problems *HELP PLEASE!*

Post by Jem » Wed, 31 Jan 2001 20:14:40





> > Hi Guys,

> > I am just finishing off development of an embedded system but I'm having
> > a bit of a problem with an ATA Flash disk that I'm trying to use.

>  [snip]

> > All sounds relatively easy and, to this end, I did the following:

> > (1)   Made up a small kernel image (mkinitrd) and used zcat to unpack it
> >       onto a ram disk
> > (2)   Edited the /etc/fstab to mount /dev/ram as root file system
> > (3)   Edited linuxrc to the following:
> >               #!/bin/sash
> >               aliasall

> >               # This mounts the flash card into /mnt
> >               mount -t minix /dev/hdc1 /mnt

> >               # This is unnecessary but I'm doing it just to make sure
> >               mkfs.minix /dev/ram 2000

> >               # Extract the new root file system to the ram disk
> >               zcat /mnt/boot/rootfs.img.gz >/dev/ram

> >               # Now unmount the flash disk
> >               umount /dev/hdc1

> >               # Just for testing purposes mount the ram disk and do
> >               # a directory listing
> >               mount -t minix /dev/ram /mnt
> >               ls /mnt

> >               # unmount the ram disk (as initrd will re-mount it)
> >               umount /dev/ram

> > (4)   Copied extra executables / libraries into /bin and /lib as
> >       determined using ldd

>   [snip]

> The entire procedure shown above seems to me a little odd. You are
> actually trying to do by means of a script what the boot loader can do
> better.

> The usual boot process, in fact, first loads a kernel, then it can
> optionally load a root filesystem possibly into a ram disk. The boot
> device is not mounted in this process, so if you want it available when
> the system is running, you must explicitly mount it (so you can mount it
> readonly or even keep it unmounted for better protection).

> You can find a lot of information on the entire process in the
> Bootdisk-HOWTO, which is intended to give direction for booting from
> diskettes, but can be applied to booting from other means, too.

> Cheers,
>                                                    l.f.

Hi Luca,

I was actually working from Paul Moodys embedded device howto:

        http://www.linux-embedded.com/pmhowto.html

What he says is that you need to use initrd to load a root file system
which then expands a larger, say 40MB, ram disk from the flash disk and
continues the boot process.

However, what you are saying does make sense to me... I am going to have
to investigate this further. He (apparently) got everything to work (I
followed his howto step-by-step) but I can't get zcat to work at all and
am wondering how he did it.... And now I'm wondering WHY he did it ;-)

Jeremy

 
 
 

Flash disk / initrd problems *HELP PLEASE!*

Post by Vincent F » Thu, 01 Feb 2001 01:05:21



*snip*

Quote:>I was actually working from Paul Moodys embedded device howto:
>    http://www.linux-embedded.com/pmhowto.html
>What he says is that you need to use initrd to load a root file system
>which then expands a larger, say 40MB, ram disk from the flash disk and
>continues the boot process.
>However, what you are saying does make sense to me... I am going to have
>to investigate this further. He (apparently) got everything to work (I
>followed his howto step-by-step) but I can't get zcat to work at all and
>am wondering how he did it.... And now I'm wondering WHY he did it ;-)

I have used the Paul Moody method to build several such systems
successfully. It's a bit tricky and tedious but it does work.

You have to make sure all the details are right. I'm sure some of
this should be obvious, but for example you need to compile your
copies of zcat, mount, and any other programs you use in the
boot phase as *static* executables. You cannot have any dynamically
linked executables unless you are going to include the libs.
I just downloaded the source rpm's and compiled static.

--
        "Who needs horror movies when we have Microsoft"?
         -- Christine Comaford, PC Week, 27/9/95

 
 
 

Flash disk / initrd problems *HELP PLEASE!*

Post by Jem » Thu, 01 Feb 2001 02:09:05



says...


> *snip*

> >I was actually working from Paul Moodys embedded device howto:

> >       http://www.linux-embedded.com/pmhowto.html

> >What he says is that you need to use initrd to load a root file system
> >which then expands a larger, say 40MB, ram disk from the flash disk and
> >continues the boot process.

> >However, what you are saying does make sense to me... I am going to have
> >to investigate this further. He (apparently) got everything to work (I
> >followed his howto step-by-step) but I can't get zcat to work at all and
> >am wondering how he did it.... And now I'm wondering WHY he did it ;-)

> I have used the Paul Moody method to build several such systems
> successfully. It's a bit tricky and tedious but it does work.

> You have to make sure all the details are right. I'm sure some of
> this should be obvious, but for example you need to compile your
> copies of zcat, mount, and any other programs you use in the
> boot phase as *static* executables. You cannot have any dynamically
> linked executables unless you are going to include the libs.
> I just downloaded the source rpm's and compiled static.

> --
>    "Who needs horror movies when we have Microsoft"?
>     -- Christine Comaford, PC Week, 27/9/95

Hmmm, I didn't static link but I did "ldd" the files and copied all the
dependent libraries into the /lib directory... could this be my problem?
Maybe it doesn't know about the /lib directory and I need to set some
form of path?

Jeremy

 
 
 

1. Linux initrd Flash disk question

I'm trying to set up a system that uses an initial ramdisk to load up the
system from a Flash drive (as is described in Paul Moody's miniHOWTO,
http://www.linux-embedded.com/pmhowto.html). While I'm trying to get this to
work, I'm substituing a hard drive for the Flash drive.

Of course, I'm running into some issues.

I've created the initrd image. I tried using sash in the linuxrc script but
I kept getting the following on bootup:

RAMDISK: Compressed image found at block 0
VFS: Mounted root (ext2 filesystem)
FATAL: Cannot determine library version
Kernel panic: VFS: Unable to mount root fs on 01:01

So, instead of sash, I decided to use BusyBox. The initrd BusyBox is
compiled as a static executable and can mount, unmount, and zcat. The
/dev/ram partition also uses a fuller version of BusyBox to do init, ls, cp,
etc, etc.

Now, if the BusyBox on the /dev/ram partition is compiled as a dynamic
executable, the following happens:

RAMDISK: Compressed image found at block 0
VFS: Mounted root (ext2 filesystem)
from linuxrc: Mounting /dev/hdb1
from linuxrc: Uncompressing RAM drive
from linuxrc: Unmounting /dev/hdb1
sh: tcsetpgrp: Inappropriate ioctl for device
VFS: Mounted root (ext2 filesystem) readonly
change_root: old root has d_count=1
Freeing unused kernel memory: 44k freed

The system locks up after the 44k freed statement. The libraries BusyBox
needs are in the /lib directory of the /dev/ram partition, so BusyBox should
be able to run ok.

Now, if I compile BusyBox as a static executable, BusyBox init runs just
fine, but I can't run anything else besides BusyBox. When I try to, nothing
happens! The BusyBox execs (like ls, etc) work just fine. Everything else is
a no go. Ugh!

Now, the kicker is that if I directly boot off of the hard drive from which
I created the compressed boot image, it works perfectly! AHHH!

I've tried different versions of BusyBox (.51 and .52) to no avail. I'm
using the 2.2.19 kernel.

Anyone have any thoughts on this? Is there something about using initrd with
/dev/ram? Any help is greatly greatly appreciated!

Thanks!
Chris Burnette
E-OIR Measurements, Inc.

2. need basic advice on developing network

3. Problem booting RPX-Lite board from flash w/initrd

4. Help with RedHat 5.2 initrd.img file

5. Konqueror and flash plugin problem, please help

6. ftp problem

7. PLEASE PLEASE HELP Major problem with my SCSI & Redhat 5.0 PLEASE Help

8. Problems saving workspace - owplaces absent

9. Sendmail problems. Please please please please help!

10. LINUX instalation problems, PLEASE HELP !?!Subject: LINUX , instalation problems, PLEASE HELP !?!

11. initrd help please

12. hpt370 - initrd - please help !!!