XCP之重新编译内核--增加IMA
2012-01-05 15:07
253 查看
因为实验室项目需要,要在XCP1.1上的dom0重新编译内核,把IMA部分添加进去。
在完成这个任务时,碰到了许多问题,具体问题、解决方法及步骤如下:
1. XCP的dom0默认只分配了4GB的空间,如果要在上面编译内核,这点容量显然是不够的。解决方法:使用LVM方式分配一个LV,在分配的LV上编译内核。步骤:
a. 分配LV(第一次)
lvcreat -L 20G -n for_dom0 VG_XenStorage-d49b8a25-73f2-8cb7-93a3-e0d8b81054d8
b. 分区LV的格式化
mke2fs -j /dev/VG_XenStorage-d49b8a25-73f2-8cb7-93a3-e0d8b81054d8/for_dom0
c. 把LV挂载到指定目录
mount //dev/VG_XenStorage-d49b8a25-73f2-8cb7-93a3-e0d8b81054d8/for_dom0 /mnt/lvm_dom0
d. 激活VG (第一次不用,当LV失效时,挂载前激活)
vgchange -a y VG_XenStorage-d49b8a25-73f2-8cb7-93a3-e0d8b81054d8
2. IMA配置
把内核源码在LV上解压后,进入源码目录。
a. cd drivers/char/tpm
vim tpm_tis.c:
static int interrupts=1 -> static int interrupts=0;
static int force -> static int force=1
b. make menuconfig
select IMA
# configure other relative options
d. make
make modules
make modules_install
make install
3. bootloader的配置遇到的问题及解决方法
由于XCP自带了grub0.97版本,又没有使用它做引导,一开始傻傻的使用grub-install /dev/sda 命令重新配了一下grub,还把grub装在了MBR和/dev/sda1的超级块中了(分别在grub shell中,使用setup (hd0) 和setup(hd0,0) )。后来才发现XCP原来用的是extlinux的启动引导器......
后果是重启后,进入了grub shell,怎么配置也进不了系统。解决方法是:
a. 使用U盘引导进U盘的Ubuntu(安装Ubuntu时的Try Ubuntu选项)
b. crtl+alt+T进入shell终端,重配root密码(sudo passwd)
c. su进入root shell后,使用fdisk -l查看需要修复引导盘的路径,我这里是/dev/sdb1
d. 把/dev/sdb1 挂载在/mnt上: mount /dev/sdb1 /mnt
e. 给/mnt/boot/目录下的chain.c32建立硬链接extlinux
f. 重建启动引导程序: extlinux -i /mnt/boot
g. 重启,问题解决,可以重新进入XCP server了
4. bootloader配置(编辑extlinux.conf)
a. 进入/boot路径,编辑extlinux.conf
b. 编译修改如下(仅供参考):
5. 编辑 /etc/fstab
加入一行:
6. 重启后,可以查看度量列表了。
vi /sys/kernel/security/ima/ascii_runtime_measurements
在完成这个任务时,碰到了许多问题,具体问题、解决方法及步骤如下:
1. XCP的dom0默认只分配了4GB的空间,如果要在上面编译内核,这点容量显然是不够的。解决方法:使用LVM方式分配一个LV,在分配的LV上编译内核。步骤:
a. 分配LV(第一次)
lvcreat -L 20G -n for_dom0 VG_XenStorage-d49b8a25-73f2-8cb7-93a3-e0d8b81054d8
b. 分区LV的格式化
mke2fs -j /dev/VG_XenStorage-d49b8a25-73f2-8cb7-93a3-e0d8b81054d8/for_dom0
c. 把LV挂载到指定目录
mount //dev/VG_XenStorage-d49b8a25-73f2-8cb7-93a3-e0d8b81054d8/for_dom0 /mnt/lvm_dom0
d. 激活VG (第一次不用,当LV失效时,挂载前激活)
vgchange -a y VG_XenStorage-d49b8a25-73f2-8cb7-93a3-e0d8b81054d8
2. IMA配置
把内核源码在LV上解压后,进入源码目录。
a. cd drivers/char/tpm
vim tpm_tis.c:
static int interrupts=1 -> static int interrupts=0;
static int force -> static int force=1
b. make menuconfig
select IMA
# configure other relative options
d. make
make modules
make modules_install
make install
3. bootloader的配置遇到的问题及解决方法
由于XCP自带了grub0.97版本,又没有使用它做引导,一开始傻傻的使用grub-install /dev/sda 命令重新配了一下grub,还把grub装在了MBR和/dev/sda1的超级块中了(分别在grub shell中,使用setup (hd0) 和setup(hd0,0) )。后来才发现XCP原来用的是extlinux的启动引导器......
后果是重启后,进入了grub shell,怎么配置也进不了系统。解决方法是:
a. 使用U盘引导进U盘的Ubuntu(安装Ubuntu时的Try Ubuntu选项)
b. crtl+alt+T进入shell终端,重配root密码(sudo passwd)
c. su进入root shell后,使用fdisk -l查看需要修复引导盘的路径,我这里是/dev/sdb1
d. 把/dev/sdb1 挂载在/mnt上: mount /dev/sdb1 /mnt
e. 给/mnt/boot/目录下的chain.c32建立硬链接extlinux
f. 重建启动引导程序: extlinux -i /mnt/boot
g. 重启,问题解决,可以重新进入XCP server了
4. bootloader配置(编辑extlinux.conf)
a. 进入/boot路径,编辑extlinux.conf
b. 编译修改如下(仅供参考):
label ima kernel mboot.c32 append /boot/xen.gz dom0_mem=752M lowmem_emergency_pool=1M crashkernel=64M@32M console= vga=mode-0x0311 --- /boot/vmlinuz root=LABEL=root-eqxvlexh ro xencons=hvc console=hvc0 console=tty0 quiet vga=785 splash ima_tcb=1 --- /boot/initrd-2.6.32.12-0.7.1.img
5. 编辑 /etc/fstab
加入一行:
securityfs /sys/kernel/security securityfs rw 0 0
6. 重启后,可以查看度量列表了。
vi /sys/kernel/security/ima/ascii_runtime_measurements
相关文章推荐
- 增加Linux系统调用——通过重新编译内核
- 重新编译Linux内核必要性及其准备工作
- S3C2440重新编译内核及移植QT4.7.3
- 重新编译了一个内核无法启动,
- linux重新编译安装gd,增加freetype支持,解决验证码不显示问题,Fatal error: Call to undefined function imagettftext()
- centos+6.0源码安装xen4.1.1(xen成功安装,但是在重新编译内核时有点小问题)
- 编译内核报错:"mkimage" command not found - U-Boot ima...
- 网卡始终不通的原因?改了linux内核后要重新编译insmod安装的模块
- Centos5.3编译内核增加connlimit模块并升级Iptables
- 嵌入式开发实战4——内核的编译之三增加对NAND支持编译
- linux内核里增加源代码编译
- ubuntu12.04重新编译内核
- 如何在ubuntu下重新编译内核
- 利用模块添加系统调用(不重新编译内核)
- 内核:为了fan的健康,我的重新编译记录
- 不重新编译为 PHP 增加 LDAP 模块
- 第一章-任务1:Linux内核的重新编译,安装,重启
- 内核重新编译之make install和生成initramfs的过程分析