*BSD News Article 29548


Return to BSD News archive

Newsgroups: comp.os.386bsd.questions
Path: sserve!newshost.anu.edu.au!munnari.oz.au!bunyip.cc.uq.oz.au!harbinger.cc.monash.edu.au!yeshua.marcam.com!MathWorks.Com!europa.eng.gtefsd.com!howland.reston.ans.net!xlink.net!boss.pem-stuttgart.de!delos.stgt.sub.org!luva!migieger
From: migieger@luva.stgt.sub.org (Michael Giegerich)
Subject: Re: I'm *this* close to mounting a dos partition in netbsd..
Keywords: NetBSD0.9 
References: <CnMLBs.GvA@cnsnews.colorado.edu>
Organization: private FreeBSD site
Date: Sat, 9 Apr 1994 20:51:57 GMT
Message-ID: <Co0FB0.2Jt@luva.stgt.sub.org>
Lines: 193

In article <CnMLBs.GvA@cnsnews.colorado.edu>,
-=Runaway Daemon=- <frechett@benji.Colorado.EDU> wrote:
>Some time back Charles Hannun posted some tips on installing
>a DOS partition from netbsd.  Something like this:
>
>Quote:
>1) Use NetBSD `fdisk' or DOS `pfdisk' to create a NetBSD partition
> spanning the whole disk in the MBR.
>2) Save the MBR.  (dd if=/dev/rwd1d of=blah bs=1b count=1)
>3) Create a NetBSD disk label containing the DOS partition, with the
> appropriate offset.
>4) Write the label to the disk, blowing away the MBR and the rest of
> the boot track.
>5) Restore the saved MBR.  (dd if=blah of=/dev/rwd1d bs=1b count=1)
>I've done it many times now.
>End Quote.

Complicated, but it should work.

>
>I am apparently lacking some critical bits of information or some
>assumptions were made above that do not apply to my situation.
>I have a Maxtor 7245 drive formated with geometry 966c/16h/31s.
>
>1. I used a a dos based fdisk to have it create a partition the full
>  length of the disk which should be cyl 0-165 size 479136 sectors.
                                            ^^^
                                            965

>  I set the type to 165 for NetBSD

Which partition editor do you use?

>
>Question: Assuming I want to use the whole drive this should be the ONLY
>  parition on the drive.. correct?

Yes.

>
>Question: Do I do anything at this stage to indicate at all that I'm
>  trying to create a DOS partition that spans the entire disk?

?
You did just create a partition spanning the whole drive and thereafter
you set the label to 165.
You don't have any space left for another partition, yes?

>
>2. I saved the MBR as described above from netbsd.

You typed `dd if=/dev/rwd0d of=blah bs=1b count=1', yes?
                         ^
                         The 1st IDE drive (DOS can't boot from 2nd hd)

>3. I have a disktab entry that looks like
>  maxtor245:Maxtor 7245: \
>        :ty=winchester:dt=ST506:se#512:nt#16:ns#31:nc#967:rm#3600:\
                                                       ^^^
                                             should be 966

>        :pa#479136:oa#0:ba#8192:fa#1024:ta=MSDOS: \
                                            ^^^^^
Should be `4.2BSD' as `a' is allways the BSD root partition (`b'
should be reserved to the BSD swap part., `c' to the whole BSD part
disk. of the disk, `d' to the whole physical disk).
Making the BSD partition as big as the whole disk you won't have
any place for your MSDOS partition.
My suggestion: Decide on the size of the DOS partition (eg. 32 MB)
and then choose the number of sectors so, that the last sector re-
sides on a cyl. boundary; keep in mind that the 1st track of a DOS
partition should never be accessed by mountpsfs
(eg. :pf#62465:of#31:
62465 is obtained as 16 h * 31 spt * 126 c - 31 s
I use the `f' part. for MSDOS - you can use any part. after `d', but
as I have some usr part. too the next free in my case is `f')

Next step: rest of the drive is for BSD: chose values for a, b, c, d
partitions
(eg.     :pa#92256:oa#62496:ba#4096:fa#512:ta=4.2BSD: \
15 MB = aprox. 60 cyls., offset after the MSDOS part.,
once again I recommend even cyl. boundaries for all BSD part. too
15 MB for /root are enough.
BTW, with a small disk as yours I wouldn't use 8196/1024 blocks.
         :pb#92256:ob#154752:tb=swap: \
15 MB = 60 cyls. for swap: I recommend twice as much swap space as
you have RAM in your system (these figures are for an 8 MB system).
         :pc#416640:oc#62496:bc#4096:fc#512:tc=4.2BSD: \
the whole BSD drive
         :pd#479136:oc#0: \
the whole physical drive, including the MSDOS part.
         :pe#169632:oe#247008:be#4096:fe#512:te=4.2BSD:
whoppy 85 MB for your /usr partition :-)

Just for a better readability, the whole disktab entry again:

   maxtor245:Maxtor 7245: \
         :ty=winchester:dt=ST506:se#512:nt#16:ns#31:nc#967:rm#3600:\
         :pa#92256:oa#62496:ba#4096:fa#512:ta=4.2BSD: \
         :pb#92256:ob#154752:tb=swap: \
         :pc#416640:oc#62496:bc#4096:fc#512:tc=4.2BSD: \
         :pd#479136:oc#0: \
         :pe#169632:oe#247008:be#4096:fe#512:te=4.2BSD: \
         :pf#62465:of#31:

>
>Something odd happens when I look at the partition from netbsd with
>fdisk.. It shows that the partition actually starts at sector 31
>and thus the total size is decreased such that it is no longer a valid
>multiple of the DOS block size 4096 bytes.
>479136 - 31 = (47105s * 512 byte/s) / 4096 bytes/dos_block = 5888.125
>and obviously I'm going to see
>mountpcfs(): root directory is not a multiple of the clustersize in length
>When I try to mount.

As you set the fs type to MSDOS in disktab, it's mountpcfs which tries
to mount the disk (not the normal ufs mount).
I found that the 1st track (in your case the 1st 31 sectors) can't be
accessed with mountpcfs (this makes sense, since the 1st track homes
the MBR which shouldn't be overwritten (normally :-) ).

>Undaunted I write the above disklabel with
>> disklabel -w -r maxtor245

Should work with the correct disktab entry (be sure you use the boot-
blocks you really want...).

>
>4. I follow the step above to restore the MBR
>
>and try to mount from fstab or 
>> mount -t msdos /dev/wd1a /msdos
>and I do indeed get the above error.

See above...

>
>Question: At what point do I actually go reformat the dos partition
>  from DOS.  As soon as I write a disklabel DOS stops even recognizing
>  that D: drive exists.  Only [p]fdisk can see it at all.

Not, if you have a disktab which actually reflects a MSDOS partition.
Don't forget to rewrite the saved MBR (see step 5. in Charles' recept).

>
>Question: How do I resolve the problem with it wanting to start
>  at offset 31.  Obviously it looks like it needs room on the disk
>  for the MBR starting at Sector 0.  Should the netbsd partition be
>  from sector 0 to sector 47136 or from sector 31? 

The MSDOS part. from 31, see above.

>  Does netbsd disklabel actually create a partition that DOS will
>  be able to see?

No, that's the reason you need to reinstall the MBR you saved before.
disklabel accomodates only the BSD part.

>
>
>Basically, the only setup I've seen work was when someone was working
>with a little DOS partition somewhere right in the middle of their
>netbsd formatted drive and it was conviently created with exact sizes  
>such that the block size works out.   I really need to know where
>the actual DOS side of it comes into play after I've basically destroyed
>any knowledge DOS had of the disk.

I have a 1st IDE drive with
 1. DOS
 2. OS/2
 3. Extended DOS
 4. BSD (/root only, /usr resides on a 1gig sd :-)
working very well...

I'm using os-bs to choose the os to start with. It's much better than
using fdisk every time to set active the part. you want to start from
next time you boot.

>
>BTW, I'm going through all this so I can backup my netbsd stuff to a
>DOS formatted drive where I can then use my qic-02 tape to back
>it all up, seeing as netbsd's and freebsd's wt.c can't seem to 
>recognize my qic-02 controller.  One way or another I'm going to get
>this crap backed up. 

Odd.

Hope this helps,
-Michael
-- 
------------------------------+------------------------------
Michael Giegerich             | migieger@luva.stgt.sub.org
------------------------------+------------------------------