使用docker搭建Linux 0.11 实验环境

使用docker搭建Linux 0.11 实验环境

对于学习linux内核的同学,Linux 0.11源码绝对是首选。但由于现在的硬件架构以及编译器的版本对于搭建Linux 0.11的实验环境会有一定的困难,因此本文目的是基于docker容器搭建一个纯净的Linux 0.11的环境。为你学习linux内核源码提供便利。
希望你的Linux内核学习之路能从这里开始。

获取源码

从github上获取Linux 0.11实验环境。

(base) frank@deepin:~/git$ git clone https://github.com/tinyclub/cloud-lab.git
正克隆到 'cloud-lab'...
remote: Enumerating objects: 332, done.
remote: Counting objects: 100% (332/332), done.
remote: Compressing objects: 100% (219/219), done.
remote: Total 4689 (delta 174), reused 214 (delta 92), pack-reused 4357
接收对象中: 100% (4689/4689), 3.22 MiB | 29.00 KiB/s, 完成.
处理 delta 中: 100% (2998/2998), 完成.
(base) frank@deepin:~/git$ cd cloud-lab/
(base) frank@deepin:~/git/cloud-lab$ ls
base  configs  COPYING  doc  images  labs  README.md  TODO.md  tools  VERSION
(base) frank@deepin:~/git/cloud-lab$ tools/docker/choose linux-0.11-lab
LOG: Current Lab is linux-0.11-lab
LOG: Current Lab is linux-0.11-lab
LOG: Source code downloaded to /home/frank/git/cloud-lab/labs/linux-0.11-lab

操作步骤:

$ git clone https://github.com/tinyclub/cloud-lab.git
$ cd cloud-lab/
$ tools/docker/choose linux-0.11-lab

拉取docker镜像

$ sudo tools/docker/pull

启动环境

$ sudo tools/docker/run
Status: Downloaded newer image for tinylab/cloud-ubuntu-web:latest
LOG: VNC screen recorded in /home/frank/git/cloud-lab/recordings
LOG: VNC pages released in /home/frank/git/cloud-lab/releasings
LOG: VNC tokens stored in /home/frank/git/cloud-lab/.vnc-tokens
WARNING: Your kernel does not support swap limit capabilities or the cgroup is not mounted. Memory limited without swap.
f850bc200aba1b2d5a5b9f1371caf34344883bae7481e7b7818c64588753a352
LOG: Wait for lab launching...
LOG: Container ID: 00a5cb415058 Container Name: linux-0.11-lab-2195
LOG: User: ubuntu ,Password: 93vrdc ,VNC Password: lvr7pz ,Viewonly Password: x7qvpx
LOG: Current Lab is linux-0.11-lab
LOG: Current Lab is linux-0.11-lab
Please login with:

    User: 7827c9
    Password: lvr7pz (Normal)
    Password: x7qvpx (View)

Local URL:

  * Normal: http://localhost:6080/?u=7827c9&p=lvr7pz
  *   View: http://localhost:6080/?r=7827c9x7qvpx

Note: Please ensure network available outside and then replace 'localhost' with the external ip or domain name.
      E.g. Virtualbox setting 'Network->Adapter2->Host-only Adapter' adds eth1. 'ifconfig eth1' give us the ip.
      Then 'echo $ip > .host_name' or 'echo $domain_name > .host_name'

Note: firefox, safari and edge work, but google chrome web browser is preferable.

ERR: No web browser found, are you running me in cloud? please open the 'Normal' url yourself.
LOG: Current Lab is linux-0.11-lab
Lab: linux-0.11-lab-2195, User: ubuntu
  * VNC (Normal): http://localhost:6080/?u=7827c9&p=lvr7pz
  * VNC   (View): http://localhost:6080/?r=7827c9x7qvpx
  * SSH    (Web): http://localhost:4433/?ssh=ssh://ubuntu:[email protected]:22

LOG: Released to: /home/frank/git/cloud-lab/releasings/index.html
LOG: Labs online: http://localhost:6080/labs/index.html

使用环境

Normal

(Normal): http://localhost:6080/?u=7827c9&p=lvr7pz
在浏览器中输入上面的网址http://localhost:6080/?u=7827c9&p=lvr7pz

运行后会在web里面提供了一个Linux的环境(桌面环境),如图:
使用docker搭建Linux 0.11 实验环境_第1张图片

ssh

(Web): http://localhost:4433/?ssh=ssh://ubuntu:[email protected]:22
在浏览器中输入上面的网址http://localhost:4433/?ssh=ssh://ubuntu:[email protected]:22

运行后会提供Ubuntu的终端环境(命令行环境)。

使用docker搭建Linux 0.11 实验环境_第2张图片

硬盘启动Linux 0.11

$ make start-hd

使用docker搭建Linux 0.11 实验环境_第3张图片

调试

$ make debug-hd

使用docker搭建Linux 0.11 实验环境_第4张图片

帮助

	 :: Compile ::

     make --generate a kernel floppy Image with a fs on hda1
     make clean -- clean the object files
     make distclean -- only keep the source code files

     :: Test ::

     make start -- start the kernel in vm (qemu/bochs)
     make start-fd -- start the kernel with fs in floppy
     make start-hd -- start the kernel with fs in hard disk
     make start-hd G=0 -- start with curses based terminal, instead of SDL

     :: Debug ::

     make debug -- debug the kernel in qemu/bochs & gdb at port 1234
     make debug-fd -- debug the kernel with fs in floppy
     make debug-hd -- debug the kernel with fs in hard disk

     make debug DST=boot/bootsect.sym -- debug bootsect
     make debug DST=boot/setup.sym    -- debug setup

     make boot BOCHS=bochs-debugger VM=bochs -- debug with bochs internal debugg
er

     make switch             -- switch the emulator: qemu and bochs
     make boot VM=qemu|bochs -- switch the emulator: qemu and bochs

     :: Read ::

     make cscope -- genereate the cscope index databases
     make tags -- generate the tag file
     make cg -- generate callgraph of the default main entry
     make cg f=func d=dir|file b=browser -- generate callgraph of func in file/d
irectory

     :: More ::

     >>> README.md <<<

生成调用关系

$ make cg

使用docker搭建Linux 0.11 实验环境_第5张图片

你可能感兴趣的:(内核,C/C++)