From owner-freebsd-questions@FreeBSD.ORG Tue Sep 16 06:50:31 2003 Return-Path: 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 2E38C16A4B3 for ; Tue, 16 Sep 2003 06:50:31 -0700 (PDT) Received: from clunix.cl.msu.edu (clunix.cl.msu.edu [35.9.2.10]) by mx1.FreeBSD.org (Postfix) with ESMTP id 2A85043F75 for ; Tue, 16 Sep 2003 06:50:30 -0700 (PDT) (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.9/8.12.9) with ESMTP id h8GDoSOg012803; Tue, 16 Sep 2003 09:50:28 -0400 (EDT) Received: (from jerrymc@localhost) by clunix.cl.msu.edu (8.12.9/8.12.9/Submit) id h8GDoS7H012802; Tue, 16 Sep 2003 09:50:28 -0400 (EDT) From: Jerry McAllister Message-Id: <200309161350.h8GDoS7H012802@clunix.cl.msu.edu> To: michaela@maa-net.net (Michael A. Alestock) Date: Tue, 16 Sep 2003 09:50:27 -0400 (EDT) In-Reply-To: <20030916061250.D70110@bsd.maa-net.net> from "Michael A. Alestock" at Sep 16, 2003 06:19:28 AM X-Mailer: ELM [version 2.5 PL2] MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit cc: questions@freebsd.org Subject: Re: LABEL (The FreeBSD Disklabel Editor) X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 16 Sep 2003 13:50:31 -0000 > > I have an existing FreeBSD v4.7 installation and want to delete a small > filesystem that I had designated for email (/var/mail), and want to freeup > that unused space to the '/usr/home' filesystem. If I use DISKLABEL to > delete '/var/mail', and then re-write '/usr/home' to reflect the added > space (writing the changes to the SAME '/usr/home' partition), will that > erase the '/usr/home' filesystem and all of its user-data contents > from the disk itself??? If I understand what you are saying, you have two (ingoring others that are not involved such as root) file systems /var/mail and /usr/home and you want to combine the space from /var/mail in to /usr/home. By filesystems I do not mean just directories within other filesystems. They are separately mountable entities. If they are just directories within their respective filesystems eg you have /var and /usr filesystems and mail is just a directory within /var and home is just a directory within /usr, then it is a completely different story. To combine those two filesystems (/var/mail and /usr/home) you need to repartition the disk using disklabel and then run newfs again. Running newfs on the newly combined larger partition will wipe out everything previously (sort of - it doesn't actually overwrite the data, just the superblocks which makes it unreachable by normal means). There is something called 'growfs' that can allow a filesystem to grow to take in some additional free space without wiping out what was already in the filesystem. I have not yet used growfs, but it might work for you. I would guess that at the least you would have to use disklabel to remove the partition that is used for /var/mail. Someone else might better comment on growfs. The disk space to be added must be addressibly contiguous to the base filesystem that you are trying to increase. I believe that is true for growfs as well as for recreating the filesystem with disklabel and newfs. If the two spaces are not contiguous, then you will have to redo your who slice partitioning schema and remake all of the partitions and re-newfs them. Since I can't say much about growfs, I will comment only on merging the full re-creation way. So, presuming the two spaces are contiguous, NOTE: this is best done in single user mode, but can be done in multi. make a good backup of the /usr/home filesystem. Use dump(8) dump -0af /dev/nrsa0 /usr/home (presumes a tape drive. Change the device to whereever you dump to) Check it out with restore. mt rewind restore -ivf /dev/nrsa0 look around a little, maybe restore a file. Then unmount the filesystems umount /usr/home umount /var/mail Then bring up disklabel disklabel -r -e /da0s1 (or whatever the disk slice device is) edit the partition table to combine the two in to one. Example, say disklabel shows something like the following: 8 partitions: # size offset fstype [fsize bsize bps/cpg] a: 2514944 0 4.2BSD 2048 16384 89 # (Cyl. 0 - 156*) b: 4618240 2514944 swap # (Cyl. 156*- 444*) c: 35551782 0 unused 0 0 # (Cyl. 0 - 2212*) e: 2514944 7133184 4.2BSD 2048 16384 89 # (Cyl. 444*- 600*) f: 25903654 9648128 4.2BSD 2048 16384 89 # (Cyl. 600*- 2212*) and you want to combine partitions e and f Edit it to look like the following (all the stuff after the # is ignored so nuke it) 8 partitions: # size offset fstype [fsize bsize bps/cpg] a: 2514944 0 4.2BSD 2048 16384 89 # (Cyl. 0 - 156*) b: 4618240 2514944 swap # (Cyl. 156*- 444*) c: 35551782 0 unused 0 0 # (Cyl. 0 - 2212*) e: 28418598 7133184 4.2BSD 2048 16384 # Or better yet, if you are using a recent FreeBSD version 8 partitions: # size offset fstype [fsize bsize bps/cpg] a: 2514944 0 4.2BSD 2048 16384 89 # (Cyl. 0 - 156*) b: 4618240 * swap # (Cyl. 156*- 444*) c: * 0 unused 0 0 # (Cyl. 0 - 2212*) e: * * 4.2BSD 2048 16384 # The newer disklabel will calculate for you all of the offsets and the size of the 'c' partition and the last partition if that is to be all of the remaining disk. Note in either case you are leaving the other partitons as is (whatever that may be in your case). Get out of the editor with a write back (save). You might want to check it to make sure it is happy by doing: disklabel -r da0s1 which forces it to read the actual label Then do the newfs newfs /dev/rda0s1e Get the device right or you have big trouble mount the newly remade filesystem mount /usr/home (presuming it is already in /etc/fstab from before) Restore the backup cd /usr/home mt rewind restore -xf /dev/nrsa0 When it finishes, all should be well. If the spaces are not contiguous on the disk (as shown by disklabel) then you will have to back up each partition, adjust the partitioning for all of the partitions with disklabel. Newfs each of the newly moved partitions and then restore the backups. If it seems complicated, it helps to write down all the commands in advance. It is easy to forget a step in the heat of the moment if you are not used to doing this stuff (even if you are used to it). If the spaces are contiguous, check out growfs to see if it will work well. If /var/mail and/or /usr/home are not separate filesystems, but just directories within filesystems, you will have to do a variation on the whole reshuffle - at least for the filesystems involved. Good luck, ////jerry > > _______________________________________________ > freebsd-questions@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-questions > To unsubscribe, send any mail to "freebsd-questions-unsubscribe@freebsd.org" >