From owner-freebsd-questions@FreeBSD.ORG Thu Oct 27 22:49:17 2005 Return-Path: X-Original-To: freebsd-questions@freebsd.org Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id C645216A41F for ; Thu, 27 Oct 2005 22:49:17 +0000 (GMT) (envelope-from jerrymc@clunix.cl.msu.edu) Received: from clunix.cl.msu.edu (clunix.cl.msu.edu [35.9.2.10]) by mx1.FreeBSD.org (Postfix) with ESMTP id 2705143D46 for ; Thu, 27 Oct 2005 22:49:16 +0000 (GMT) (envelope-from jerrymc@clunix.cl.msu.edu) Received: from clunix.cl.msu.edu (localhost [127.0.0.1]) by clunix.cl.msu.edu (8.12.10+Sun/8.12.2) with ESMTP id j9RMnE38006564; Thu, 27 Oct 2005 18:49:14 -0400 (EDT) Received: (from jerrymc@localhost) by clunix.cl.msu.edu (8.12.10+Sun/8.12.2/Submit) id j9RMnEs6006563; Thu, 27 Oct 2005 18:49:14 -0400 (EDT) From: Jerry McAllister Message-Id: <200510272249.j9RMnEs6006563@clunix.cl.msu.edu> To: freebsd@redry.net (eoghan) Date: Thu, 27 Oct 2005 18:49:14 -0400 (EDT) In-Reply-To: X-Mailer: ELM [version 2.5 PL7] MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Cc: freebsd-questions@freebsd.org Subject: Re: increasing mount size X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 27 Oct 2005 22:49:17 -0000 > > Hello > My /var mount has no more space left. I was wondering if there is > some way to increase the size of it without loosing anything? This is a frequent question on the list. There might even be a FAQ on it. You might check. I know I have written numerous responses to essentially the same question. The first thing to do is find out what is using up all the space. In /var, it may well be log files that are outdated and can be thrown away, or stuff stuck in /var/spool that never goes anywhere, or something of that nature. To start checking, go in to that directory and run du(1) cd /var du -sk * Then if you see a directory that seems abnormally large, go in to it and run du again until you get a clearer picture of what is using the space and if it is something you need to keep or can just nuke. Presuming you need to keep enough of the stuff that it won't free up enough space for you, you have two options. One is to get a larger or additional disk. Another is to look for a existing file system that isn't getting much use. If you have enough extra space somewhere else such as in a /junk file system you made way back, just for something to do with extra space, then you can move the biggest consumers of space there and make symlinks. Lets say /var/spool is gobbling scads of space and you want to move it in to /junk Go to /junk and create a directory for it - say var.spool tar stuff up and move it check it for peace of mind make the symlink clean up cd /junk mkdir var.spool cd /var/spool tar cvpf /junk/varspool.tar * cd /junk/var.spool tar xvpf ../varspool.tar Look at stuff to make sure it is cool. cd /var mv spool spool.old ln -s /junk/var.spool spool Check things out some more. At this stage, it should all be working from the copy in /junk/var.spool If you do a cd /var/spool and then a pwd you should see that you are really in /junk/var.spool Then clean up. cd /var rm -rf spool.old cd /junk rm varspool.tar Voila - lots of space now in var and room for spool to grow as well. Note that the way I describe is somewhat due to lack of confidence in stuff. It results in three copies of /var/spool for a short time until you clean up. You could pipe the one tar in to another and it would work fine and leave you with just two copies until cleanup. I also explain it this way, because it is more straightforward to understand. If you add a disk, fdisk, disklabel/bsdlabel and newfs it to get a filesystem, then the process of moving some part of /var there is exactly the same. Only the names (of where you are putting it) change a little. If you add a disk and make a big file system on it just for /var then use dump(8) and restore(8) to move the old /var to the new file system and then just edit /etc/fstab so that the new file system gets mounted as /var instead of the old one. Let's presume your current /var is /dev/da0s1e. Let's also say you created a /dev/da1s1f (amongst possibly others) with lots of room and you want to put /var there. cd / mkdir tmpvar (Could probably use /mnt but I usually mount /dev/da1s1f /tmpvar already have that one tied up elsewhere) cd /tmpvar dump 0af - /var | restore rf - Then edit /etc/fstab so that the previous line: /dev/da0s1e /var ufs rw 2 2 Now looks like: /dev/da1s1f /var ufs rw 2 2 Then you remount /var umount /var mount /var I think you can just do mount -u /var Now it will be using the new one and you have some left over space on the old disk (/dev/da0s1e) to decide what to do with. You can use it as scratch space. cd / mkdir scratch mount /dev/da0s1e /scratch Make an /etc/fstab entry that looks like: /dev/da0s1e /scratch ufs rw 2 2 And it will mount on boot. If your current /var is not its own separately mounted filesystem - but really just a part of /root, which is most often the case, then you will not be able to use dump/restore to move stuff. You will need to use tar. But the rest is the same in that you create the new filesystem on the new disk. Then put stuff there like we did with tar above when moving just the /var/spool directory except you move the whole /var instead of just /var/spool. Then make the entry in /etc/fstab. But, before mounting it, rename the old /var and make a new mount point - somewhat like we did above when moving just /var/spool. cd / mv /var /var.old mkdir var mount /dev/da1s1f /var Now you can clean up the old space cd / rm -rf var.old That will automatically return all that space to the /root filesystem. ////jerry > Thanks > Eoghan