Docker製做私有的基礎鏡像

debootstrap是debian/ubuntu下的一個工具,用來構建一套基本的系統(根文件系統)。生成的目錄符合Linux文件系統標準(FHS),即包含了/boot、/etc、/bin、/usr等等目錄,但它比發行版本的Linux體積小不少,固然功能也沒那麼強大,所以,只能說是「基本的系統」。php

fedora下(centos亦可用)有相似功能的工具:febootstrap。觀察這兩個工具名稱,能夠看到debootstrap使用debian前綴「de」,而febootstrap使用fedora前綴「fe」,bootstrap含義爲「引導」,並若是作過LFS的話,對它瞭解會比較多,而在編譯gcc編譯器時也有涉及到這個概念。不過debootstrap或febootstrap彷佛沒有表達出「引導」的意思。html

製做根文件系統,在PC上最全面的莫過於LFS(linux form scratch,從頭作一個linux系統),而嵌入式中,busybox是不二之選。固然,隨着芯片的強大及一些linux發行版本的進化,也有桌面系統直接用於嵌入式領域中,好比ubuntu,就有支持硬件浮點的工具直接下載。python

ubuntu默認沒有安裝debootstrap,安裝十分簡單,執行下列命令便可:linux

 sudo apt-get install debootstrap

  使用也十分簡單,命令格式爲:ios

sudo debootstrap --arch [平臺] [發行版本代號] [目錄]

  

 

 

sudo debootstrap --arch [平臺] [發行版本代號] [目錄]

好比下面的命令git

sudo debootstrap --arch i386 trusty /mnt

便是構建x86(32位)平臺ubuntu最新發行版14.04(代號爲trusty)的基本系統,存放到/mnt目錄下。web

當前debootstrap支持的發行版本能夠在/usr/share/debootstrap/scripts查看,而各發行版代號,能夠到http://en.wikipedia.org/wiki/List_of_Ubuntu_releases查看。好比gutsy是7.10的代號,precise是12.04的代號,等等。編程

輸入上述命令後,就會從網絡下載相關的文件,當看到bootstrap

I: Configuring python-central... I: Configuring ubuntu-minimal... I: Configuring libc-bin... I: Configuring initramfs-tools... I: Base system installed successfully.

即表示成功。若是看到ubuntu

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/

後記:本想寫稍有點技術含量的文章,把過程所涉及到的知識點都說起,但發現本身文筆不復如前,仍是按流水帳那樣寫出來比較暢快些。

李遲,寫於2014年10月20日中午休息前

 

 

近來經濟拮据,如本文對閣下有幫助,可慷慨解囊贊助筆者以輸出更多好文章。 
支付寶readchy@163 或 微信fly_camel_fly 都可。感謝!
14373903313201                                  14373903313202 

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

如無特別說明, 遲思堂工做室文章均爲原創,轉載請註明:  ubuntu系統debootstrap的使用 | 遲思堂工做室

目前暫無評論

發表評論

 

 

 

 

 

驗證圖片
刷新驗證碼
  *

 

 

快捷鍵:Ctrl+Enter
 
相關文章
相關標籤/搜索