在笔记本上先装了ubuntu,用grub2启动,近来又装了个centos,grub启动还是用ubuntu上的,重启报错 switchroot: mount failed: No such file or directory. Kernel panic - not syncing: Attempted to kill init! 

google下有许多说是VFS问题(为内核不支持SATA硬盘),但我安装时SATA硬盘可以识别到,不需要boot:linux all-generic-ide irgpoil参数来安装。

差点重新编译内核,还是换个思路想一下,找到方法如下:

1、重新安装下grub(使用centos的),用centos安装盘重启进入linux results模式,

#chroot /mnt/sysp_w_picpath ***改变根目录***

#mount /dev/sda12 /mnt ***我的ubuntu为sda12***

#cp /mnt/boot/vmlinuz-2.6.35-22-generic /boot/

#cp /mnt/boot/initrd.img-2.6.35-22-generic /boot/

2、把ubuntu下的grub.cfg中的一段:

linux   /boot/vmlinuz-2.6.35-22-generic root=UUID=521d876a-432d-4bdb-94a6-e1374221c200 ro acpi=off  quiet splash
        initrd  /boot/initrd.img-2.6.35-22-generic

复制到centos中的grub.conf修改如下:

title Ubuntu
        root (hd0,7)
        kernel /boot/vmlinuz-2.6.35-22-generic root=UUID=521d876a-432d-4bdb-94a6-e1374221c200 ro single acpi=off

        initrd  /boot/initrd.img-2.6.35-22-generic

 

其中root (hd0,7)为centos根目录。

3、重启选择Ubuntu,会有一些提示,可能是内核重新找到"/"目录,自动重启一下,出现一个选择菜单,选择救援模式,出现tty1模式,startx搞定。

题外话:最后这个选择菜单还有一些root 选项(木有记住详细),难道是可以越狱了(ubuntu下没有root),有空大家可以试下,grub2竟然没有低版本的grub好用,很是费解。