From owner-freebsd-questions@FreeBSD.ORG Thu Feb 5 22:25:06 2009 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5D47A10656C2 for ; Thu, 5 Feb 2009 22:25:06 +0000 (UTC) (envelope-from jerrymc@gizmo.acns.msu.edu) Received: from gizmo.acns.msu.edu (gizmo.acns.msu.edu [35.8.1.43]) by mx1.freebsd.org (Postfix) with ESMTP id 1988A8FC14 for ; Thu, 5 Feb 2009 22:25:05 +0000 (UTC) (envelope-from jerrymc@gizmo.acns.msu.edu) Received: from gizmo.acns.msu.edu (localhost [127.0.0.1]) by gizmo.acns.msu.edu (8.13.6/8.13.6) with ESMTP id n15MNQgw036852; Thu, 5 Feb 2009 17:23:26 -0500 (EST) (envelope-from jerrymc@gizmo.acns.msu.edu) Received: (from jerrymc@localhost) by gizmo.acns.msu.edu (8.13.6/8.13.6/Submit) id n15MNQcd036851; Thu, 5 Feb 2009 17:23:26 -0500 (EST) (envelope-from jerrymc) Date: Thu, 5 Feb 2009 17:23:26 -0500 From: Jerry McAllister To: perikillo Message-ID: <20090205222326.GA36658@gizmo.acns.msu.edu> References: <51d7a5160902051219j252b222ao5c0bd53498524244@mail.gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <51d7a5160902051219j252b222ao5c0bd53498524244@mail.gmail.com> User-Agent: Mutt/1.4.2.2i Cc: FreeBSD Mailing List Subject: Re: Shrink a Slice? FreeBSD 7.1 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, 05 Feb 2009 22:25:07 -0000 On Thu, Feb 05, 2009 at 12:19:13PM -0800, perikillo wrote: > Hi people. > I have been googling without any good info about: How to shrink a slice? > > Case: I installed a new server for mysql, is working, I already install > all the ports I need, them I spend a lot of hours yesterday with this baby, > now this is my current disk layout: > > /dev/ad0s1a on / (ufs, local, noatime, soft-updates) > devfs on /dev (devfs, local) > /dev/ad0s1f on /tmp (ufs, local, noatime, soft-updates) > /dev/ad0s1d on /usr (ufs, local, noatime, soft-updates) > /dev/ad0s1e on /var (ufs, local, noatime, soft-updates) > /dev/ad0s1g on /backups (ufs, local, soft-updates) > > What I want to do is to shrink the slice /dev/ad0s1g /dev/ad0s1g is a partition, not a slice. /dev/ad0s1 is the slice. MicroSloth usage of the terms is different and confuses people sometimes. As far as I know neither growfs(8) nor tunefs(8) can shrink the disk allocated to a partition. The only way is to dump each of the filesystems to some other reliable media (maybe tape or a large USB disk) and then repartition that slice to be the sizes you want. Use dump(8) to make the dumps and then check the dump files out before starting the repartitioning. First you have to build a filesystem on the USB drive. You should be able to use bsdlabel to create a single partition that covers the whole drive. But, if your FreeBSD or BIOS is old enough it might not go that big, so you will need to break it down in to smaller slices and make a partition in each. (I have had to do that. But if it is 7.xx it should not be necessary) To break it up, get the gparted utility. Download its boot image and use it to break up the USB disk in to slices that your FreeBSD will handle. You need to have it make all what it calls (in the MS way) Primary Partitions, but those are what are called slices in FreeBSD land. Don't get tempted to use gparted to shrink your ad0s1 slice because it will not work right. That will just trash the current partitions. It is not what you are looking for. Either if your FreeBSD will handle the whole USB or after you have it broken up, then build a partition on each slice of the USB using bsdlabel. Don't make it bootable or write a boot sector on it. Then run newfs(8) on it to make a filesystem. This bsdlabel and newfs can be done while the system is running. Then, take the system down and run the dumps. You can do the dumps from single user mode or boot a fixit image from the install CD. You will need to do the repartitioning and restore the dumps from the fixit anyway so you could just start there. Boot the machine from the fixit disk - create a 'holographic' image as they call it. Fixit is usually on disc1. Run the dumps. Lets say you are doing the dumps to a USB drive that comes up as /dev/da0 in the fixit boot and your current disk still is comes up with the name /dev/ad0 . First, make up mount points for all your filesystems that you want to dump plus for the filesystem[s] on the USB drive. NOTE: That the fixit runs from a memory resident filesystem so whatever you create there will disappear on boot. Anyway, skip dumping /tmp and /dev is a pretend filesystem. mkdir /oldroot mkdir /oldusr mkdir /oldvar mkdir /oldbkup mkdir /usbdrive (You can actually make the dumps from the devices rather than mounting them, but I have never gotten in to that habit) Mount those partitions mount /dev/ad0s1a /oldroot mount /dev/ad0s1d /oldusr mount /dev/ad0s1e /oldvar mount /dev/ad0s1g /oldbkup mount /dev/da0s1 /usbdrive (This device name might be different depending on how you make it. Some possibilities are: /dev/da0s1 If you just newfs the slice without making a partition in it /dev/da0s1a If you make a slice with fdisk and a partition with bsdlabel /dev/da0a If you make a partition with bsdlabel without making a slice Now do the dumps dump 0af /usbdrive/rootdump /oldroot dump 0af /usbdrive/usrdump /oldusr dump 0af /usbdrive/vardump /oldvar dump 0af /usbdrive/bkupdump /oldbkup This will take a while depending on media you use. By the way, to tape it would go to /dev/nsa0 rather than /usbdrive/oldroot, etc Once the dumps are done, you may want to reboot and mount that USB drive or read the tape and look at the dumps to make sure they can be read. Just a precaution. At least you will need to unmount all the partitions so bsdlabel can work on them Anyway, once you are happy with your dumps, then get back in to the fixit and use bsdlabel to rewrite the partitions. Just bsdlabel -e ad0s1 (You should not need to write a new boot block as this process should not touch that sector) Adjust the partitions as you see fit. Make partition 'a' start at offset of 0 and use a '*' for the rest of the offsets. bsdlabel will calculate them correctly. You can also make the size of the last partition be '*' and bsdlabel will put the remainder of the usable space in it. Write/Quit out of the bsdlabel editor -- just like vi. Now you need to do a newfs for each partition except for swap. Just take the defaults. Do: newfs /dev/ad0s1a newfs /dev/ad0s1d newfs /dev/ad0s1e etc for how many you made. Once that is done, you need to mount up the partitions and restore the dumps. Remember that if you rebooted the fixit from when you first made the mount points, you will have to make them again and remount things. Restores will look like: cd /oldroot restore -rf /usbdrive/rootdump cd /oldusr restore -rf /usbdrive/usrdump cd /oldvar restore -rf /usbdrive/vardump cd /oldbkup restore -rf /usbdrive/bkupdump If you created a new partition while doing this, there is currently nothing to put in it. You will need to reboot and then you can split things up and move data as you see fit. ////jerry > > Filesystem 1M-blocks Used Avail Capacity Mounted on > /dev/ad0s1a 495 232 223 51% / > devfs 0 0 0 100% /dev > /dev/ad0s1f 495 0 456 0% /tmp > /dev/ad0s1d 5967 4225 1264 77% /usr > /dev/ad0s1e 15863 1343 13251 9% /var > /dev/ad0s1g 272313 48823 201704 19% /backups > > Like u can see, is the last slice I have, is posible to remove that slice > and create a new one? > > I don't have info there yet and is not a freebsd default slice, I know > that I need to umount first. > > I have been reading some post but all I have seen is that ins not possible > or I'm wrong? > > I try to with sysinstall looks like don't let me do this. > > Running FreeBSD 7.1-p2. > > Thanks all for your time!!! > _______________________________________________ > 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"