From owner-freebsd-questions@FreeBSD.ORG Fri Oct 24 04:35:28 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 C3B3316A4B3 for ; Fri, 24 Oct 2003 04:35:28 -0700 (PDT) Received: from smtp.infracaninophile.co.uk (ns0.infracaninophile.co.uk [81.2.69.218]) by mx1.FreeBSD.org (Postfix) with ESMTP id BAD1643FD7 for ; Fri, 24 Oct 2003 04:35:26 -0700 (PDT) (envelope-from m.seaman@infracaninophile.co.uk) Received: from happy-idiot-talk.infracaninophile.co.uk (localhost [127.0.0.1]) h9OBZADK044324 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 24 Oct 2003 12:35:14 +0100 (BST) (envelope-from matthew@happy-idiot-talk.infracaninophile.co.uk) Received: (from matthew@localhost)id h9OBZ9L0044319; Fri, 24 Oct 2003 12:35:09 +0100 (BST) (envelope-from matthew) Date: Fri, 24 Oct 2003 12:35:09 +0100 From: Matthew Seaman To: Richard Shea Message-ID: <20031024113509.GB5768@happy-idiot-talk.infracaninophile.co.uk> Mail-Followup-To: Matthew Seaman , Richard Shea , FreeBSD Questions References: <20031024094745.73CC97775D@smtp.us2.messagingengine.com> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="gatW/ieO32f1wygP" Content-Disposition: inline In-Reply-To: <20031024094745.73CC97775D@smtp.us2.messagingengine.com> User-Agent: Mutt/1.5.4i X-Spam-Status: No, hits=-4.9 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=2.60 X-Spam-Checker-Version: SpamAssassin 2.60 (1.212-2003-09-23-exp) on happy-idiot-talk.infracaninophile.co.uk cc: FreeBSD Questions Subject: Re: Replacing drive with root file system on 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: Fri, 24 Oct 2003 11:35:29 -0000 --gatW/ieO32f1wygP Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Oct 24, 2003 at 10:47:45PM +1300, Richard Shea wrote: > Hi - I have a system with two IDE drives on it and I need more disk space > than I have . The current situation is : >=20 > Filesystem 1K-blocks Used Avail Capacity Mounted on > /dev/ad0s1a 257998 36308 201052 15% / > /dev/ad0s1f 498398 424568 33960 93% /usr > /dev/ad3s1e 7939980 6610848 693934 91% /usr/home > /dev/ad0s1e 226734 2542 206054 1% /var > procfs 4 4 0 100% /proc >=20 > I would like to swop the 1Gb ad0 drive for a larger drive. As you can see > the other IDE drive is almost full. Can anyone suggest how to move what's > on ad0 to a larger disk ? I wondered about=20 >=20 > 1. disconnecting the ad3 and putting a new drive in its place > 2. then (in some way) backuping up the entirety of ad0, restoring it to > the 'fake' ad3 3. then taking out the original ad0 and replacing with ad3 > 4. then (in some way) persuading machine to boot off new, larget drive, > with root on it=20 >=20 > ... would that work ? Can anyone fill in the details ? It it wouldn't > work can anyone suggset an alternative bearing in in mind I can only have > two drives and the largest each can be is 8Gb (old BIOS).=20 You have pretty much the right idea. I'd do the job something like this: i) Edit your /etc/fstab and comment out the line that mounts /usr/home. ii) Shutdown and remove the current ad3 drive. Add your new 8Gb disk in it's place. iii) Reboot to single user mode, mounting all of the partition from ad0, much as you would for doing a {build,install}world cycle: # fsck -p # swapon -a # mount -a iv) Set up the fdisk(8) slice table on your new drive: presumably you want the whole disk to be devoted to FreeBSD. This also sets up the boot sector so that you can eventually boot from the disk. # fdisk -B -b /boot/mbr -I ad3 Once you're done, modulo the exact size/cylinders/heads/sectors of the disk you should see output something like this: # fdisk ad3 Password: ******* Working on device /dev/ad3 ******* parameters extracted from in-core disklabel are: cylinders=3D4462 heads=3D255 sectors/track=3D63 (16065 blks/cyl) =20 Figures below won't work with BIOS for partitions not in cyl 1 parameters to be used for BIOS calculations are: cylinders=3D4462 heads=3D255 sectors/track=3D63 (16065 blks/cyl) =20 Media sector size is 512 Warning: BIOS sector numbering starts with sector 1 Information from DOS bootblock is: The data for partition 1 is: sysid 165,(FreeBSD/NetBSD/386BSD) start 63, size 71681967 (35000 Meg), flag 80 (active) beg: cyl 0/ head 1/ sector 1; end: cyl 1023/ head 254/ sector 63 The data for partition 2 is: The data for partition 3 is: The data for partition 4 is: v) Set up FreeBSD partitions on your new drive using disklabel(8) -- decide before hand what partitions and what sizes you want: # disklabel -e ad3s1 This will pop you into an editor -- you need to add lines at the end after where it says '8 partitions:' -- don't touch the line for c:, but add lines for a: (/), b: (swap), e: (/usr), f: (/var) etc. Set fstype to 4.2BSD (or swap for the swap partition). Some calculation will be necessary here. Sizes are given in numbers of sectors, which are usually 512bytes apiece. Eventually you should end up with something that looks rather like this: # size offset fstype [fsize bsize bps/cpg] a: 262144 0 4.2BSD 1024 8192 16 # (Cyl. = 0 - 16*) b: 2097152 262144 swap # (Cyl. 1= 6*- 146*) c: 71681967 0 unused 0 0 # (Cyl. = 0 - 4461*) e: 262144 2359296 4.2BSD 1024 8192 16 # (Cyl. 14= 6*- 163*) f: 12582912 2621440 4.2BSD 1024 8192 16 # (Cyl. 16= 3*- 946*) g: 56477615 15204352 4.2BSD 1024 8192 16 # (Cyl. 94= 6*- 4461*) You need to fill in the first three columns -- you can fill in the fsize, bsize and bps/cpg fields if you want, but the newfs(8) command used in the next step will fill in the blanks for you. The stuff after the '#' on each line is automatically generated. vi) Create filesystems on the new partitions using newfs(8). There are any number of parameters to play with when creating filesystems which is all very confusing. If you don't have a specific need for a specially laid out FS, then just take the defaults. These will be fine for general purpose filesystems of the sort of size you'll be needing: # newfs -v /dev/ad3s1a and the same for the other partitions ad3s1e, ad3s1f. You don't need to do anything special to prepare the swap (b) partition. If you want to use soft updates (definitely recommended for /usr and /var and usually good for / unless space is particularly tight) then you can enable it on the new partitions by # tunefs -n enable /dev/ad3s1a and analogously for the other filesystems. vii) Now mount the new partitions under /mnt: # mount -t ufs -o rw /dev/ad3s1a /mnt # mount -t ufs -o rw /dev/ad3s1e /mnt/usr # mount -t ufs -o rw /dev/ad3s1f /mnt/var viii) Use dump(8)/restore(8) to duplicate your original filesystems onto the new disk # dump -0 -f - / | ( cd /mnt ; restore rf - ) # dump -0 -f - /usr | ( cd /mnt/usr ; restore rf - ) # dump -0 -f - /var | ( cd /mnt/var ; restore rf - ) ix) Unmount your new partitions, shutdown the machine and move your new disk to replace your original boot disk. Stick your original /usr/home drive back in since you have the case open. x) Reboot to single user mode again. The system should come up smoothly from the new disk. If not, you'll have to open the case again, swap the old root disk back into the machine as ad0 and the new disk back to ad3 and you should be able to get the system back up and try and fix things. When you get to single user, do the usual fsck and mount things: # fsck -p # swapon -a # mount -a Now edit the /etc/fstab file to uncomment the /usr/home line. Then fsck and mount that partition: # fsck -p /dev/ad3s1e # mount /usr/home ix) If everything has gone well so far, type Ctrl-D to exit from single user mode and continue booting up to full multi-user mode. If not, you'll have to backtrack, work out what went wrong and fix it. x) That's it. You're done. Cheers, Matthew --=20 Dr Matthew J Seaman MA, D.Phil. 26 The Paddocks Savill Way PGP: http://www.infracaninophile.co.uk/pgpkey Marlow Tel: +44 1628 476614 Bucks., SL7 1TH UK --gatW/ieO32f1wygP Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.3 (FreeBSD) iD8DBQE/mQ5tdtESqEQa7a0RAmp/AKCUMT9Fi3wwuk2opdQRjhu68/9i/ACeOXNj 7uMtCi6OsFqWGwgliY5vha4= =LS6x -----END PGP SIGNATURE----- --gatW/ieO32f1wygP--