From owner-freebsd-questions@FreeBSD.ORG Sun May 26 09:32:36 2013 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id E32CF29A for ; Sun, 26 May 2013 09:32:36 +0000 (UTC) (envelope-from freebsd@edvax.de) Received: from mx01.qsc.de (mx01.qsc.de [213.148.129.14]) by mx1.freebsd.org (Postfix) with ESMTP id AD15CFF2 for ; Sun, 26 May 2013 09:32:36 +0000 (UTC) Received: from r56.edvax.de (port-92-195-231-35.dynamic.qsc.de [92.195.231.35]) by mx01.qsc.de (Postfix) with ESMTP id 506E43CC6B; Sun, 26 May 2013 11:32:25 +0200 (CEST) Received: from r56.edvax.de (localhost [127.0.0.1]) by r56.edvax.de (8.14.5/8.14.5) with SMTP id r4Q9WZZx010949; Sun, 26 May 2013 11:32:36 +0200 (CEST) (envelope-from freebsd@edvax.de) Date: Sun, 26 May 2013 11:32:35 +0200 From: Polytropon To: Erich Dollansky Subject: Re: "swap" partition leads to instability? Message-Id: <20130526113235.f5dbe768.freebsd@edvax.de> In-Reply-To: <20130526160906.4e379016@X220.ovitrap.com> References: <1369558712.96152.YahooMailNeo@web165006.mail.bf1.yahoo.com> <20130526160906.4e379016@X220.ovitrap.com> Organization: EDVAX X-Mailer: Sylpheed 3.1.1 (GTK+ 2.24.5; i386-portbld-freebsd8.2) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: "freebsd-questions@freebsd.org" , "M. V." X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: Polytropon List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 26 May 2013 09:32:36 -0000 On Sun, 26 May 2013 16:09:06 +0700, Erich Dollansky wrote: > Hi, > > On Sun, 26 May 2013 01:58:32 -0700 (PDT) > "M. V." wrote: > > > I have a 24/7 network server/gateway with FreeBSD-8.2 on a SSD drive. > > it's partitioned as normal (/ , /tmp, /var , /usr and swap) for a > > long time now. But recently I heard from a FreeBSD expert that I > > shouldn't have swap partition for my server, and having swap > > partition could make my server unstable. this was so strange for me, > > and I searched a lot but couldn't find a reason for this claim. > > > because it is a false claim. I never ever have had any system with > working hard, that gave a problem because of the swap space. I think the "problem" here is that he's using a SSD. As soon as the swap partition is being in heavy use, which means it receives many writes, this may lead to the SSD "wearing out", decreasing its lifetime. Swap space usually does not make a system unstable. Sometimes, the opposite is true. :-) So if you're using a SSD, you can apply certain optimizations to increase its lifetime so it can be in use for several years (running 24/7). Here are some suggestions -- check if they are useful in your specific case! # newfs -m 0 -i 16384 -b 16384 -f 2048 -U /dev/ada0a This assumes that you don't have created any slices, just one bootable partition covering the whole disk (therefor ada0a). Create a swapfile like this: # /bin/rm -f /swapfile.tmp # /bin/dd if=/dev/zero of=/swapfile.tmp bs=16m seek=1k count=0 # /sbin/mdconfig -a -t vnode -u 0 -f /swapfile.tmp || /bin/sh # /bin/chflags nodump /swapfile.tmp # /bin/rm -f /swapfile.tmp # /sbin/swapctl -a /dev/md0 This makes the system use a "disk-backed dynamic swap file". If the swap won't be used, no space will be occupied or "reserved" on the SSD. You can also think about "changing stuff" you won't need to store on the SSD, maybe some content of /tmp or /var. You can also put those into a "memory disk". The "SSD rule" is: Minimize writes if you can. This is a _general_ rule and does not correspond to swap only! -- Polytropon Magdeburg, Germany Happy FreeBSD user since 4.0 Andra moi ennepe, Mousa, ...