Aditya Godbole wrote: > Oliver Fromme wrote: > > You can also put the image of the root file system into the > > kernel itself, so it doesn't have to be loaded separately. > > The kernel option to allocate appropriate space is called > > MD_ROOT_SIZE. > > Thanks. I'm investigating this option. How do I specify the filesystem > image that should be put into the kernel?
You don't. It's not necessary. MD_ROOT_SIZE only reserves space in the kernel image. Then you can use strings(1) to find the offset in the kernel image, and then write your image into the reserved space with standard shell tools. For example, suposse your root FS image is 5 MB: # ls -l rootfs.img -rw------- 1 root wheel 5242880 Nov 9 15:34 rootfs.img Then add these lines to your kernel configuration: options MD_ROOT options MD_ROOT_SIZE=5120 # number of KBytes Build the kernel as usual. It will now contain 5 MB of free space, and you can find the offset with strings(1): # strings -td kernel | grep "MFS Filesystem" 4505376 MFS Filesystem goes here 9748256 MFS Filesystem had better STOP here The first number is the start offset, the second is the end offset. The difference should be exactly 5 MB in this case (5252880 bytes), which is the size of our root FS image. Now construct a new kernel binary that contains the root FS image at the right place. You can use dd(1), but it is probably easier to use head+cat+tail: # head -c 4505376 kernel > kernel.new # cat rootfs.img >> kernel.new # tail -c +9748257 kernel >> kernel.new Note that the tail(1) number must be one more than the end offset, because tail(1) starts numbering bytes with 1, not with 0. Verify that the resulting "kernel.new" file has exactly the same size as the original kernel. Of course, you can automate the whole process easily with a shell script. That's all. If you're going to mount the root FS read-only, you can also compress the image with mkuzip(8) (requires geom_uzip(4) to be present in the kernel), to save space. > > Then where are you booting from? At least your kernel has > > to come from somewhere, i.e. you need either networking or > > some kind of media (disk, USB stick or similar). > > Currently I'm using u-boot to get the kernel image from the network > and boot it. Since I'm using u-boot, I proabably need to do something > in my kernel bootstrap code that the loader would do otherwise. I don't know u-boot. What is that? Best regards Oliver -- Oliver Fromme, secnetix GmbH & Co. KG, Marktplatz 29, 85567 Grafing Dienstleistungen mit Schwerpunkt FreeBSD: http://www.secnetix.de/bsd Any opinions expressed in this message may be personal to the author and may not necessarily reflect the opinions of secnetix in any way. "File names are infinite in length, where infinity is set to 255 characters." -- Peter Collinson, "The Unix File System" _______________________________________________ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to "[EMAIL PROTECTED]"