# initrd: error 6 mounting ext3

## matthead

I'm moving the root volume from an IDE disk to a SCSI disk.  Since my kernel doesn't have the right SCSI driver compiled in, I figured I'd just compile it as a module and use an initrd to boot.  Except I can't get the initrd working the way it should!

The module I need is mptspi.ko.  So I build the module and install it.  Oops, mkinitrd isn't part of "system."  So:

```
emerge mkinitrd
```

Now I'm ready to make the initrd.  I run:

```
mkinitrd -v --preload mptspi /boot/initrd-2.6.16.16.gz 2.6.16.16
```

It correctly detects the dependencies, and sets up the initrd.  I edit the GRUB config file appropriately, reboot, and get:

```
...

RAMDISK: Compressed image found at block 0

VFS: Mounted root (ext2 filesystem)

Red Hat nash version 3.5.7 starting

Loading mptbase.ko module

Fusion MPT base driver 3.03.07

Copyright (c) 1999-2005 LSI Logic Corporation

Loading mptscsih.ko module

Loading mptspi.ko module

Fusion MPT SPI Host driver 3.03.07

...

SCSI device sda: 8388608 512-byte hdwr sectors

sda: Write Protect is off

sda: cache data unavailable

sda: assuming drive cache: write through

SCSI device sda: 8388608 512-byte hdwr sectors

sda: Write Protect is off

sda: cache data unavailable

sda: assuming drive cache: write through

 sda: sda1

sd 0:0:0:0: Attached scsi disk sda

Mounting /proc filesystem

Creating block devices

Creating root device

Mounting root filesystem

mount: error 6 mounting ext3

pivotroot: pivot_root(/sysroot,/sysroot/initrd) failed: 2

umount /initrd/proc failed: 2

```

And then a kernel panic, because it can't find /sbin/init.  So it loads the modules and detects the disk OK!  I just didn't get the next part, where it can't mount the root filesystem.  Yes, ext3 is compiled directly into the kernel.  Everything it needs except the SCSI driver is compiled into the kernel.  Since the SCSI driver is being loaded, it looks like it should work.  Yes, the root device is on the kernel command line.  GRUB config is:

```

kernel /boot/bzImage-2.6.16.16 root=/dev/sda1

initrd /boot/initrd-2.6.16.16.gz

```

After some poking around, I found in /linuxrc (inside the initrd):

```
echo 0x0100 >/proc/sys/real-root-dev
```

Why is this stuck in here?  It looks like it's overwriting my requested root device!  So what is my root device?  Well, ls -l /dev/sda1 shows the device numbers are 8,1.  Sure enough, if I change this line to

```
echo 0x0801 >/proc/sys/real-root-dev
```

It works!  Mostly.  I still get the errors above, but instead of a kernel panic the system actually boots!  On the other hand, if I comment the line out in linuxrc, the system doesn't boot at all (slightly different error message, though "cannot find device sda1" or something similar).  Can anyone help me figure out just what the heck is going on here?  Honestly, I don't think I ever had this much trouble with initrd when using Red Hat/Fedora.  Of course, Red Hat always used labels for mounting, not device names.

Arrgh!  At least I got it kinda working.  Any thoughts?

----------

## xoomix

Try appending a "real_root=/dev/blah" line in your Grub conf - using Genkernel shows you the exact verbiage at the end.

----------

## matthead

That doesn't work either.  I get the same error as before.  I expect  that /proc/sys/real-root-dev overrides it, since it's a post-boot action.

----------

## DamFam

I had this problem as well.

The problem was two-fold

First, there was no device listing for my root file system in the /dev directory of my initrd.

For example, my root filesystem ( / ) was on sda, partition 3. There was no listing in the /dev directory in the initramfs for sda3, only sda, and sda1 (which is my boot partition).

booting the livecd and mounting my partitions, I corrected that (uncompressing the initrd,  then mounting it, I went in and made a new node (mknod) for sda3)

this error:

mount: error 6 mounting ext3 

went away. The root filesystem was loaded, and ext3 was initialized.

I was still getting:

pivotroot: pivot_root(/sysroot,/sysroot/initrd) failed: 2

umount /initrd/proc failed: 2

However.

This is because you need a "initrd" directory on your root filesystem. 

Booted with the livecd, mounted my root partition and created the /initrd directory.

Unmounted, rebooted... and SUCCESS! The system boots without a single error.

Hope this helps.

----------

## matthead

No dice, unfortunately.  I created /dev/sda and /dev/sda1 nodes on the failing initrd, and the behavior is the same.

As for the second part, I do have an /initrd directory on the root fs.  Curiously, even with the working initrd I still get the pivot_root and umount errors.  I wonder if those have to do with whatever is causing the "error mounting ext3," which I also still get on the working initrd.  Once the system is booted and I login, I can "umount /initrd/proc; umount /initrd" with no problem.

Thanks for the suggestions!  I just wish they worked for me.  Of course, this also raises the question of why Gentoo's mkinitrd isn't creating the devices.

----------

## DamFam

 *matthead wrote:*   

> No dice, unfortunately.  I created /dev/sda and /dev/sda1 nodes on the failing initrd, and the behavior is the same.
> 
> As for the second part, I do have an /initrd directory on the root fs.  Curiously, even with the working initrd I still get the pivot_root and umount errors.  I wonder if those have to do with whatever is causing the "error mounting ext3," which I also still get on the working initrd.  Once the system is booted and I login, I can "umount /initrd/proc; umount /initrd" with no problem.
> 
> Thanks for the suggestions!  I just wish they worked for me.  Of course, this also raises the question of why Gentoo's mkinitrd isn't creating the devices.

 

Make sure ALL your filesystems are there.

/dev/sda is the disk device

/dev/sda1 is one partition (is this your /boot or "/" directory?) you need both in there.

Also,  make sure the node numbers are right.

For example, /dev/sda might be 8,0, /dev/sda1 8,1  /dev/sda2 8,2 etc etc

----------

## matthead

Yes, I understand the problem.  /dev/sda1 is my root filesystem; I did not separate /boot.  And /dev/sda1 is 0x0801 on every Linux machine I've ever been on, and that's what I created the node as.

```
logan ~:0# gunzip /boot/initrd-bad-2.6.16.16.gz

logan ~:0# mount -t ext2 -o loop /boot/initrd-bad-2.6.16.16 /mnt/cdrom

logan ~:0# ls -l /mnt/cdrom/dev

total 2

drwxr-xr-x  2 root root 1024 Nov  8 02:09 ./

drwxr-xr-x  9 root root 1024 Nov  4 15:02 ../

crw-r--r--  1 root root 5, 1 Nov  4 15:02 console

crw-r--r--  1 root root 1, 3 Nov  4 15:02 null

brw-r--r--  1 root root 1, 1 Nov  4 15:02 ram

brw-r--r--  1 root root 8, 0 Nov  8 02:09 sda

brw-r--r--  1 root root 8, 1 Nov  8 02:09 sda1

crw-r--r--  1 root root 4, 0 Nov  4 15:02 systty

crw-r--r--  1 root root 4, 1 Nov  4 15:02 tty1

crw-r--r--  1 root root 4, 2 Nov  4 15:02 tty2

crw-r--r--  1 root root 4, 3 Nov  4 15:02 tty3

crw-r--r--  1 root root 4, 4 Nov  4 15:02 tty4

```

You forgot to remind me to make sure that I created them as block devices, not character devices.   :Wink: 

Looking again at the linuxrc script, I see that it's supposed to make the necessary devices itself!  There's a line:

```
mkdevices /dev
```

The nash man page says that's supposed to create a node for everything in /proc/partitions.  I'll have to figure out what the contents of /proc/partitions is at that point in time.  But the linuxrc is still mounting "/dev/root" as the root filesystem, not "/dev/sda1."  I'm curious what your working linuxrc script looks like.  Does it have this junk about "echo 0x0100" into real-root-dev?

```
echo "Loading mptbase.ko module"

insmod /lib/mptbase.ko

echo "Loading mptscsih.ko module"

insmod /lib/mptscsih.ko

echo "Loading mptspi.ko module"

insmod /lib/mptspi.ko

echo Mounting /proc filesystem

mount -t proc /proc /proc

echo Creating block devices

mkdevices /dev

echo Creating root device

mkrootdev /dev/root

echo 0x0100 > /proc/sys/kernel/real-root-dev

echo Mounting root filesystem

mount -o defaults --ro -t ext3 /dev/root /sysroot

pivot_root /sysroot /sysroot/initrd

umount /initrd/proc

```

----------

## wynn

Just a tiny little point, shouldn't

```
mount -o defaults --ro -t ext3 /dev/root /sysroot
```

be

```
mount -o defaults,ro -t ext3 /dev/root /sysroot
```

There doesn't appear to be a --ro flag.

```
mount: error 6 mounting ext3
```

appears to be 

```
ENXIO            6      /* No such device or address */
```

which, as you've already found out, is due to the missing /dev/sda1

 *matthead wrote:*   

> Honestly, I don't think I ever had this much trouble with initrd when using Red Hat/Fedora. Of course, Red Hat always used labels for mounting, not device names
> 
> ```
> mkrootdev /dev/root
> 
> ...

 

From the nash manpage *Quote:*   

> mkrootdev path
> 
> Makes path a block inode for the device which should be mounted as root. To determine this device nash uses the device suggested by the root= kernel command line argument (if root=LABEL is used devices are probed to find one with that label).  If no root= argument is available, /proc/sys/kernel/real-root-dev provides the device number.

 So it seems that /dev/root is being made into /dev/sda1 (8,1) but, as /proc/sys/kernel/real-root-dev is being set to /dev/ram0 afterwards it should have no effect on what /dev/root is set to.

----------

## matthead

 *wynn wrote:*   

> There doesn't appear to be a --ro flag.

 

This is nash's builtin mount, not /bin/mount.  nash mount does have an --ro switch.

 *wynn wrote:*   

> So it seems that /dev/root is being made into /dev/sda1 (8,1) but, as /proc/sys/kernel/real-root-dev is being set to /dev/ram0 afterwards it should have no effect on what /dev/root is set to.

 

But I noted before that I still cannot boot with this initrd, even if I comment out the echo!  And that's with a root=/dev/sda1 kernel command line, and I've never commented out or removed the mkrootdev or mkdevices commands.

----------

