growfs error message, lack of comprehension

2014-07-08 Thread Adam Thompson
On 5.4-RELEASE, I'm trying to use growfs to expand a root filesystem. 
I've grown the disk from 2GB to 10GB, I've used disklabel(8) to adjust 
the OpenBSD area and the size of partition 'a'.  All those numbers line up.
Rebooting into bsd.rd, copying /sbin/growfs to the ramdisk, and then 
using it (successfully, more or less), I still see this error:


new filesystem size is: 3411480 frags
Warning: 376928 sector(s) cannot be allocated.
growfs: not enough new space

I can see in growfs.c where that messages is being emitted, and I see 
the comment there that says The space in the new last cylinder group is 
too small, so revert back.
I lack, however, a sufficiently low-level understanding of FFS internals 
to understand _why_ the space in the new last cylinder group is too small.
dumpfs(8) reports cylgrp dynamic inodes 4.4BSD fslevel 3, which I 
vaguely understood to mean that cylinder groups were now 
dynamically-sized things...?


So, per growfs, what is the space too small _for_ ?  Too small for 
another cylinder group?  How would I go about calculating how much more 
(or less) disk space I would need to make growfs happy, and not wasting ?


Now waiting incoming cluebats :-(

--
-Adam Thompson
 athom...@athompso.net



Re: growfs error message, lack of comprehension

2014-07-08 Thread Otto Moerbeek
On Tue, Jul 08, 2014 at 09:41:08PM -0500, Adam Thompson wrote:

 On 5.4-RELEASE, I'm trying to use growfs to expand a root filesystem. I've
 grown the disk from 2GB to 10GB, I've used disklabel(8) to adjust the
 OpenBSD area and the size of partition 'a'.  All those numbers line up.
 Rebooting into bsd.rd, copying /sbin/growfs to the ramdisk, and then using
 it (successfully, more or less), I still see this error:
 
 new filesystem size is: 3411480 frags
 Warning: 376928 sector(s) cannot be allocated.
 growfs: not enough new space
 
 I can see in growfs.c where that messages is being emitted, and I see the
 comment there that says The space in the new last cylinder group is too
 small, so revert back.
 I lack, however, a sufficiently low-level understanding of FFS internals to
 understand _why_ the space in the new last cylinder group is too small.
 dumpfs(8) reports cylgrp dynamic inodes 4.4BSD fslevel 3, which I vaguely
 understood to mean that cylinder groups were now dynamically-sized
 things...?
 
 So, per growfs, what is the space too small _for_ ?  Too small for another
 cylinder group?  How would I go about calculating how much more (or less)
 disk space I would need to make growfs happy, and not wasting ?
 
 Now waiting incoming cluebats :-(
 
 -- 
 -Adam Thompson
  athom...@athompso.net

An ffs filsystems consist of a number of cylinder groups. Note that
this term is fornm the old days, these days cylinders do not matter at
all. Each group holds it's own inode table, block usage bitmap and
summary information (but note that files can span cgs).

The cylinder group size is fixed during newfs. The last cylinder group can
be smaller than the standard size, but needs to be big enough to hold
the minimal amount of metadata like the inode table and block usage bitmap.

Now assume a cylgroup size is 100, old size of the disk was 500, so
you have 5 cgs. If you grow it to 601, the last cg would need to be 1
in size, which might be too small to hold the cg meta info.

The message says that you hit a situation where the last cg would have
been to small, so instead of n new cylinder groups you get n-1. 

Now use dumpfs.

Look at the superblock: dblkno is the offset of the start of
the data area (in frags) of a cylgroup. That's the minimal size of a
cylinder group.
fpg is the standard group size (in frags). You should be able to
compute what you want using these numbers. dumpfs also reports the
size of the last cg.

dynamic has to do with the rotational info, it is hardly relevant,
afaik. 

-Otto