Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 14 Jul 2001 00:32:14 +0100
From:      Ian Dowse <iedowse@maths.tcd.ie>
To:        David Gilbert <dgilbert@velocet.ca>
Cc:        Matt Dillon <dillon@earth.backplane.com>, Thierry Herbelot <thierry@herbelot.com>, Alfred Perlstein <bright@sneakerz.org>, hackers@FreeBSD.ORG
Subject:   Re: Swapping in diskless ? (was :Re: [hackers] Re: getting rid of sysinstall) 
Message-ID:   <200107140032.aa55106@salmon.maths.tcd.ie>
In-Reply-To: Your message of "Fri, 13 Jul 2001 18:37:48 EDT." <15183.30780.779907.874814@trooper.velocet.net> 

next in thread | previous in thread | raw e-mail | index | archive | help
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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi? <200107140032.aa55106>