From owner-freebsd-arch Sun Dec 9 12:50:52 2001 Delivered-To: freebsd-arch@freebsd.org Received: from glatton.cnchost.com (glatton.cnchost.com [207.155.248.47]) by hub.freebsd.org (Postfix) with ESMTP id 194BA37B405 for ; Sun, 9 Dec 2001 12:50:50 -0800 (PST) Received: from bitblocks.com (adsl-209-204-185-216.sonic.net [209.204.185.216]) by glatton.cnchost.com id PAA26830; Sun, 9 Dec 2001 15:50:49 -0500 (EST) [ConcentricHost SMTP Relay 1.14] Message-ID: <200112092050.PAA26830@glatton.cnchost.com> To: freebsd-arch@FreeBSD.ORG Subject: Real world Root Resizing (was Re: Proposed auto-sizing patch ... Date: Sun, 09 Dec 2001 12:50:49 -0800 From: Bakul Shah Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Changing sysinstall helps new installations but doesn't help existing systems with a "tiny" root fs -- something I had to fix recently. I was surprised to see how easy it was! Here is the procedure I used, in case anyone else needs to do the same. Assume ad0s1a is the root filesystem and ad0s1b is the swap partition and its size is atleast new root fs size + old root fs size. Do this as single user on a freshly booted system. 1. disklabel ad0s1 > label # save a copy of the disklabel 2. disklabel -e ad0s1 if the new root size is N, change the b partition to start at offset N. make its size the same as partition a and make its type 4.2BSD type. 3. dd /dev/ad0s1b bs=1m 4. fsck /dev/ad0s1b 5. echo 'boot_askname="YES"' >> /boot/loader.conf 6. shutdown -r now 7. boot in single user mode and when asked, choose the b partition as root. 8. disklabel -e ad0s1 change 'a' partition size to N. 9. growfs -s N /dev/ad0s1a 10. fsck /dev/ad0s1a # just to convince yourself everything is okay 11. shutdown -r now 12. boot in single user mode and when aske, choose the a partition as root. 13. disklabel -e ad0s1 restore the swap partition (to its new reduced size) 14. remove the change to /boot/loader.conf made in step 5. 15. reboot If there is an easier way, I'd like to hear about it. In particular if / can be switched at runtime, all of this can be done in one program without so many reboots. One can even write a program to shuffle filesystems around to grow any fs so long as there is some space somewhere! Disclaimer: use at your own risk. make backups and keep a cleenex handy in case you screw up. make notes while doing this to aid in debugging in case things go wrong. growfs should take an optional argument -A (for Auto :-) to grow a fs to fill up the partition. growfs needs to be renamed grow_ufs in case in future growfs is extended to grow other fs types. Ditto for newfs, dumpfs, tunafish and so on. -- bakul To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message