Compiling Swap space

Steve O'Hara-Smith steve at sohara.org
Tue Feb 27 17:32:30 UTC 2018


On Tue, 27 Feb 2018 13:16:01 +0000
RW via freebsd-questions <freebsd-questions at freebsd.org> wrote:

> On Tue, 27 Feb 2018 08:09:19 +0000
> Steve O'Hara-Smith wrote:
> 
> > On 27 Feb 2018 00:23:46 -0500
> > "John Levine" <johnl at iecc.com> wrote:
> 
> > > You can also use mdconfig to make an md device backed by a file and
> > > swap on that.  That's slower than a swap partition since it has to  
> > 
> > 	You don't need mdconfig, just make a large file and use
> > swapon like this:
> > 
> > # dd if=/dev/zero of=swapfile bs=1m count=1024
> > # swapon swapfile
> 
> 
> I tried that and got:
> 
>   # swapon swapfile
>   swapon: swapfile: Block device required

	Hmm, I used to use swap files a lot and it worked when I tried it
earlier ... repeating hmmm interesting:

[root at steve /home/steve]# dd if=/dev/zero of=swapfile bs=1m count=128
128+0 records in
128+0 records out
134217728 bytes transferred in 7.005077 secs (19160066 bytes/sec)
[root at steve /home/steve]# swapon swapfile
[root at steve /home/steve]# swapinfo
Device          1K-blocks     Used    Avail Capacity
<NFSfile>          131072        0   131072     0%
[root at steve /home/steve]# swapoff swapfile

	I'd forgotten I was in an NFS mounted directory when I tried it
earlier and got the expected result.

	So you can swap onto a file in an NFS mounted directory but not a
local file - bizarre!

-- 
Steve O'Hara-Smith <steve at sohara.org>


More information about the freebsd-questions mailing list