Subject: Re: File system image
To: Brian Rose <saider@gate.net>
From: Luke Mewburn <lukem@netbsd.org>
List: netbsd-users
Date: 02/08/2003 18:31:09
On Fri, Feb 07, 2003 at 12:41:48PM -0500, Brian Rose wrote:
| 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.
/usr/sbin/makefs effectively handles steps 1 through 6 for you.
In short, you:
* Populate a directory with the files you want to put in ffs image.
* Run
makefs -t ffs memdrive.image somedir
This uses the permissions of the files in somedir.
If you do not want to run makefs as root, you can create
an "mtree specfile" and pass that to makefs to override the
permissions of files under somedir as they're put into the
image, or even to create new directories & devices with the
appropriate permissions.
Using this technique, makefs can build ffs images with images
with devices, setuid root files, etc, without requiring any
root privileges.
* Place the image into the kernel using mdsetimage
The ramdisk (md) file system images in the kernels on the NetBSD 1.6
boot media are created using makefs, and these are generally not
limited to a 1.44MB or 2.88MB boundary.
Once the kernel has had the filesystem injected with mdsetimage, it
is compressed and then optionally manipulated into floppy sized
chunks.
Take a look at distrib/i386/floppies/ramdisk-big, and the associated
framework, to see this in aciton.
| 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?