# How to insert the ram disk image to a FreeBSD kernel?



## wsw1wsw2 (Jul 2, 2009)

Hi, Guys

As i know, it is easy to insert a ram disk image into a NetBSD kernel image.

say :


```
makefs -s 20m -t ffs ramdisk.img fakeroot/
mdsetimage -v netbsd ramdisk.img
```

Is this *possible* in FreeBSD and how ?

Thanks in advance.


----------



## DutchDaemon (Jul 2, 2009)

md(4), mdmfs(8), mdconfig(8), I guess.


----------



## wsw1wsw2 (Jul 3, 2009)

DutchDaemon said:
			
		

> md(4), mdmfs(8), mdconfig(8), I guess.



These are memory disks(filesystem) support in FreeBSD. But i want to know is there a way to *insert* a memory disk as root file system to a FreeBSD kernel?


----------



## vermaden (Jul 3, 2009)

wsw1wsw2 said:
			
		

> These are memory disks(filesystem) support in FreeBSD. But i want to know is there a way to *insert* a memory disk as root file system to a FreeBSD kernel?



You can for sure put memory disk (even compressed) on the medium along with the kernel, and boot it as a / filesystem, but I havent heard about putting it into the kernel (many FreeBSD LiveCD's work like that).

BTW, you got some more info/links on the sollution you mentioned? About ramdisk in NetBSD kernel and pros/cons of that sollution?


----------



## s0xxx (Jul 3, 2009)

vermaden said:
			
		

> BTW, you got some more info/links on the sollution you mentioned? About ramdisk in NetBSD kernel and pros/cons of that sollution?


Here are some:



> *Introduction*
> 
> The purpose of this document is to guide you to create a RAM disk image and a custom kernel in order to boot your mini NetBSD off a Compact Flash or use it to debug it in an emulated environment, such as qemu.
> 
> ...


http://wiki.netbsd.se/How_to_create_bootable_NetBSD_image
http://brianrose.net/family/fetch.php?dir=/Brian/NetBSD/Embedded&filename=single.html

And also man page of mdsetimage(8), which is not very descriptive though.


----------



## vermaden (Jul 4, 2009)

@s0xxx

Thank you mate


----------



## wsw1wsw2 (Jul 7, 2009)

s0xxx said:
			
		

> And also man page of mdsetimage(8), which is not very descriptive though.



By reading the mdsetimage's source code, the ramdisk image insert into the kernel's some ELF section.

NetBSD kernel can be configured to work with multiboot boot loader such as grub. So we can get a *single* ELF file (kernel with ramdisk root filesystem in it) to boot up a computer runing a complete NetBSD system. (with enough memory)

i think FreeBSD can not do that.


----------



## Jamz (Jul 17, 2009)

man loader


```
boot_dfltroot
               Instructs the kernel to mount the statically compiled-in root
               file system.
```

I have no idea how to get it in there, been wondering the same myself.

James


----------

