陈磊
unread,Mar 2, 2011, 10:54:51 PM3/2/11Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Sign in to report message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to xiyoulinux
我的环境是ubuntu10.04 2.6.32-24的内核 编写模块
这个是makefile
obj-m := hello.o
kernel_path = /usr/src/linux-headers-$(shell uname -r)
all:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
clean:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
执行make命令时提示
make -C /lib/modules/2.6.32-24-generic/build M=/home/lost/Programs/C modules
make[1]: Entering directory `/usr/src/linux-headers-2.6.32-24-generic'
CC [M] /home/lost/Programs/C/hello.o
In file included from include/linux/gfp.h:4,
from include/linux/kmod.h:22,
from include/linux/module.h:13,
from /home/lost/Programs/C/hello.c:2:
include/linux/mmzone.h:18:26: error: linux/bounds.h: No such file or directory
include/linux/mmzone.h:258:5: warning: "MAX_NR_ZONES" is not defined
include/linux/mmzone.h:260:7: warning: "MAX_NR_ZONES" is not defined
include/linux/mmzone.h:262:7: warning: "MAX_NR_ZONES" is not defined
In file included from include/linux/gfp.h:4,
from include/linux/kmod.h:22,
from include/linux/module.h:13,
from /home/lost/Programs/C/hello.c:2:
include/linux/mmzone.h:300: error: ‘MAX_NR_ZONES’ undeclared here (not in a function)
make[2]: *** [/home/lost/Programs/C/hello.o] Error 1
make[1]: *** [_module_/home/lost/Programs/C] Error 2
make[1]: Leaving directory `/usr/src/linux-headers-2.6.32-24-generic'
make: *** [all] Error 2
其中那个bounds.h 找不到... 在网上各种资料查找后 说可能在编译内核的时候make clean 过 所以那个h文件就被删除了 解决方法是
在 /lib/modules/2.6.32-24-generic/build 下 执行make prepare
make prepare 之后再次提示错误
CHK include/linux/version.h
CHK include/linux/utsrelease.h
SYMLINK include/asm -> include/asm-x86
make[1]: *** No rule to make target `kernel/bounds.c', needed by `kernel/bounds.s'. Stop.
make: *** [prepare0] Error 2
再次谷歌百度...
网上说可以通过重新编译内核解决...请问学长对上述问题有什么解决办法么??
于是手动开始重新编译内核 下载最新稳定版本 2.6.37.2
重新编译后 sudo update-grub
重启...
载入内核成功 但是又出现错误...
"an error occured while mounting /"
“press s to skip or m for manual ....”
但是按下s 之后进入控制台界面 在控制台界面下登录正常 但是不能进入ubuntu的图形界面
在控制台界面下输入
uname -r
显示
2.6.23.2
输入df -l
显示 / 已经被挂载...
继续谷歌百度...
网上有类似的问题 但没有说挂不上根文件系统的...
我列举一下我的fstab 文件 和grub.cfg 文件
#fstab
#proc /proc proc nodev,noexec,nosuid 0 0
# / was on /dev/sda8 during installation
UUID=4b4a8477-0ed0-4bf8-9c32-f2d2b1132bfc / ext4 errors=remount-ro 0 1
# swap was on /dev/sda9 during installation
UUID=4e8ae8ce-2f32-40d2-9483-0f33c24547ad none swap sw 0 0
/dev/sda6 /media/MEDIA ntfs auto,rw 0 0
/dev/sda1 /media/SYSTEM ntfs auto,rw 0 0
#grub
if [ -s $prefix/grubenv ]; then
load_env
fi
set default="0"
if [ ${prev_saved_entry} ]; then
set saved_entry=${prev_saved_entry}
save_env saved_entry
set prev_saved_entry=
save_env prev_saved_entry
set boot_once=true
fi
function savedefault {
if [ -z ${boot_once} ]; then
saved_entry=${chosen}
save_env saved_entry
fi
}
function recordfail {
set recordfail=1
if [ -n ${have_grubenv} ]; then if [ -z ${boot_once} ]; then save_env recordfail; fi; fi
}
insmod ext2
set root='(hd0,8)'
search --no-floppy --fs-uuid --set 4b4a8477-0ed0-4bf8-9c32-f2d2b1132bfc
if loadfont /usr/share/grub/unicode.pf2 ; then
set gfxmode=640x480
insmod gfxterm
insmod vbe
if terminal_output gfxterm ; then true ; else
# For backward compatibility with versions of terminal.mod that don't
# understand terminal_output
terminal gfxterm
fi
fi
insmod ext2
set root='(hd0,8)'
search --no-floppy --fs-uuid --set 4b4a8477-0ed0-4bf8-9c32-f2d2b1132bfc
set locale_dir=($root)/boot/grub/locale
set lang=en
insmod gettext
if [ ${recordfail} = 1 ]; then
set timeout=-1
else
set timeout=10
fi
### END /etc/grub.d/00_header ###
### BEGIN /etc/grub.d/05_debian_theme ###
set menu_color_normal=white/black
set menu_color_highlight=black/light-gray
### END /etc/grub.d/05_debian_theme ###
### BEGIN /etc/grub.d/10_linux ###
menuentry 'Ubuntu, with Linux 2.6.37.2' --class ubuntu --class gnu-linux --class gnu --class os {
recordfail
insmod ext2
set root='(hd0,8)'
search --no-floppy --fs-uuid --set 4b4a8477-0ed0-4bf8-9c32-f2d2b1132bfc
linux /boot/vmlinuz-2.6.37.2 root=/dev/sda8 ro quiet splash
}
menuentry 'Ubuntu, with Linux 2.6.37.2 (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os {
recordfail
insmod ext2
set root='(hd0,8)'
search --no-floppy --fs-uuid --set 4b4a8477-0ed0-4bf8-9c32-f2d2b1132bfc
echo 'Loading Linux 2.6.37.2 ...'
linux /boot/vmlinuz-2.6.37.2 root=/dev/sda8 ro single
echo 'Loading initial ramdisk ...'
}
menuentry 'Ubuntu, with Linux 2.6.32-24-generic' --class ubuntu --class gnu-linux --class gnu --class os {
recordfail
insmod ext2
set root='(hd0,8)'
search --no-floppy --fs-uuid --set 4b4a8477-0ed0-4bf8-9c32-f2d2b1132bfc
linux /boot/vmlinuz-2.6.32-24-generic root=UUID=4b4a8477-0ed0-4bf8-9c32-f2d2b1132bfc ro quiet splash
initrd /boot/initrd.img-2.6.32-24-generic
}
menuentry 'Ubuntu, with Linux 2.6.32-24-generic (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os {
recordfail
insmod ext2
set root='(hd0,8)'
search --no-floppy --fs-uuid --set 4b4a8477-0ed0-4bf8-9c32-f2d2b1132bfc
echo 'Loading Linux 2.6.32-24-generic ...'
linux /boot/vmlinuz-2.6.32-24-generic root=UUID=4b4a8477-0ed0-4bf8-9c32-f2d2b1132bfc ro single
echo 'Loading initial ramdisk ...'
initrd /boot/initrd.img-2.6.32-24-generic
}
### END /etc/grub.d/10_linux ###
### BEGIN /etc/grub.d/20_memtest86+ ###
menuentry "Memory test (memtest86+)" {
insmod ext2
set root='(hd0,8)'
search --no-floppy --fs-uuid --set 4b4a8477-0ed0-4bf8-9c32-f2d2b1132bfc
linux16 /boot/memtest86+.bin
}
menuentry "Memory test (memtest86+, serial console 115200)" {
insmod ext2
set root='(hd0,8)'
search --no-floppy --fs-uuid --set 4b4a8477-0ed0-4bf8-9c32-f2d2b1132bfc
linux16 /boot/memtest86+.bin console=ttyS0,115200n8
}
### END /etc/grub.d/20_memtest86+ ###
### BEGIN /etc/grub.d/30_os-prober ###
menuentry "Microsoft Windows XP Professional (on /dev/sda1)" {
insmod ntfs
set root='(hd0,1)'
search --no-floppy --fs-uuid --set 06d07950d07946c9
drivemap -s (hd0) ${root}
chainloader +1
}
求指教...