XCP之重新编译内核--增加IMA

  因为实验室项目需要,要在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 

 

 

 

 

 

 

 

 

 

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值