colinux+ubuntu7.10 下实现UML

1)下载linux内核
 
#wget –c http://kernel.org/pub/linux/kernel/v2.6/linux-2.6.24.2.tar.bz2
#tar –xvjf linux-2.6.24.2.tar.bz2
 
2)编译UML内核
#cd linux-2.6.24.2
#make ARCH=um defconfig
#make ARCH=um menuconfig
#make ARCH=um linux
 
完事uml的linux编译好了,那我们建立一个ext3根文件系统
 
3)建立UML的文件系统
#mkdir uml
#cd uml
#dd if=/dev/zero of=root_fs bs=1M count=500
#mke2fs -j root_fs
 
#dd if=/dev/zero of=swap bs=1M count=128
 
将新建文件系统挂在/mnt/tmp,将光盘iso也挂接到/mnt/cdrom0/
debootstrap命令为我们建立一个基础linux系统
 
4)安装基础系统到新建文件系统
#mount -o loop root_fs /mnt/tmp
#mount -o loop /root/ubuntu710.iso /mnt/cdrom0/
debootstrap --arch i386 gutsy /mnt/tmp file:///mnt/cdrom0/
 
5)修改安装的基础系统中的文件
 
修改基础系统中的/etc/fstab为如下
 
/dev/ubd0     /     ext3     defaults     0 1
proc  /     proc     proc     defaults     0 0
 

在基础系统建立设备文件ubd0
#cd /mnt/tmp/dev
#mknod --mode=660 ubd0 b 98 0
#mknod --mode=660 ubd1 b 98 1

#chown root:disk ubd0
 
修改基础系统上主机文件
cd /mnt/tmp/etc/hosts
 
127.0.0.1 localhost
 

修改基础系统上网络接口文件
cd /mnt/tmp/etc/networking/interfaces
 
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static
    address 192.168.0.201
    netmask 255.255.255.0
    network 192.168.0.0
    broadcast 192.168.0.255
    gateway 192.168.0.1
 

配置tty0
#echo "tty0" >> /mnt/tmp/etc/securetty
#echo "ttys/0" >> /mnt/etc/securetty
 
#rm /mnt/tmp/etc/event.d/tty2
#rm /mnt/tmp/etc/event.d/tty3
#rm /mnt/tmp/etc/event.d/tty4
#rm /mnt/tmp/etc/event.d/tty5
#rm /mnt/tmp/etc/event.d/tty6
 

#rm /mnt/tmp/etc/udev/rules.d/75-persistent-net-generator.rules
 
5)安装编译好的UML模块
 
root@ubuntu:/usr/src/linux-2.6.24.2# make modules_install INSTALL_MOD_PATH=/mnt/tmp/
  DEPMOD  2.6.24.2
root@ubuntu:/usr/src/linux-2.6.24.2#

#umount /mnt/tmp
 
 
 
6)运行编译好的UML
 
root@ubuntu:/usr/src/linux-2.6.24.2# ./linux ubd0=/root/uml/root_fs ubd1=/root/uml/swap
Core dump limits :
        soft - 0
        hard - NONE
Checking that ptrace can change system call numbers...OK
Checking syscall emulation patch for ptrace...OK
Checking advanced syscall emulation patch for ptrace...OK
Checking for tmpfs mount on /dev/shm...OK
Checking PROT_EXEC mmap in /dev/shm/...OK
Checking for the skas3 patch in the host:
  - /proc/mm...not found: No such file or directory
  - PTRACE_FAULTINFO...not found
  - PTRACE_LDT...not found
UML running in SKAS0 mode
Linux version 2.6.24.2 (root@ubuntu) (gcc version 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2))
#1 Tue Jun 24 05:40:41 EDT 2008
Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 8128
Kernel command line: ubd0=/root/uml/root_fs root=98:0
PID hash table entries: 128 (order: 7, 512 bytes)
Dentry cache hash table entries: 4096 (order: 2, 16384 bytes)
Inode-cache hash table entries: 2048 (order: 1, 8192 bytes)
Memory: 30192k available
Mount-cache hash table entries: 512
Checking for host processor cmov support...Yes
Checking for host processor xmm support...No
Checking that host ptys support output SIGIO...Yes
Checking that host ptys support SIGIO on close...No, enabling workaround
net_namespace: 64 bytes
Using 2.6 host AIO
NET: Registered protocol family 16
NET: Registered protocol family 2
Time: itimer clocksource has been installed.
IP route cache hash table entries: 1024 (order: 0, 4096 bytes)
TCP established hash table entries: 1024 (order: 1, 8192 bytes)
TCP bind hash table entries: 1024 (order: 0, 4096 bytes)
TCP: Hash tables configured (established 1024 bind 1024)
TCP reno registered
Checking host MADV_REMOVE support...OK
mconsole (version 2) initialized on /root/.uml/Ln7mDE/mconsole
Host TLS support detected
Detected host type: i386
VFS: Disk quotas dquot_6.5.1
Dquot-cache hash table entries: 1024 (order 0, 4096 bytes)
io scheduler noop registered
io scheduler anticipatory registered (default)
io scheduler deadline registered
io scheduler cfq registered
TCP cubic registered
NET: Registered protocol family 1
NET: Registered protocol family 17
Initialized stdio console driver
Console initialized on /dev/tty0
console [tty0] enabled
Initializing software serial port version 1
console [mc-1] enabled
 ubda: unknown partition table
kjournald starting.  Commit interval 5 seconds
EXT3-fs: mounted filesystem with ordered data mode.
VFS: Mounted root (ext3 filesystem) readonly.
 * Setting preliminary keymap...
Couldnt get a file descriptor referring to the console
Couldnt get a file descriptor referring to the console
Couldnt get a file descriptor referring to the console
Couldnt get a file descriptor referring to the console
Couldnt get a file descriptor referring to the console
Couldnt get a file descriptor referring to the console

 * Setting the system clock                                         [ OK ]
 hwclock is unable to get I/O port access:  the iopl(3) call failed.
 * Unable to set System Clock to: Wed Jun 25 03:08:16 UTC 2008
 * Starting basic networking...                                     [ OK ]
 * Starting kernel event manager...                                 [ OK ]
 * Loading hardware drivers...                                      [ OK ]
 * Setting the system clock
hwclock is unable to get I/O port access:  the iopl(3) call failed.
 * Unable to set System Clock to: Wed Jun 25 03:08:27 UTC 2008

 * Loading kernel modules...                                        [ OK ]
 * Activating swap...                                               [ OK ]
 * Checking root file system...
 fsck 1.40.2 (12-Jul-2007)
/dev/shm/root: clean, 11872/122400 files, 209933/488280 blocks      [ OK ]
EXT3-fs: Unrecognized mount option "proc" or missing value
[mntent]: line 3 in /etc/fstab is bad
EXT3-fs: Unrecognized mount option "proc" or missing value
mount: / not mounted already, or bad option
 * Checking file systems...
 fsck 1.40.2 (12-Jul-2007)                                          [ OK ]
 * Mounting local filesystems...
 [mntent]: line 3 in /etc/fstab is bad                              [ OK ]
 * Activating swapfile swap...                                      [ OK ]
/etc/init.d/bootclean: 143: cannot create /tmp/.clean: Read-only file system
 * Checking minimum space in /tmp...                                [ OK ]
mv: cannot create regular file `/var/log/udev': Read-only file system
 * Configuring network interfaces...                                 [ OK ]
/etc/init.d/bootclean: 143: cannot create /tmp/.clean: Read-only file system
line_ioctl: tty0: unknown ioctl: 0x541e
line_ioctl: tty0: unknown ioctl: 0x5603
touch: cannot touch `/var/log/dmesg.new': Read-only file system
chown: cannot access `/var/log/dmesg.new': No such file or directory
chmod: cannot access `/var/log/dmesg.new': No such file or directory
ln: creating hard link `/var/log//dmesg.0' to `/var/log/dmesg': Read-only file system
Error hardlinking /var/log/dmesg to /var/log//dmesg.0
/etc/rcS.d/S80bootmisc.sh: 81: cannot create /var/log/dmesg: Read-only file system
chgrp: changing group of `/var/log/dmesg': Read-only file system
 * Starting system log daemon...
chown: changing ownership of `/var/log/mail.warn': Read-only file system
chown: changing ownership of `/var/log/user.log': Read-only file system
chown: changing ownership of `/var/log/daemon.log': Read-only file system
chown: changing ownership of `/var/log/messages': Read-only file system
chown: changing ownership of `/var/log/debug': Read-only file system
chown: changing ownership of `/var/log/auth.log': Read-only file system
chown: changing ownership of `/var/log/mail.err': Read-only file system
chown: changing ownership of `/var/log/syslog': Read-only file system
chown: changing ownership of `/var/log/mail.log': Read-only file system
chown: changing ownership of `/var/log/kern.log': Read-only file system
chown: changing ownership of `/var/log/lpr.log': Read-only file system
chown: changing ownership of `/var/log/mail.info': Read-only file system
  syslogd: /var/log/auth.log: Read-only file system
  syslogd: /var/log/syslog: Read-only file system
  syslogd: /var/log/daemon.log: Read-only file system
  syslogd: /var/log/kern.log: Read-only file system
  syslogd: /var/log/lpr.log: Read-only file system
  syslogd: /var/log/mail.log: Read-only file system
  syslogd: /var/log/user.log: Read-only file system
  syslogd: /var/log/mail.info: Read-only file system
  syslogd: /var/log/mail.warn: Read-only file system
  syslogd: /var/log/mail.err: Read-only file system
  syslogd: /var/log/news/news.crit: Read-only file system
  syslogd: /var/log/news/news.err: Read-only file system
  syslogd: /var/log/news/news.notice: Read-only file system
  syslogd: /var/log/debug: Read-only file system
  syslogd: /var/log/messages: Read-only file system                   [ OK ]
 * Starting kernel log daemon...                                      [ OK ]
 * Running local boot scripts (/etc/rc.local)                         [ OK ]

弄个inittab文件到/etc/
 
#
# inittab       This file describes how the INIT process should set up
#               the system in a certain run-level.
#
# Author:       Miquel van Smoorenburg, <miquels@drinkel.nl.mugnet.org>
#               Modified for RHS Linux by Marc Ewing and Donnie Barnes
#
 
# Default runlevel. The runlevels used by RHS are:
#   0 - halt (Do NOT set initdefault to this)
#   1 - Single user mode
#   2 - Multiuser, without NFS (The same as 3, if you do not have networking)
#   3 - Full multiuser mode
#   4 - unused
#   5 - X11
#   6 - reboot (Do NOT set initdefault to this)
#
id:3:initdefault:
 
# System initialization.
si::sysinit:/etc/rc.d/rc.sysinit
 
l0:0:wait:/etc/rc.d/rc 0
l1:1:wait:/etc/rc.d/rc 1
l2:2:wait:/etc/rc.d/rc 2
l3:3:wait:/etc/rc.d/rc 3
l4:4:wait:/etc/rc.d/rc 4
l5:5:wait:/etc/rc.d/rc 5
l6:6:wait:/etc/rc.d/rc 6
 
# Things to run in every runlevel.
ud::once:/sbin/update
 
# Trap CTRL-ALT-DELETE
ca::ctrlaltdel:/sbin/shutdown -t3 -r now
 
# When our UPS tells us power has failed, assume we have a few minutes
# of power left.  Schedule a shutdown for 2 minutes from now.
# This does, of course, assume you have powerd installed and your
# UPS connected and working correctly. 
pf::powerfail:/sbin/shutdown -f -h +2 "Power Failure; System Shutting Down"
 
# If power was restored before the shutdown kicked in, cancel it.
pr:12345:powerokwait:/sbin/shutdown -c "Power Restored; Shutdown Cancelled"
 

# Run gettys in standard runlevels
 
# Run xdm in runlevel 5
# xdm is now a separate service
x:5:respawn:/etc/X11/prefdm -nodaemon
0:2345:respawn:/sbin/mingetty tty0
1:2345:respawn:/sbin/mingetty tty1
#2:2345:respawn:/sbin/mingetty tty2
#3:2345:respawn:/sbin/mingetty tty3
#4:2345:respawn:/sbin/mingetty tty4
#5:2345:respawn:/sbin/mingetty tty5
#6:2345:respawn:/sbin/mingetty tty6
c:2345:respawn:/sbin/mingetty ttyS0

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值