您的位置:首页 > 其它

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. 编译修改如下(仅供参考):

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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: