亚洲av成人无遮挡网站在线观看,少妇性bbb搡bbb爽爽爽,亚洲av日韩精品久久久久久,兔费看少妇性l交大片免费,无码少妇一区二区三区

  免費注冊 查看新帖 |

Chinaunix

  平臺 論壇 博客 文庫
最近訪問板塊 發(fā)新帖
查看: 3037 | 回復: 5
打印 上一主題 下一主題

[FreeBSD] 從映像文件引導,使用ramdisk為根目錄的freebsd。 [復制鏈接]

論壇徽章:
0
跳轉(zhuǎn)到指定樓層
1 [收藏(0)] [報告]
發(fā)表于 2004-08-26 20:51 |只看該作者 |倒序瀏覽
網(wǎng)上有老外問道:
Could someone point me to some examples for how to use MD_ROOT with 5.1
Release?

What I am trying to do is create a system which:

1) Boots off of a hard drive
2) Copies a full filesystem into RAM (I've got lots)
3) Boots the kernel and mounts the RAM as its filesystem
4) Shuts down the hard drive completely

I've seen a few things for creating read-only systems, but I don't want to
have to access the media after boot.

There are some references to the old MFS stuff, but I'm not finding any
obvious references to doing similar stuff with MD.

Any pointers would be appreciated.

Thanks,
有人研究嗎,我保證很多人希望了解,知道得老大說說嘛。
但是好象md_root的工作方式不是這樣的,是loader直接從一個映像文件啟動系統(tǒng)。

man md
man loader
man mdconfig
都沒有什么線索。只有man md提到有l(wèi)oader啟動mdimage方面的內(nèi)容。

論壇徽章:
0
2 [報告]
發(fā)表于 2004-08-26 20:54 |只看該作者

從映像文件引導,使用ramdisk為根目錄的freebsd。

呵呵,剛發(fā)完貼子就看到這篇文章,獻上:

Building Monolithic Kernels and Root Filesystems for FreeBSD
David Yeske <dyeske@yahoo.com>;

This article explains an alternative method of creating a kernel that contains a root file system image within it. This single-file kernel and file system can be used in many ways beyond what usual FreeBSD kernels allow, just as having the root file system loaded along with the kernel enables you to have more flexibility in the boot process.

A utility called write_mfs_in_kernel was once used to create a monolithic kernel and mfsroot (memory resident root file system). However, write_mfs_in_kernel has been removed from FreeBSD. Since the functionality was still important, I needed a replacement.

Here are examples of basic uses of this mechanism:

    * Network booting with a preloaded root file system without needing a PXE client or NFS server
    * Loading PicoBSD from a TFTP image
    * Thin terminals
    * Embedded systems
    * Data recovery
    * Fully automated and unattended FreeBSD installation that works with any network device supported by grub or etherboot
    * Any other method where /boot/loader or /boot/pxeboot cannot be used

The flexibility of a monolithic kernel allows FreeBSD to be loaded in many situations. Here are additional examples where this can be used.

    * If a floppy disk has grub or etherboot installed, then FreeBSD can be loaded over tftp and is not required to be in the same subnet as the tftp server. This allows any computer with an internet connection to run picobsd or the FreeBSD installer with one floppy disk. The size of the FreeBSD kernel with mfsroot is not limited to the size of the floppy, either.
    * An image could be made containing the FreeBSD installer with sshd added. This allows for a remote install using an inbound ssh connection. Access control configuration could be stored on a FAT formatted floppy disk. Users could modify the configuration on a machine that is not running FreeBSD and enter in information provided by a remote administrator.
    * A machine can download a monolithic kernel onto a drive formatted with FAT32, ext2, or anything else supported by grub or etherboot. This permits installation onto a machine that does not have a bootable 1.44M floppy drive or a bootable cdrom drive. Some laptops and older machines could benefit from this.
    * An average PC could quickly become a router, firewall, mp3 server, or X terminal that would not need to modify or remove the existing operating system.

Comparison

The alternative method uses the objcopy program, which is part of GNU binutils. It is used to convert a mfsroot image into an ELF object that can be linked into the FreeBSD kernel. The md device is modified so that it can reference both the beginning and end of the mfsroot from weak symbols that objcopy adds to the mfsroot image before the kernel is linked. Currently this requires the kernel to be recompiled every time you want to replace the image; once a kernel is compiled using this method, the root file system might be able to be replaced by relinking the kernel rather than recompiling it.

The write_mfs_in_kernel method required padding (options MD_ROOT_SIZE) to be added to a kernel, the kernel compiled, and the root file system inserted into it via write_mfs_in_kernel. This allowed a mfsroot image to be inserted into a kernel as long as it was less than the size of the padding. The mfsroot image could also be replaced without having to recompile or relink the kernel. A mfsroot image larger than the size of the padding would require the kernel to be recompiled with more padding though. NetBSD and OpenBSD currently use a similar technique.

I am also working on adding additional functionality so that an arbitrary file can be linked into the kernel and attached to a vnode backed md device during the kernel load. Another benefit to the objcopy method is that it can be extended to have more than one root file system per kernel, which can be referenced via ufs:/dev/md0c, ufs:/dev/md1c, etc... Further development could lead to a distribution of FreeBSD that can live in a file that is not on a drive formatted with ufs. QNX can live in a file on a FAT32 partition, and BeOS was also able to. There are also Linux distributions that can live in a file via the loopback interface. Novice users might want to initially try out FreeBSD in a symbiotic way that does not require another partition, especially if their drive is already formatted with FAT32.
Kernel Construction Overview

The following steps were used to create a FreeBSD kernel and mfsroot image from the 4.7-RELEASE install sets. There is a link to a usable image here that can be used to install FreeBSD 4.7-RELEASE. First, the following patch must be applied so the kernel and md device will have support for the objcopy method. This patch should apply clean to RELENG_4_7_0_RELEASE and not have any effect on a system when MD_ROOT_IMAGE is not defined. This method also works on FreeBSD current, but the code is slightly different. Next the BOOTMFS kernel config file that is created during a make release was modified by adding these 2 lines:


makeoptions     MD_ROOT_IMAGE="/tmp/mdimage.o"
options         MD_ROOT_IMAGE

The makeoptions MD_ROOT_IMAGE="/tmp/mdimage.o" line adds the mdimage.o object file to the list of files to be linked into the kernel.
The options MD_ROOT_IMAGE line is needed so the md device will compile with some extra definitions.

The next step is to run the following commands that remove the mfsroot image from the mfsroot.flp floppy image.

# vnconfig -v vn1 mfsroot.flp
/dev/vn1: 0 bytes on mfsroot.flp
# mount /dev/vn1 /mnt
# cp /mnt/mfsroot.gz .
# umount /mnt
# vnconfig -v -u vn1
/dev/vn1: cleared
# gzip -d mfsroot.gz

An ELF object must be created from the mfsroot image and symbols added to it so the kernel can mount it as the root file system. The mfsroot file is copied to a file called mdimage so that the symbols will work properly. Objcopy is then used to create the ELF object file with symbols that can be linked in with the kernel.

      # cp mfsroot /tmp/mdimage
      # cd /tmp
      # objcopy -v -I binary -O elf32-i386 -B i386 --redefine-sym _binary_mdimage_start=__md_root_image_start --redefine-sym _binary_mdimage_end=__md_root_image_end mdimage mdimage.o
      copy from mdimage(binary) to mdimage.o(elf32-i386)


The __md_root_image_start and __md_root_image_end arguments redefine the the start and end address of the mdimage.o object file so that the md device can reference the weak symbols.

The mdimage.o file is slightly larger (428 bytes) than the original mfsroot image that was copied to mdimage.

4423680 mdimage compared with 4424108 mdimage.o

Make release was run in order to get the BOOTMFS kernel definition file and test this after 4.7-RELEASE was tagged. A kernel was built as follows without modules because they are already on the mfsroot image file system in /stand/modules.

      # cd /usr/src && make buildkernel KERNCONF=BOOTMFS NO_MODULES=yes

The result of applying these steps resulted in a kernel of the following size :
7815765 kernel

Size difference between new kernel compared with original BOOTMFS kernel:


3363818 BOOTMFS

      # echo $((7815765 - 336381) 4451947


Increase in size of kernel for objcopy method not including mfsroot image:

      # echo $((4451947 - 4423680)) 28267

Approximately 28k was lost using this process which is less than the size of the /boot/loader file on the boot.flp image:

84875 Oct  9 11:22 loader

A kernel image created with this method can be loaded using /boot/loader or /boot/pxeboot just like a normal kernel can, but it can also be loaded from grub or etherboot. This method has also been tested after running strip on a kernel.

Acknowledgments

I would like to thank Poul-Henning Kamp and Jerry Hicks for all their effort and input. They made it possible for me to progress this far. I would also like to thank everyone that provided me with technical feedback.

論壇徽章:
0
3 [報告]
發(fā)表于 2004-08-26 20:59 |只看該作者

從映像文件引導,使用ramdisk為根目錄的freebsd。

漢化加精吧。

論壇徽章:
1
榮譽版主
日期:2011-11-23 16:44:17
4 [報告]
發(fā)表于 2004-08-27 11:00 |只看該作者

從映像文件引導,使用ramdisk為根目錄的freebsd。

哪位漢化一下...

論壇徽章:
0
5 [報告]
發(fā)表于 2004-08-27 15:21 |只看該作者

從映像文件引導,使用ramdisk為根目錄的freebsd。

還漢化什么,發(fā)覺這個東東太復雜,不好用。
每次改動都需要編譯內(nèi)核,麻煩。而且有些命令5.x還不能用(vnconfig被mdconfig代替)。算了還是自己搞:

環(huán)境:vmware4.5+freebsd-5.2.1

1:mount /cdrom && cd /tmp && cp /cdrom/boot/mfsroot.gz /tmp
(實際上mfsroot.gz就是普通的磁盤映象文件經(jīng)過gzip壓縮,這里也可以用其他freebsd啟動盤用dd做映象代替)
2: gzip -d /tmp/mfsroot.gz
3: mdconfig -a -t vnode -f /tmp/mfsroot -u 0
(建立設(shè)備名為md0,以/tmp/mfsroot為映像的ramdisk)
(參考
man md
man mdconfig
)
4: mount /dev/md0 /mnt/ram(自己建個ram)
(如果是disklable -w過,可能是md0a 或md0c,看newfs哪個了)
5: 修改ram的內(nèi)容復合您的要求
6: umount /mnt/ram && mdconfig -d -u 0
7: cp /tmp/mfsroot /boot
8: reboot
9: 啟動選6(prompt... ... )
10:unload
11:load /boot/kernel/kernel
12:load -t md_image /boot/mfsroot
(參考
man loader
)
13:set vfs.root.mountfrom=ufs:/dev/md0c
(參考
man loader
)
14:autoboot 3
啟動后用df檢驗/是否是md0或md0a或md0c

15:啟動成功后可以直接修改/boot/defaults/loader.conf
exec="unload"
exec="load /boot/kernel/kernel"
exec="load /boot/xxxxxx.img"
exec="set vfs.root.mountfrom=ufs:/dev/md0c"
(這條也可以直接修改vfs.root選項。)
exec="boot"

16:好象這個映像文件還可以用gzip 壓縮。

改完收工!

論壇徽章:
0
6 [報告]
發(fā)表于 2004-08-27 17:03 |只看該作者

從映像文件引導,使用ramdisk為根目錄的freebsd。

剛剛把以前做的u盤版freebsd的鏡像:
直接拿來用,發(fā)覺基本上可以啟動(可能需要修改rc)。

結(jié)合U盤版FREEBSD,將使FREEBSD在普通PC上制作商業(yè)化防火墻、撥號服務(wù)器等成為可能 。
1:軟盤太容易壞,容量太小,價格沒有優(yōu)勢:優(yōu)質(zhì)的軟驅(qū)+N張好的軟盤  可能 比一個64M的U盤貴。
2:光盤維護太麻煩。價格自然也貴。
3:硬盤?
5:flash硬盤,可能貴了點。而且也失去了維護的優(yōu)勢。
6:可以利用這個技術(shù)+PXE技術(shù)制作無盤防火墻(???不知到有沒有意義)。
5.x巴實!
您需要登錄后才可以回帖 登錄 | 注冊

本版積分規(guī)則 發(fā)表回復

  

北京盛拓優(yōu)訊信息技術(shù)有限公司. 版權(quán)所有 京ICP備16024965號-6 北京市公安局海淀分局網(wǎng)監(jiān)中心備案編號:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年舉報專區(qū)
中國互聯(lián)網(wǎng)協(xié)會會員  聯(lián)系我們:huangweiwei@itpub.net
感謝所有關(guān)心和支持過ChinaUnix的朋友們 轉(zhuǎn)載本站內(nèi)容請注明原作者名及出處

清除 Cookies - ChinaUnix - Archiver - WAP - TOP