码迷,mamicode.com
首页 > 系统相关 > 详细

ubuntu系统debootstrap的使用

时间:2014-12-29 22:51:42      阅读:888      评论:0      收藏:0      [点我收藏+]

标签:

该文引自http://www.latelee.org/using-gnu-linux/ubuntu-debootstrap.html

debootstrap是debian/ubuntu下的一个工具,用来构建一套基本的系统(根文件系统)。生成的目录符合Linux文件系统标准(FHS),即包含了/boot、/etc、/bin、/usr等等目录,但它比发行版本的Linux体积小很多,当然功能也没那么强大,因此,只能说是“基本的系统”。

fedora下(centos亦可用)有类似功能的工具:febootstrap。观察这两个工具名称,可以看到debootstrap使用debian前缀“de”,而febootstrap使用fedora前缀“fe”,bootstrap含义为“引导”,并如果做过LFS的话,对它了解会比较多,而在编译gcc编译器时也有涉及到这个概念。不过debootstrap或febootstrap似乎没有表达出“引导”的意思。

制作根文件系统,在PC上最全面的莫过于LFS(linux form scratch,从头做一个linux系统),而嵌入式中,busybox是不二之选。当然,随着芯片的强大及一些linux发行版本的进化,也有桌面系统直接用于嵌入式领域中,比如ubuntu,就有支持硬件浮点的工具直接下载。

ubuntu默认没有安装debootstrap,安装十分简单,执行下列命令即可:

# sudo apt-get install debootstrap

使用也十分简单,命令格式为:

sudo debootstrap –arch [平台] [发行版本代号] [目录]

比如下面的命令

sudo debootstrap –arch i386 trusty /mnt

即是构建x86(32位)平台ubuntu最新发行版14.04(代号为trusty)的基本系统,存放到/mnt目录下。

当前debootstrap支持的发行版本可以在/usr/share/debootstrap/scripts查看,而各发行版代号,可以到http://en.wikipedia.org/wiki/List_of_Ubuntu_releases查看。比如gutsy是7.10的代号,precise是12.04的代号,等等。

输入上述命令后,就会从网络下载相关的文件,当看到

I: Configuring python-central…

I: Configuring ubuntu-minimal…

I: Configuring libc-bin…

I: Configuring initramfs-tools…

I: Base system installed successfully.

即表示成功。如果看到

E: Failed getting release file

http://archive.ubuntu.com/ubuntu/dists/trusty/Release

或卡在

I: Retrieving Release

则可能是网络原因。

下载的文件在/mnt/var下,如:

$ tree

.

├── debootstrap

│   ├── debootstrap.log

│   └── debpaths

└── var

├── cache

│   └── apt

│       └── archives

│           ├── adduser_3.113+nmu3ubuntu3_all.deb

│           ├── apt_1.0.1ubuntu2_i386.deb

其中adduser_3.113是14.04对应的adduser。从这里也可以确认其下载的是哪一发行版的软件。

下面使用chroot进入/mnt目录,并查看linux版本。

latelee@ubuntu:~$ cd /mnt/

latelee@ubuntu: /mnt$ ls

bin  boot  dev  etc  home  lib  media  mnt  opt  proc  root  run  sbin  srv  sys  tmp  usr  var

latelee@ubuntu: /mnt$ sudo -s

[sudo] password for latelee:

root@ubuntu: /mnt# chroot .

root@ubuntu:/# ls

bin  boot  dev  etc  home  lib  media  mnt  opt  proc  root  run  sbin  srv  sys  tmp  usr  var

root@ubuntu:/# cat etc/issue

Ubuntu 14.04 LTS \n \l

root@ubuntu:/# ls /proc/ -l

total 0

root@ubuntu:/# ifconfig

Warning: cannot open /proc/net/dev (No such file or directory). Limited output.

root@ubuntu:/# uname -a

Linux ubuntu 3.13.0-32-generic #57-Ubuntu SMP Tue Jul 15 03:51:12 UTC 2014 i686 i686 i686 GNU/Linux

因为当然系统使用的并不这个新的系统,因此/proc并没有内容,而内核依然是当前系统所用的版本。

使用光盘不成功

W: Failure trying to run: chroot /home/latelee/test_sys mount -t proc proc /proc

W: See /home/latelee/test_sys/debootstrap/debootstrap.log for details

注:

本文并没有过多技术含量,仅是在学习过程中碰见了debootstrap而写点笔记。本文所用环境均是虚拟机vmware。

附录:

未完事宜:

限于时间,目前还没有实际启动新的系统。

一些涉及到ubuntu根文件系统构建的资源:

http://www.virtuatopia.com/index.php/Building_a_Debian_or_Ubuntu_Xen_Guest_Root_Filesystem_using_debootstrap

https://wiki.ubuntu.com/DebootstrapChroot

https://help.ubuntu.com/10.04/installation-guide/i386/linux-upgrade.html

http://www.thegeekstuff.com/2010/01/debootstrap-minimal-debian-ubuntu-installation/

http://askubuntu.com/questions/442610/debootstrap-warning-during-installation-12-04-lts-server-vmware-virtual-mach

https://help.ubuntu.com/lts/installation-guide/i386/index.html

查看ubuntu各发行版本wiki:

http://en.wikipedia.org/wiki/List_of_Ubuntu_releases

查看ubuntu安装包:

http://packages.ubuntu.com/

后记:本想写稍有点技术含量的文章,把过程所涉及到的知识点都提及,但发现自己文笔不复如前,还是按流水账那样写出来比较畅快些。

 

 

 

本文固定链接: http://www.latelee.org/using-gnu-linux/ubuntu-debootstrap.html

ubuntu系统debootstrap的使用

标签:

原文地址:http://www.cnblogs.com/NKCZG/p/4192557.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!