swap at beginning of slice - danger?

Dmitry Pryanishnikov dmitry at atlantis.dp.ua
Wed Mar 15 14:22:48 UTC 2006


Hello!

On Wed, 15 Mar 2006, Oliver Fromme wrote:
> >  # bsdlabel ad0s1 | fgrep b:
> >    b:  2097152        0      swap
> >
> > Previously, on a 4.11 system, swapinfo said that swap size was less than
> > size of b: partition on a slice - it was ok, as boot sectors are
> > located at beginning of slice. But now, sizes match exactly. What
> > changed and is it dangerous nowadays to have swap partition at offset 0 ?
>
> The code in sys/swap_pager.c does not touch the first two
> blocks, where blocks are measured in PAGE_SIZE units.
> The smallest page size supported on FreeBSD architectures
> is 4 KB (on i386), so that's at least 2 * 4k, which is 16
> sectors on the disk.  That's enough to skip MBR, disklabel
> and boot blocks.

  You're right about RELENG_5 (and CURRENT). I've found this code (though not 
from the first attempt ;) in /sys/vm/swap_pager.c, at start of 
swaponsomething():

         /*
          * Do not free the first two block in order to avoid overwriting
          * any bsd label at the front of the partition
          */
         blist_free(sp->sw_blist, 2, nblks - 2);

However I don't see any equivalent code in RELENG_4. Neither can I find where 
it's documented, and thus any guarantees that it won't disappear tomorrow ;(

> In other words:  You're save.  No danger.  No need to worry.

  In this particular case - yes.


Sincerely, Dmitry
-- 
Atlantis ISP, System Administrator
e-mail:  dmitry at atlantis.dp.ua
nic-hdl: LYNX-RIPE


More information about the freebsd-stable mailing list