From owner-svn-doc-all@FreeBSD.ORG Thu Feb 6 04:03:29 2014 Return-Path: Delivered-To: svn-doc-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 7CB684FA; Thu, 6 Feb 2014 04:03:29 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 627D61102; Thu, 6 Feb 2014 04:03:29 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s1643Tus014319; Thu, 6 Feb 2014 04:03:29 GMT (envelope-from wblock@svn.freebsd.org) Received: (from wblock@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s1643Tpe014318; Thu, 6 Feb 2014 04:03:29 GMT (envelope-from wblock@svn.freebsd.org) Message-Id: <201402060403.s1643Tpe014318@svn.freebsd.org> From: Warren Block Date: Thu, 6 Feb 2014 04:03:29 +0000 (UTC) To: doc-committers@freebsd.org, svn-doc-all@freebsd.org, svn-doc-head@freebsd.org Subject: svn commit: r43798 - head/en_US.ISO8859-1/books/handbook/disks X-SVN-Group: doc-head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-doc-all@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: "SVN commit messages for the entire doc trees \(except for " user" , " projects" , and " translations" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 06 Feb 2014 04:03:29 -0000 Author: wblock Date: Thu Feb 6 04:03:28 2014 New Revision: 43798 URL: http://svnweb.freebsd.org/changeset/doc/43798 Log: Add a new section on growing disks. Modified version of patch submitted with PR. PR: docs/186377 Submitted by: Allan Jude Modified: head/en_US.ISO8859-1/books/handbook/disks/chapter.xml Modified: head/en_US.ISO8859-1/books/handbook/disks/chapter.xml ============================================================================== --- head/en_US.ISO8859-1/books/handbook/disks/chapter.xml Thu Feb 6 01:58:10 2014 (r43797) +++ head/en_US.ISO8859-1/books/handbook/disks/chapter.xml Thu Feb 6 04:03:28 2014 (r43798) @@ -252,6 +252,154 @@ &prompt.root; mount /newdisk + + + Resizing and Growing Disks + + + + + Allan + Jude + + Originally contributed by + + + + + + disks + resizing + + + A disk's capacity can increase without any changes to the + data already present. This happens commonly with virtual + machines, when the virtual disk turns out to be too small and is + enlarged. Sometimes a disk image is written to a + USB memory stick, but does not use the full + capacity. Here we describe how to resize or + grow disk contents to take advantage of + increased capacity. + + Determine the device name of the disk to be resized by + inspecting /var/run/dmesg.boot. In this + example, there is only one SATA disk in the + system, so the drive will appear as + ada0. + + partitions + + gpart + + + List the partitions on the disk to see the current + configuration: + + &prompt.root; gpart show ada0 +=> 34 83886013 ada0 GPT (48G) [CORRUPT] + 34 128 1 freebsd-boot (64k) + 162 79691648 2 freebsd-ufs (38G) + 79691810 4194236 3 freebsd-swap (2G) + 83886046 1 - free - (512B) + + + If the disk was formatted with the + GPT partitioning scheme, it may show + as corrupted because the GPT + backup partition table is no longer at the end of the + drive. Fix the backup + partition table with + gpart: + + &prompt.root; gpart recover ada0 +ada0 recovered + + + Now the additional space on the disk is available for + use by a new partition, or an existing partition can be + expanded: + + &prompt.root; gpart show ada0 +=> 34 102399933 ada0 GPT (48G) + 34 128 1 freebsd-boot (64k) + 162 79691648 2 freebsd-ufs (38G) + 79691810 4194236 3 freebsd-swap (2G) + 83886046 18513921 - free - (8.8G) + + Partitions can only be resized into contiguous free space. + Here, the last partition on the disk is the swap partition, but + the second partition is the one that needs to be resized. Swap + partitions only contain temporary data, so it can safely be + unmounted, deleted, and then recreated after resizing other + partitions. + + &prompt.root; swapoff /dev/ada0p3 +&prompt.root; gpart delete -i 3 ada0 +ada0p3 deleted +&prompt.root; gpart show ada0 +=> 34 102399933 ada0 GPT (48G) + 34 128 1 freebsd-boot (64k) + 162 79691648 2 freebsd-ufs (38G) + 79691810 22708157 - free - (10G) + + + There is risk of data loss when modifying the partition + table of a mounted file system. It is best to perform the + following steps on an unmounted file system while running from + a live CD-ROM or USB + device. However, if absolutely necessary, a mounted file + system can be resized after disabling GEOM safety + features: + + &prompt.root; sysctl kern.geom.debugflags=16 + + + Resize the partition, leaving room to recreate a swap + partition of the desired size. This only modifies the size of + the partition. The file system in the partition will be + expanded in a separate step. + + &prompt.root; gpart resize -i 2 -a 4k -s 47G ada0 +ada0p2 resized +&prompt.root; gpart show ada0 +=> 34 102399933 ada0 GPT (48G) + 34 128 1 freebsd-boot (64k) + 162 98566144 2 freebsd-ufs (47G) + 98566306 3833661 - free - (1.8G) + + Recreate the swap partition: + + &prompt.root; gpart add -t freebsd-swap -a 4k ada0 +ada0p3 added +&prompt.root; gpart show ada0 +=> 34 102399933 ada0 GPT (48G) + 34 128 1 freebsd-boot (64k) + 162 98566144 2 freebsd-ufs (47G) + 98566306 3833661 3 freebsd-swap (1.8G) +&prompt.root; swapon /dev/ada0p3 + + Grow the UFS file system to use the new + capacity of the resized partition: + + + Growing a live UFS file system is only + possible in &os; 10.0-RELEASE and later. For earlier + versions, the file system must not be mounted. + + + &prompt.root; growfs /dev/ada0p2 +Device is mounted read-write; resizing will result in temporary write suspension for /. +It's strongly recommended to make a backup before growing the file system. +OK to grow file system on /dev/ada0p2, mounted on /, from 38GB to 47GB? [Yes/No] Yes +super-block backups (for fsck -b #) at: + 80781312, 82063552, 83345792, 84628032, 85910272, 87192512, 88474752, + 89756992, 91039232, 92321472, 93603712, 94885952, 96168192, 97450432 + + Both the partition and the file system on it have now been + resized to use the newly-available disk space. + + USB Storage Devices