From owner-freebsd-hackers Fri Jul 13 16:32:23 2001 Delivered-To: freebsd-hackers@freebsd.org Received: from salmon.maths.tcd.ie (salmon.maths.tcd.ie [134.226.81.11]) by hub.freebsd.org (Postfix) with SMTP id 9B1A537B403 for ; Fri, 13 Jul 2001 16:32:17 -0700 (PDT) (envelope-from iedowse@maths.tcd.ie) Received: from walton.maths.tcd.ie by salmon.maths.tcd.ie with SMTP id ; 14 Jul 2001 00:32:15 +0100 (BST) To: David Gilbert Cc: Matt Dillon , Thierry Herbelot , Alfred Perlstein , hackers@FreeBSD.ORG Subject: Re: Swapping in diskless ? (was :Re: [hackers] Re: getting rid of sysinstall) In-Reply-To: Your message of "Fri, 13 Jul 2001 18:37:48 EDT." <15183.30780.779907.874814@trooper.velocet.net> Date: Sat, 14 Jul 2001 00:32:14 +0100 From: Ian Dowse Message-ID: <200107140032.aa55106@salmon.maths.tcd.ie> Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG In message <15183.30780.779907.874814@trooper.velocet.net>, David Gilbert write s: >Is it not possible (or has nobody done it) to swap with the current >diskless boot? I do remember some problem with PXE and swap, but I forget the details or if it was resolved. The diskless setup that we have locally uses an MFS root image in the kernel instead of an NFS root, which meant that we couldn't use DHCP tags to configure swap. Our solution was a small patch that allows swapon(8) to configure direct swapping to NFS regular files. This does the same thing as the DHCP swap tags, but is much more controllable - the rc scripts can do something like: swap=/swap/swapfile rm -f $swap truncate -s 30M $swap swapon $swap The patch (against RELENG_4) is below; I wonder should this just be committed? We have certainly found it quite useful. Ian Index: vm_swap.c =================================================================== RCS file: /FreeBSD/FreeBSD-CVS/src/sys/vm/vm_swap.c,v retrieving revision 1.96.2.1 diff -u -r1.96.2.1 vm_swap.c --- vm_swap.c 2000/10/13 07:13:23 1.96.2.1 +++ vm_swap.c 2001/07/13 23:12:10 @@ -202,10 +202,14 @@ NDFREE(&nd, NDF_ONLY_PNBUF); vp = nd.ni_vp; - vn_isdisk(vp, &error); - - if (!error) + if (vn_isdisk(vp, &error)) error = swaponvp(p, vp, vp->v_rdev, 0); + else if (vp->v_type == VREG && vp->v_tag == VT_NFS) { + struct vattr attr; + error = VOP_GETATTR(vp, &attr, p->p_ucred, p); + if (!error) + error = swaponvp(p, vp, NODEV, attr.va_size/DEV_BSIZE); + } if (error) vrele(vp); To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message