[轉載請註明出處] http://kezeodsnx.pixnet.net/blog

作者: kezeodsnx

base-system很好玩,可以玩很久,玩很大,也有很多功能,像測試新軟體,或是進行一些擔心會影響到系統的操作時,可以在base-system上先惡搞一下,看看有沒有什麼side-effect,沒問題再弄上原本的系統。如果想要有自己的distro,也可以從base-system開始,裝上bootloader,kernel後,再根據需要來裝xserver,windows manager,等於是自己專有的Linux。

root@user-ubuntu:/home/user/temp# dd if=/dev/zero of=./lenny.img bs=1k count=1024000  //建一個1G的base-system
1024000+0 records in
1024000+0 records out
1048576000 bytes (1.0 GB) copied, 41.7743 s, 25.1 MB/s
root@user-ubuntu:/home/user/temp# losetup /dev/loop0 ./lenny.img  //掛成loop device

root@user-ubuntu:/home/user/temp# fdisk /dev/loop0 //建立分割區

Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0xb06f756a.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-127, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-127, default 127):
Using default value 127

Command (m for help): w
The partition table has been altered!
root@user-ubuntu:/home/user/temp# mkfs.ext2 /dev/loop0 //格式化成ext2
root@user-ubuntu:/home/user/temp# mount /dev/loop0 /mnt //mount起來,準備使用debootstrap建立base-system
root@user-ubuntu:/home/user/temp# debootstrap lenny /mnt/ http://ftp.us.debian.org/debian
I: Retrieving Release
I: Retrieving Packages

I: Configuring tasksel...
I: Base system installed successfully.

//chroot 前,先把proc和sys mount起來起來

root@user-ubuntu:/home/user# mount -o bind /proc/ /mnt/proc/
root@user-ubuntu:/home/user
# mount -o bind /sys/ /mnt/sys/
root@user-ubuntu:/home/user/temp# chroot /mnt/
user-ubuntu:/# ls
bin  boot  dev    etc  home  lib    lost+found  media  mnt    opt  proc  root  sbin  selinux    srv  sys  tmp  usr  var

base-system建好了,可以開始亂搞了。

 

kezeodsnx 發表在 痞客邦 PIXNET 留言(0) 人氣()