From owner-freebsd-stable@FreeBSD.ORG Wed Mar 15 15:42:23 2006 Return-Path: X-Original-To: freebsd-stable@FreeBSD.ORG Delivered-To: freebsd-stable@FreeBSD.ORG Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id DFDA216A401 for ; Wed, 15 Mar 2006 15:42:23 +0000 (UTC) (envelope-from olli@lurza.secnetix.de) Received: from lurza.secnetix.de (lurza.secnetix.de [83.120.8.8]) by mx1.FreeBSD.org (Postfix) with ESMTP id 002DA43D5A for ; Wed, 15 Mar 2006 15:42:18 +0000 (GMT) (envelope-from olli@lurza.secnetix.de) Received: from lurza.secnetix.de (xqvcpa@localhost [127.0.0.1]) by lurza.secnetix.de (8.13.4/8.13.4) with ESMTP id k2FFgBm8038015 for ; Wed, 15 Mar 2006 16:42:16 +0100 (CET) (envelope-from oliver.fromme@secnetix.de) Received: (from olli@localhost) by lurza.secnetix.de (8.13.4/8.13.1/Submit) id k2FFgBSY038014; Wed, 15 Mar 2006 16:42:11 +0100 (CET) (envelope-from olli) Date: Wed, 15 Mar 2006 16:42:11 +0100 (CET) Message-Id: <200603151542.k2FFgBSY038014@lurza.secnetix.de> From: Oliver Fromme To: freebsd-stable@FreeBSD.ORG In-Reply-To: <20060315161248.L47405@atlantis.atlantis.dp.ua> X-Newsgroups: list.freebsd-stable User-Agent: tin/1.8.0-20051224 ("Ronay") (UNIX) (FreeBSD/4.11-STABLE (i386)) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-2.1.2 (lurza.secnetix.de [127.0.0.1]); Wed, 15 Mar 2006 16:42:16 +0100 (CET) Cc: Subject: Re: swap at beginning of slice - danger? X-BeenThere: freebsd-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: freebsd-stable@FreeBSD.ORG List-Id: Production branch of FreeBSD source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 15 Mar 2006 15:42:24 -0000 Dmitry Pryanishnikov wrote: > 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). And RELENG_6, of course. > However I don't see any equivalent code in RELENG_4. RELENG_4 doesn't touch the first sectors of the swap partition either. See the calculations for vsbase in vm/vm_swap.c in the swaponvp() function. Apart from that, RELENG_4 is pretty much dead, as far as development is concerned, so nobody would suddenly change how partitions are laid out by default. > Neither can I find where it's documented, > and thus any guarantees that it won't disappear tomorrow ;( The comment in the source clearly state _why_ the first two blocks of the swap partition are excluded, so no developper will rip that out. UFS skips the first 16 sectors, too -- that won't change either, and nobody is really worried about it. By the way, the first partition on a disk is usually the root partition, not the swap partition. So the problem could arise only in unusual circumstances. > > In other words: You're save. No danger. No need to worry. > > In this particular case - yes. If you create a swap partition intentionally at the start of a disk (for whatever reason), and if you're paranoid, then make sure it starts at offset 16, not 0. But even with offset 0 you're save. Best regards Oliver -- Oliver Fromme, secnetix GmbH & Co. KG, Marktplatz 29, 85567 Grafing Dienstleistungen mit Schwerpunkt FreeBSD: http://www.secnetix.de/bsd Any opinions expressed in this message may be personal to the author and may not necessarily reflect the opinions of secnetix in any way. "In My Egoistical Opinion, most people's C programs should be indented six feet downward and covered with dirt." -- Blair P. Houghton