ubuntu系统debootstrap的使用(构建一套基本的系统)
debootstrap是debian/ubuntu下的一個(gè)工具,用來構(gòu)建一套基本的系統(tǒng)(根文件系統(tǒng))。生成的目錄符合Linux文件系統(tǒng)標(biāo)準(zhǔn)(FHS),即包含了/boot、/etc、/bin、/usr等等目錄,但它比發(fā)行版本的Linux體積小很多,當(dāng)然功能也沒那么強(qiáng)大,因此,只能說是“基本的系統(tǒng)”。
fedora下(centos亦可用)有類似功能的工具:febootstrap。觀察這兩個(gè)工具名稱,可以看到debootstrap使用debian前綴“de”,而febootstrap使用fedora前綴“fe”,bootstrap含義為“引導(dǎo)”,并如果做過LFS的話,對它了解會比較多,而在編譯gcc編譯器時(shí)也有涉及到這個(gè)概念。不過debootstrap或febootstrap似乎沒有表達(dá)出“引導(dǎo)”的意思。
制作根文件系統(tǒng),在PC上最全面的莫過于LFS(linux form scratch,從頭做一個(gè)linux系統(tǒng)),而嵌入式中,busybox是不二之選。當(dāng)然,隨著芯片的強(qiáng)大及一些linux發(fā)行版本的進(jìn)化,也有桌面系統(tǒng)直接用于嵌入式領(lǐng)域中,比如ubuntu,就有支持硬件浮點(diǎn)的工具直接下載。
ubuntu默認(rèn)沒有安裝debootstrap,安裝十分簡單,執(zhí)行下列命令即可:
# sudo apt-get install debootstrap使用也十分簡單,命令格式為:
sudo debootstrap --arch [平臺] [發(fā)行版本代號] [目錄]比如下面的命令
sudo debootstrap --arch i386 trusty /mnt即是構(gòu)建x86(32位)平臺ubuntu最新發(fā)行版14.04(代號為trusty)的基本系統(tǒng),存放到/mnt目錄下。
當(dāng)前debootstrap支持的發(fā)行版本可以在/usr/share/debootstrap/scripts查看,而各發(fā)行版代號,可以到http://en.wikipedia.org/wiki/List_of_Ubuntu_releases查看。比如gutsy是7.10的代號,precise是12.04的代號,等等。
輸入上述命令后,就會從網(wǎng)絡(luò)下載相關(guān)的文件,當(dāng)看到
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則可能是網(wǎng)絡(luò)原因。
下載的文件在/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對應(yīng)的adduser。從這里也可以確認(rèn)其下載的是哪一發(fā)行版的軟件。
下面使用chroot進(jìn)入/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因?yàn)楫?dāng)然系統(tǒng)使用的并不這個(gè)新的系統(tǒng),因此/proc并沒有內(nèi)容,而內(nèi)核依然是當(dāng)前系統(tǒng)所用的版本。
使用光盤不成功
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總結(jié)
以上是生活随笔為你收集整理的ubuntu系统debootstrap的使用(构建一套基本的系统)的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: ROS(kinetic)安装中的一些问题
- 下一篇: (六)深度Q网络