Brian Rose | 7 Feb 2003 18:41
Favicon

File system image


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.

(Continue reading)

David Laight | 7 Feb 2003 18:50
Picon

Re: File system image

> 
> I tried using virtual devices, but you cannot disklabel a virtual 
> device.

man vnd

	David

--

-- 
David Laight: david <at> l8s.co.uk

Perry E. Metzger | 7 Feb 2003 19:16
Gravatar

Re: File system image


You should read the scripts that build NetBSD boot media. No physical
drives are used in the process at all.

Brian Rose <saider <at> gate.net> writes:

> 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
[...]

Brian Rose | 7 Feb 2003 20:17
Favicon

Re: File system image


Wojciech Puchar wrote:

>I tried using virtual devices, but you cannot disklabel a virtual
>  
>

why? could you please say what was a problem?

David Laight wrote:

>>I tried using virtual devices, but you cannot disklabel a virtual 
>>device.
>>    
>>
>
>man vnd
>
>	David
>  
>
I was doing some googling on the subject, and I came across some 
articles that mentioned that the virtual device driver does not have the 
proper ioctl routines that disklabel uses. I don't know the details. 
After I read several of these I decided to try to find a workaround. I 
tried the following with no errors...

1) dd if=/dev/zero of=fs_16M.img bs=512 count=32768
2) vnconfig -c -v /dev/rvnd0 fs_16M.img
3) fdisk -i /dev/vnd0
(Continue reading)

Michael Kukat | 7 Feb 2003 19:13

Re: File system image

Hello,

On Fri, 7 Feb 2003, Brian Rose wrote:
> 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.

It works with virtualk devices. Try this:

(assuming a virtual disk with 512 bytes blocksize, 64 sectors, 32 heads, 16
tracks = 16 MB)

[root <at> calchas tmp]# dd if=/dev/zero bs=512 count=$((64*32*16)) of=vdisk.img
[root <at> calchas tmp]# vnconfig vnd0 `pwd`/vdisk.img 512/64/32/16
[root <at> calchas tmp]# disklabel -eI vnd0
(edit your disklabel like you want it)
[root <at> calchas tmp]# newfs vnd0a
[root <at> calchas tmp]# mount /dev/vnd0a /mnt
(copy your files)
[root <at> calchas tmp]# umount /mnt
[root <at> calchas tmp]# vnconfig -u vnd0

Now, mdsetimage should work. Never tried this last step, but above, you just
have the directions how to make the filesystem in an any-sized virtual disk.
Looking at the values, just change the "16" in dd and in vnconfig to the value
in megs you want to use.
(Continue reading)

Brian Rose | 7 Feb 2003 22:28
Favicon

Re: File system image

Perry E. Metzger wrote:

>You should read the scripts that build NetBSD boot media. No physical
>drives are used in the process at all.
>
>Brian Rose <saider <at> gate.net> writes:
>
>  
>
>>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
>>    
>>
>[...]
>  
>

I was looking in that area and the problem I ran across was when I was 
trying to initialize the disklabel, I found that all the boot media seem 
to use either 1.44 Meg floppies or 2.88 Meg floppies, both of which have 
an entry in the disktab file.
(Continue reading)

Perry E. Metzger | 7 Feb 2003 22:32
Gravatar

Re: File system image


Brian Rose <saider <at> gate.net> writes:
> I was looking in that area and the problem I ran across was when I was
> trying to initialize the disklabel, I found that all the boot media
> seem to use either 1.44 Meg floppies or 2.88 Meg floppies, both of
> which have an entry in the disktab file.

The disklabel program doesn't need an actual functioning disktab to
operate -- indeed, the average drive running NetBSD doesn't have a
disktab. You can just run it -- try out disklabel -i for example.

And yes, you can run it on a vnd based file system (obbviously.)

> The main problem I am having is that my kernel won't boot. When I
> select it from the boot menu, it loads it up and resets the machine. I
> see the numbers as the kernel is loading, but it reboots immediately
> after, when the banner is usually displayed.
> 
> I'm going to be delving into the source code to find out what is going
> on, but if anyone can shed light as to what is happening, I'd
> appreciate it.

You might want to explain what you are loading this kernel from and
what the kernel has been configured to do.

--

-- 
Perry E. Metzger		perry <at> piermont.com

Perry E. Metzger | 7 Feb 2003 22:46
Gravatar

Re: File system image


Brian Rose <saider <at> gate.net> writes:
> I was doing some googling on the subject, and I came across some
> articles that mentioned that the virtual device driver does not have
> the proper ioctl routines that disklabel uses. I don't know the
> details. After I read several of these I decided to try to find a
> workaround. I tried the following with no errors...

You can set the "geometry" of your vnd device with vnconfig, fyi.

--

-- 
Perry E. Metzger		perry <at> piermont.com

David Laight | 7 Feb 2003 23:12
Picon

Re: File system image

> 11) FTP the test image to my test machine, reboot and at the boot 
> prompt, select netbsd.test as the kernel to boot.
> 
> The bootloader seems to load the kernel (I see the numbers) and then 
> reboots immediately.

You need to use the correct geometry of the target drive when you
build your image.  Otherwise it will go 'tits up'.

Actually you also have a problem unless the image is copies to the
bottom of the hard disk because part of teh boot sequence uses
absolute sector numbers.

	David

--

-- 
David Laight: david <at> l8s.co.uk

Brian Rose | 8 Feb 2003 00:33
Favicon

Re: File system image


David Laight wrote:

>>11) FTP the test image to my test machine, reboot and at the boot 
>>prompt, select netbsd.test as the kernel to boot.
>>
>>The bootloader seems to load the kernel (I see the numbers) and then 
>>reboots immediately.
>>    
>>
>
>You need to use the correct geometry of the target drive when you
>build your image.  Otherwise it will go 'tits up'.
>
>Actually you also have a problem unless the image is copies to the
>bottom of the hard disk because part of teh boot sequence uses
>absolute sector numbers.
>
>
>	David
>  
>

I thought that the target drive would be irrelevant after booting. 
Here's some more background on my little project.

I am building for a i386 target. The machine is a PC104 sized system 
with a 2GB hard drive and a 32MB Disk-On-Chip. My goal is to develop a 
small NetBSD system that will fit on the DOC without the need for a hard 
drive. But for now I am booting off of the hard drive. There is no 
(Continue reading)


Gmane