Chinaunix首页 | 论坛 | 博客
  • 博客访问: 33369
  • 博文数量: 29
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 0
  • 用 户 组: 普通用户
  • 注册时间: 2015-10-31 10:55
文章分类

全部博文(29)

文章存档

2015年(29)

我的朋友

分类: LINUX

2015-10-31 11:37:49

原文地址:user mode linux 作者:Renwen0524

 UML是指用户模式的Linux。顾名思义,就是让Linux系统作为一个用户进程运行。UML为研究Linux内核代码提供了一种便利的方式,整个Linux系统完全是一个用户进程,可以像调试普通用户进程一样调试它。Linux内核把不同平台称为一个ARCH,每个ARCH实现依赖于特定硬件平台的功能,UML作为一个ARCH来实现,用软件模拟了硬件功能。Linux内核2.6.16及后续版本已经集成了UML,使用UML的具体过程如下:
1.下载最新的Linux内核,版本是3.14.2
2.解压
new@new-Aspire-V5-471G:/usr/local/src$ tar Jxvf linux-3.14.2.tar.xz
3.配置内核,推荐使用xconfig,非常直观,图形界面,需要安装Qt,非常稳定。
new@new-Aspire-V5-471G:/usr/local/src/linux-3.14.2$ sudo apt-get install qt4-dev-tools qt4-doc qt4-qtconfig qt4-demos qt4-designer
new@new-Aspire-V5-471G:/usr/local/src/linux-3.14.2$ sudo make ARCH=um xconfig
首先请确保UML内核编译时已经选上这么几项:
— Block devices
[*] Virtual block device
[*] Always do synchronous disk IO for UBD
其次,如果你的根文件系统是ext4的,请确保选中:
File systems —>
<*> The Extended 4 (ext4) filesystem
其它文件系统类似。
另外几个选项也建议选上:将以虚拟设备作为网络设备:
[*] Networking support —>
UML Network Devices —>
[*] Virtual network device
[*] Ethertap transport
[*] TUN/TAP transport
使用UML大部分是为了调内核,这两个选项必不可少:
Kernel hacking —>
[*] Compile the kernel with debug info
[*] Compile the kernel with frame pointers
4.编译内核
new@new-Aspire-V5-471G:/usr/local/src/linux-3.14.2$ sudo make ARCH=um
5.安装内核
new@new-Aspire-V5-471G:/usr/local/src/linux-3.14.2$ sudo cp linux /usr/local/bin/
6.制作根文件系统。
new@new-Aspire-V5-471G:/usr/local/src/um$ dd if=/dev/zero of=root_fs seek=500 count=1 bs=1M
new@new-Aspire-V5-471G:/usr/local/src/um$ mkfs.ext4 ./root_fs
new@new-Aspire-V5-471G:/usr/local/src/um$ mkdir /mnt/rootfs
new@new-Aspire-V5-471G:/usr/local/src/um$ mount -o loop root_fs /mnt/rootfs/
(拷贝你需要的文件:因为只是研究内核,拷贝一些基本的运行库、可执行文件和配置文件就行了)
new@new-Aspire-V5-471G:/usr/local/src/um$ umount /mnt/rootfs/
网上有很多制作好的根文件系统,如果目的只是研究内核,从网上下载根文件系统最方便的选择。
7.制作交换分区
new@new-Aspire-V5-471G:/usr/local/src/um$ dd if=/dev/zero of=swap_fs seek=500 count=1 bs=1M
new@new-Aspire-V5-471G:/usr/local/src/um$ mkswap ./swap_fs
8.正常运行。
new@new-Aspire-V5-471G:/usr/local/src/um$ linux ubd0=root_fs ubd1=swap_fs
9.调试运行。
gdb linux
(gdb) b start_kernel
(gdb) r ubd0=root_fs ubd1=swap_fs

阅读(232) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~