Subject: File system image
To: NetBSD - tech-embed <tech-embed@netbsd.org>
From: Brian Rose <saider@gate.net>
List: tech-embed
Date: 02/07/2003 12:41:48
I am trying to build a NetBSD kernel with a built in MEMDRIVE that 
contains all the files that I need to run a machine. This is similiar to 
a diskless setup except that I am not mounting a drive via NFS.

I'm running into a bit of a paradox. I'll detail the working 
configuration first, then I'll show you where my trouble is...

WORKING SETUP - To create a 1.44Meg MEMDRIVE
--------------------------------------------
1) Zero the drive
   dd if=/dev/zero of=/dev/fd0a bs=512 count=2880
2) Create a new filesystem on the drive
   newfs /dev/fd0a floppy
3) Mount the floppy
   mount -t ffs /dev/fd0a /mnt/floppy
4) Copy the files
5) unmount the floppy
   umount /mnt/floppy
6) Copy the image
   dd if=/dev/fd0a of=memdrive.image
7) place the image into the kernel
   mdsetimage -s -v netbsd.memkernel memdrive.image
8) boot the new image!

Again, this works fine. The problem I am having is creating an arbitrary 
memdrive that is not based on any physical device. For example, I'd like 
to make a 16M memdrive. But I don't have any devices that have a 16M 
capacity that I can dd from. My next smallest device is my 4.3GB hard drive.

I tried using virtual devices, but you cannot disklabel a virtual 
device. And without a disklabel, you can't put a filesystem on an image 
using newfs. So how do I create a memdrive with a proper disklabel so 
that I can put a filesystem on it and boot from it? I've been looking 
all over trying various combinations of mdconfig, vnconfig, disklabel, 
fdisk, and other commands to try and force a disk label onto a memdrive 
or a virtual device.

Has anyone done this before?

Thanks,

Brian Rose