# Kernel Panic, pivot_root failed. [SOLVED]

## sputnik_uk

I'm dual booting ubuntu and gentoo, I get the following lines as the kernel dies:

pivot root :pivot_root (/sysrroot, /sysroot, initrd ) failed : 2

umount /initrd/proc failed : 2

kernel panic - not syncing: no init found.

ubuntu is installed on hda1,

gentoo is installed on hda2.

What's wierd is, when I run grub-install it complains it can't find /dev/ROOT, so I symlinked it to /dev/hda2. I think this may be the cause of my problems. AFAIK the livecd references /dev/ROOT, /etc/fstab doesn't.

Using 2.6.20.3 kernel. mkinitrd initrd.img-2.6.20.3 2.6.20.3

kernel has been copied to /boot/vmlinuz-2.6.20.3

Modules have been instaleld using depmod.

I've run grub: root (hd0,1) setup (hd0).

Here's the lines from /boot/grub/menu.lst:

 *Quote:*   

> 
> 
> title           Gentoo, kernel 2.6.20.3
> 
> root            (hd0,1)
> ...

 

/etc/fstab

 *Quote:*   

> 
> 
> # <fs>                  <mountpoint>    <type>          <opts>          <dump/pass>
> 
> #proc
> ...

 Last edited by sputnik_uk on Fri Jan 18, 2008 4:10 pm; edited 6 times in total

----------

## yabbadabbadont

http://www.gentoo.org/doc/en/handbook/handbook-x86.xml?part=1&chap=10#doc_chap2

Take a close look at code listing 4.

----------

## sputnik_uk

Thanks yabbadabbadont.

Still get the same error message, (pivot) then goes on as below:

"cannot create /dev/hda /dev/hdb etc.  then the kernel panics saying "trying to kill init".

Built loopback, RAMdisk support, ext2 and ext3 into the kernel.

Any ideas greatly appreciated.

----------

## selig

First, make sure that the directory /initrd inside your Gentoo root (hda2) exists. It is crucial for pivot_root. If yes and the problem persists, try the following:

Obviously it is a problem with your initrd. Maybe you could mount it and look at its insides?

```

cp /boot/initrd.img-2.6.20.3 /tmp/initrd.gz

gunzip /tmp/initrd.gz

mkdir /tmp/initrd_root

mount -t ext2 -o loop,rw /tmp/initrd /tmp/initrd_root

ls -lR /tmp/initrd_root

```

The problem with your setup probably is that you do not have any tmpfs or something writable in the initial root (the one that you see inside this initrd) /dev directory. Or maybe the kernel modules for the devices/filesystems are not present in the initrd and/or do not get loaded by the script. mkinitrd sometimes does not create proper images... You should create the needed nodes if they are not present:

```

cd /tmp/initrd_root/dev

ls -l

# now create what is missing

mknod hda b 3 0

mknod hda1 b 3 1

mknod hda2 b 3 2

ln -s hda2 root

```

When you are satisfied, you can unmount it, compress and use it:

```

cd

umount /tmp/initrd_root

gzip /tmp/initrd

cp /tmp/initrd.gz /boot/initrd.img-2.6.20.3-new

```

And modify your grub.conf to include the new initrd. On the other hand, I have never used grub-install, you might have better luck with running grub and installing it manually.

I hope this helps... if not, post the results.   :Wink: 

----------

## sputnik_uk

Adding the /initrd directory solved teh pivot root problem, but it seems the kernel can't write to it's bootup (sysroot?) directory before mounting /dev/hda2.  

/linuxrc:

 *Quote:*   

> 
> 
> #!/bin/nash
> 
> echo Mounting /proc filesystem
> ...

 

Here's the Kernel output:

 *Quote:*   

> 
> 
> VFS: Mounted Root (ext2) Readonly
> 
> mounting /proc
> ...

 

----------

## sputnik_uk

Was using the wrong kernel bootup options, needed set 3 from

http://www.gentoo.org/doc/en/handbook/handbook-x86.xml?part=1&chap=10#doc_chap2

----------

## sputnik_uk

Well I've come back to Gentoo gaving had a break.

The same problems still persist, opnly this time I can;'t mount the initrd image as mentioend previously in this thread

```

ubuntu tmp # mv /boot/initrd.img-2.6.21.3 /tmp/initrd.img.gz

ubuntu tmp # gunzip initrd.g

gunzip: initrd.g.gz: No such file or directory

ubuntu tmp # gunzip initrd.img.gz 

ubuntu tmp # mount -t ext2 -o loop initrd.img initrd_root/

mount: wrong fs type, bad option, bad superblock on /dev/loop1,

       missing codepage or other error

       In some cases useful info is found in syslog - try

       dmesg | tail  or so

ubuntu tmp # 

```

What kind of filesystem is initrd.img?  I've tried ext2 and tmpfs, or am I having problems with mounting loop devices?

Thanks in advance.

      Rob.

----------

## sputnik_uk

Fixed by using "genkernel initrd"

----------

