From owner-freebsd-current@FreeBSD.ORG Fri Oct 25 16:00:56 2013 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 17ED4C98 for ; Fri, 25 Oct 2013 16:00:56 +0000 (UTC) (envelope-from rosti.bsd@gmail.com) Received: from mail-we0-x22e.google.com (mail-we0-x22e.google.com [IPv6:2a00:1450:400c:c03::22e]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id AB5952FF9 for ; Fri, 25 Oct 2013 16:00:55 +0000 (UTC) Received: by mail-we0-f174.google.com with SMTP id u56so4022037wes.19 for ; Fri, 25 Oct 2013 09:00:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=pElBtltYp5QA6FOgTQr2FJB8ikXnc7kvsnK/9bpth+M=; b=d+ukc/tK3XXpLUV7WvqKdNubQ4+CkedCXb+Hy9NJ7cWoXZn/SCzY2+wY5Jj9zDnzhm SYCG+pwEKQGLZEUV3r+bIjgJFcsPfgLz3mJTxad7x3StJ90EuBSY5mI8m1gGvPp2BGqD CTifMWw6k0VXiOv30wcVeABVYwxmd6n/5CqimiroI3qx9F6WA7JXHAj39pqYaT4d9s3k DE2VNqYG4yroL75Oyqe67DLL/bKkPYQhw8xYEDHvMp7d+3nfsQWn+P1+t2x5PLu/VvJ+ pT9DHGYYGXNULoB8N5ITOBiHDZi+H7F38MNjTmppC2LIVIwQxB0kKYe5k2/3FIdVr3sX o8Pw== MIME-Version: 1.0 X-Received: by 10.194.63.228 with SMTP id j4mr7973149wjs.34.1382716854100; Fri, 25 Oct 2013 09:00:54 -0700 (PDT) Received: by 10.194.216.2 with HTTP; Fri, 25 Oct 2013 09:00:54 -0700 (PDT) In-Reply-To: References: Date: Fri, 25 Oct 2013 18:00:54 +0200 Message-ID: Subject: Re: Using a swap file From: Rostislav Krasny To: freebsd-current@freebsd.org Content-Type: text/plain; charset=UTF-8 X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Oct 2013 16:00:56 -0000 On Fri, Oct 25, 2013 at 6:31 PM, Rostislav Krasny wrote: > On Fri, Oct 25, 2013 at 3:50 PM, Rostislav Krasny wrote: >> Hi there, >> >> I've 10.0-BETA1 i386 installed and I want to use a swap file instead >> of a swap partition. I created /swapfile and I'm able to enable it >> manually by following commands: >> >> mdconfig -a -t vnode -f /swapfile -u 0 >> swapon /dev/md0 >> >> This is according to the following section of the Handbook: >> >> http://www.freebsd.org/doc/handbook/adding-swap-space.html >> >> It still states that adding swapfile="" into >> /etc/rc.conf enables that swap file during a boot automatically. >> However this is already not true for CURRENT and for the upcoming 10.0 >> release. According to following commit number 252310 this rc.conf >> parameter is obsolete >> >> http://svnweb.freebsd.org/base?view=revision&revision=252310 >> >> It introduces different configuration and offers to add a line like >> following into /etc/fstab >> >> md none swap sw,file=/swapfile 0 0 >> >> This is what I did but 'swapon -a' still doesn't work. I didn't try to >> reboot because I build world in other console. But I believe the >> result will be the same, because /etc/rc.d/swap runs the same command: >> '/sbin/swapon -aq'. So what is the right way to enable a swap file >> during a boot and for commands like 'swapon -a' ? >> >> Thanks >> >> P.S. The Handbook needs to be updated > > After rebooting (into an updated system) the swap file somehow turned > on and was running through /dev/md0. Unfortunately after running > 'swapoff -a' it is impossibly to turn it back on and /dev/md0 is > disappeared. So the swapon(8) program is still broken. Finally I've figured out how to turn swap on in case it's on a swap file: root@saturn:~ # swapon -aL swapon: adding /dev/md0 as swap device This is (with an additional -q parameter) what /etc/rc.d/swaplate does during the boot. But from the swapon(8) manual page this is not obvious: The swapon utility adds the specified swap devices to the system. If the -a option is used, all swap devices in /etc/fstab will be added, unless their ``noauto'' or ``late'' option is also set. If the -L option is specified, swap devices with the ``late'' option will be added as well as ones with no option. If the -q option is used, informational messages will not be written to standard output when a swap device is added. But I have no 'late' option in my /etc/fstab: root@saturn:~ # cat /etc/fstab # Device Mountpoint FStype Options Dump Pass# /dev/ada0s2a / ufs rw 1 1 md none swap sw,file=/swapfile 0 0 Then why 'swapon -a' (without -L) doesn't work? It's either buggy or confusing. P.S. Please update the Handbook as well.