返回列表 回復 發帖

1-6 Creating BrazilFW hd image to use in qemu, VirtualBox etc.

作者: wen 日期: 2009-5-19 17:01 閱讀: 166打印 收藏
資料來源:
http://www.brazilfw.com.br/forum/viewtopic.php?f=38&t=62943

目前:
建立hd (or floppy) image with BrazilFW 讓虛擬機像是qemu, VirtualBox或其他一些不需真實硬體來run Brazilfw

準備工具:
1. recent syslinux (the binary provided with BFW is ancient one and fails to boot on many systems including qemu)
2. dd
3. fdisk
4. mkfs.vfat
5. ms-sys
5. loopback support in kernel
6. BrazillFW install CD iso image

製做步驟:
1.Create image file (16MB in this example - adjust to Your needs)
# dd if=/dev/zero of=/tmp/brazil.img bs=1k count=16384
16384+0 records in
16384+0 records out
16777216 bytes (17MB) copied, 0.467463 s,35,9 MB/s

2.在image檔中建立分割區
#cd /tmp
# fdisk -C 128 -u brazil.img
there You have to:
- create new primary partition at least 3MB (command n)
- change type of partition to FAT16 (command t type 6)
- mark partition as bootable (command a)
- REMEMBER STARTING BLOCK OF PARTITION AND BLOCK SIZE (referred later as SBoP and BS)
- exit writing changes

3.Create filesystem in image file
You have to calculate offset of partition in image file.
OFFSET = BS*SBoP (the one shown by fdisk)
In my example BS=512 SBoP=63 => OFFSET=32256
(32256 是怎麼算出來的?因為 fdisk -l brazil.img 顯示的資訊如下,每個 track 共 63 sectors, 每個 sector 是 512bytes, 而第一個 partition 是從第一個 track 開始的,因此第一個分割區的位移是 63 x 512 也就等於 32256。因此若你的分割區不是如此的話請類推。)

# losetup -o OFFSETT /dev/loop0 brazil.img
# mkfs.vfat /dev/loop0

4. Loopmount BrazilFW install CD and create brazil files
# mkdir /tmp/brazilCD
# mount brazilfw-cd.iso /tmp/brazilCD -o loop
# cd /tmp/brazilCD/BrazilFW
# ./makefloppy.sh -hd

Answer configuration questions (just like in normal installation of bfw)
The installer will create dir /brazilfw-tmp-disk with (almost)all needed files

5. Mount FAT partition from image file
# mkdir /tmp/brazilIMG
# mount /dev/loop0 /tmp/brazilIMG

6. Copy all files from /brazilfw-tmp-disk into Your image
# cp -a /brazilfw-tmp-diski/* /tmp/brazilIMG

7. Copy kernel with IDE support
# cp /tmp/brazilCD/install/linux /tmp/brazilIMG

8. Edit syslinux.cfg
# chmod 644 /tmp/brazilIMG/syslinux.cfg
# vi /tmp/brazilIMG/syslinux.cfg
- remove '=' after append
- change boot=/dev/xxxx,vfat to boot=/dev/hda1,vfat
- save and exit

Content of the file after modification should look like this:

display syslinux.dpy
timeout 0
default linux
append load_ramdisk=1 initrd=root.tgz initrd_dyn=minix ramdisk_size=4096 root=/dev/ram0 boot=/dev/hda1,vfat

9. umount BrazilCD
# umount /tmp/brazilCD
# rm -r /tmp/brazilCD

10. umount brazil image
# umount /tmp/brazilIMG
# rm -r /tmp/brazilIMG
11. Remove /brazilfw-tmp-disk
# rm -r /brazilfw-tmp-disk

12. install syslinux in image
# syslinux /dev/loop0

13. Remove association between image and loop device
# losetup -d /dev/loop0

14. Write mbr to the image
# ms-sys -df /tmp/brazil.img

15. Test Your image :-)
# qemu -hda /tmp/brazil.img

Hopefully You will see standard boot process of BFW (maybe with some errors from loading ethernet drivers).

Final notes:
You can also create more sophisticated image with two partitions (the second one should be of type Linux and filesystem should be minix). This second partition is used by some of BFW additions (like squid for example).
With some small adjustments this procedure can be used to build custom floppy image also.*/
2005.12.04不預期遇見什麼、才可能什麼都能遇見。
如果你是會員,有任何使用上的問題,請發短訊給我(wen)
如果你是訪客的話,註冊之後可以得到完整的瀏覽權限
返回列表