今天在Debian VPS上更新内核时碰到了问题,报错为
Setting up linux-image-2.6.32-5-686-bigmem (2.6.32-31) ... Running depmod. Running update-initramfs. update-initramfs: Generating /boot/initrd.img-2.6.32-5-686-bigmem Examining /etc/kernel/postinst.d. run-parts: executing /etc/kernel/postinst.d/initramfs-tools 2.6.32-5-686-bigmem /boot/vmlinuz-2.6.32-5-686-bigmem run-parts: executing /etc/kernel/postinst.d/zz-update-grub 2.6.32-5-686-bigmem /boot/vmlinuz-2.6.32-5-686-bigmem Searching for GRUB installation directory ... found: /boot/grub warning: grub-probe can't find drive for /dev/xvda1. grub-probe: error: cannot find a GRUB drive for /dev/xvda1. Check your device.map. run-parts: /etc/kernel/postinst.d/zz-update-grub exited with return code 1 Failed to process /etc/kernel/postinst.d at /var/lib/dpkg/info/linux-image-2.6.32-5-686-bigmem.postinst line 799, line 2. dpkg: error processing linux-image-2.6.32-5-686-bigmem (--configure): subprocess installed post-installation script returned error exit status 2
之前在给公司的VPS作配置的时候也遇到了一样的问题,都是Xen的VPS,装的是Debian的系统,当时就只是把kernel的更新给keep了。今天自己碰到了一样的问题就细细琢磨了一下。看报错的情况是在更新Kernel的时候,没有找到装有GRUB的设备。下面是我解决的步骤:
解决方法:
-
检查/dev/目录下是否存在/dev/xvda的设备块,如果没有就建一个,在XEN的Debian VPS下面会把硬盘认认成是xvdXX的。
# mknod /dev/xvda b 202 0
-
修改/boot/grub/device.map文件,这个文件是grub用来跟磁盘设备作对应关系的:
# vim /boot/grub/device.map
将
# (hd0) /dev/sda
改成:
# (hd0) /dev/xvda
-
修改/usr/sbin/update-grub文件,这个文件是用来更新grub的menu.lst/grub.cfg的,
# vim /usr/sbin/update-grub
将
find_device () { if ! test -e ${device_map} ; then echo quit | grub --batch --no-floppy --device-map=${device_map} > /dev/null fi grub-probe --device-map=${device_map} -t device $1 2 > /dev/null }
改成
find_device () { if ! test -e ${device_map} ; then echo quit | grub --batch --no-floppy --device-map=${device_map} > /dev/null fi #grub-probe --device-map=${device_map} -t device $1 2 > /dev/null echo /dev/xvda }
-
更新一下grub:
# update-grub 0
-
最后,修改/boot/grub/menu.lst文件
# vim /boot/grub/menu.lst
找到“root=/dev/xvda ro quiet”把它改回成“root=/dev/xvda1 ro quiet”,否则会无法启动机器,应该像这样:。
... title Debian GNU/Linux, kernel 2.6.32-5-xen-amd64 root (hd0,0) kernel /boot/vmlinuz-2.6.32-5-xen-amd64 root=/dev/xvda1 ro quiet initrd /boot/initrd.img-2.6.32-5-xen-amd64 ...
OK,接去再执行 apt-get install 应该不会有问题了。