利用 mkisofs 製作 sparc-boot 開機光碟

我們生活周遭存在太多太多的 embedded system ,過去 embedded system 有專屬的 OS,現在 linux 也可以應用在嵌入式環境,不過本版將廣泛討論所有嵌入式系統不只 linux 喔,歡迎有這方面經驗或有興趣的朋友一同進來討論。

版主: chester

利用 mkisofs 製作 sparc-boot 開機光碟

文章lloyd » 週四 1月 06, 2005 4:09 pm

前情題要:
公司最近有個特殊需求,要求要在 mips 的平台上支援 cdrom 開機
這牽扯到需要 bootloader 支援 cdrom , 也需要一些額外特殊手法來
作這樣個事情。


背景知識:
我們知道可以利用 mkisofs 來製作 ISO file. 在可開機光碟上有幾
種作法。
-G generic_boot_image
Specifies the path and filename of the generic boot image to be
used when making a generic bootable CD. The generic_boot_image
will be placed on the first 16 sectors of the CD. The first 16
sectors are the sectors that are located before the iso9660 pri-
mary volume descriptor. If this option is used together with
the -sparc-boot option, the Sun disk label will overlay the
first 512 bytes of the generic boot image.

-b eltorito_boot_image
Specifies the path and filename of the boot image to be used
when making an "El Torito" bootable CD. The pathname must be
relative to the source path specified to mkisofs. This option
is required to make an "El Torito" bootable CD. The boot image
must be exactly the size of either a 1200, 1440, or a 2880 kB
floppy, and mkisofs will use this size when creating the output
iso9660 filesystem. It is assumed that the first 512 byte sector
should be read from the boot image (it is essentially emulating
a normal floppy drive). This will work, for example, if the
boot image is a LILO based boot floppy.

-G 是將開機檔案寫在前 16 軌內,這容量是有限制的。而 -b 則是在 iso9660
檔案格式內含開機檔案存放開機程式位置資訊。不過很特別的是裏面註明只能使
用 1200, 1440, 2880kb floppy. 未查原因不明。

最近有一種新興的開機光碟使用的是 isolinux.bin , 用的也是 -b 底下是幾種
作法的簡圖

[I. -G]
biso -cdrom -bootimg booting.
[II. -b]
biso -cdrom -iso9660 fs -bootimg booting
bios -cdrom -iso9660 fs -isolinux.bin -linux kernel booting.

-b 限制 1200,1400,2880 大小(未查), 所以利用一個 isolinux.bin 在來載
linux kernel , 作法有點像是 syslinux 或是 dos 下的 loadlin 。
當然 isolinux.bin 要支援 iso9660 file sytem.


實際環境:
我們的系統 image 通常大約 4M or 8M or 16M 不等。看來 image 大
小是個問題。要不要採用 isolinux.bin on mips cpu 也是個問題?似
乎好像沒這個必要。

目前結果:
最後我採用的是 sparc-boot 的方式。這個方式很有趣。提供給大家
參考。

-sparc-boot img_sun4,img_sun4c,img_sun4m,img_sun4d,img_sun4e
Specifies a comma separated list of boot images that are needed
to make a bootable CD for sparc systems. Partition 0 is used
for the ISO-9660 image, the first image file is mapped to parti-
tion 1. There may be empty fields in the comma separated list.
The maximum number of possible partitions is 8 so it is impossi-
ble to specify more than 7 partition images. This option is
required to make a bootable CD for Sun sparc systems. If the -B
or -sparc-boot option has been specified, the first sector of
the resulting image will contain a Sun disk label. This disk
label specifies slice 0 for the iso9660 image and slice 1 ...
slice 7 for the boot images that have been specified with this
option. Byte offset 512 ... 8191 within each of the additional
boot images must contain a primary boot that works for the
appropriate sparc architecture. The rest of each of the images
usually contains an ufs filesystem that is used primary kernel
boot stage.

簡譯: 共有 8 個 partition, partition 0 放 ISO-9660, 1-7 可以放 7 個不同的
開機 image.

做好的光碟片狀況如下
# fdisk -l /dev/sr0
Note: sector size is 2048 (not 512)

Disk /dev/sr0 (Sun disk label): 1 heads, 640 sectors, 2048 cylinders
Units = cylinders of 640 * 512 bytes

Device Flag Start End Blocks Id System
/dev/sr0p1 r 0 73 23360 4 SunOS usr
/dev/sr0p2 r 73 99 8320 2 SunOS root

# mount -t iso9660 -o ro /dev/sr0 /mnt/
# mount
/dev/sr0 on /mnt type iso9660 (ro)

由於 boot image 是利用獨立的 partition 所以檔案大小就沒有特別的限制。而且
不需要理解 iso-9660 file system 的能力。因為他並不存放在 iso9660 上面,要
找 boot image 直接在 512 byte 的 fstab 上面找十分簡單。

底下是 sun_label 的資料結構
struct sun_label {
char dkl_ascilabel[128];
..........
struct dk_map { /* logical partitions */
Uchar dkl_cylno[4]; /* starting cylinder */
Uchar dkl_nblk[4]; /* number of blocks */
} dkl_map[NDKMAP]; /* logical partition headers */
..........
Uchar dkl_magic[2]; /* identifies this label format */
Uchar dkl_cksum[2]; /* xor checksum of sector */
};


# ./read_kernel /dev/sr0
CD-ROM Disc with Sun sparc boot created by mkisofs
kcylno = 73
seek = 23920640
knblk = 8320
KR size = 8519680

# ls -l KR
-rw------- 1 root root 8519680 Jan 6 14:37 KR

真是超級簡單.

--
    ◢◣
□□□ ██ □□□□
□  ◢█□ 造形.空間.秩序.
□  ███◣ 主從.對比.韻律
為什麼你的 Celeron 300 比我的 PIII 600 還要快。 :-(
我的寶貝 IBM TP240 Celeron 300 B5 size 1.32Kg
lloyd
可愛的小學生
可愛的小學生
 
文章: 18
註冊時間: 週四 5月 15, 2003 10:39 am
來自: KaLUG

Re: 利用 mkisofs 製作 sparc-boot 開機光碟

文章lloyd » 週四 1月 06, 2005 6:40 pm

lloyd huang <lloyd@coventive.comwrote:

實際環境:
我們的系統 image 通常大約 4M or 8M or 16M 不等。看來 image 大
小是個問題。要不要採用 isolinux.bin on mips cpu 也是個問題?似
乎好像沒這個必要。


footnote: 我後來又查了一下,isolinux 是由 syslinux 所提供,而且
只針對 x86 only.

--
    ◢◣
□□□ ██ □□□□
□  ◢█□ 造形.空間.秩序.
□  ███◣ 主從.對比.韻律
為什麼你的 Celeron 300 比我的 PIII 600 還要快。 :-(
我的寶貝 IBM TP240 Celeron 300 B5 size 1.32Kg
lloyd
可愛的小學生
可愛的小學生
 
文章: 18
註冊時間: 週四 5月 15, 2003 10:39 am
來自: KaLUG


回到 embedded system

誰在線上

正在瀏覽這個版面的使用者:沒有註冊會員 和 1 位訪客

cron