From owner-freebsd-questions@FreeBSD.ORG Thu Mar 24 10:36:32 2005 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 23E8716A4CE for ; Thu, 24 Mar 2005 10:36:32 +0000 (GMT) Received: from rosebud.otenet.gr (rosebud.otenet.gr [195.170.0.26]) by mx1.FreeBSD.org (Postfix) with ESMTP id 257DD43D39 for ; Thu, 24 Mar 2005 10:36:30 +0000 (GMT) (envelope-from keramida@ceid.upatras.gr) Received: from orion.daedalusnetworks.priv (aris.bedc.ondsl.gr [62.103.39.226])j2OAZrXG014868 for ; Thu, 24 Mar 2005 12:35:53 +0200 Received: from orion.daedalusnetworks.priv (orion [127.0.0.1]) j2OAaSWV001604 for ; Thu, 24 Mar 2005 12:36:28 +0200 (EET) (envelope-from keramida@ceid.upatras.gr) Received: (from keramida@localhost)j2OAaRO8001603 for freebsd-questions@freebsd.org; Thu, 24 Mar 2005 12:36:27 +0200 (EET) (envelope-from keramida@ceid.upatras.gr) Date: Thu, 24 Mar 2005 12:36:27 +0200 From: Giorgos Keramidas To: freebsd-questions@freebsd.org Message-ID: <20050324103627.GA1469@orion.daedalusnetworks.priv> References: <1735169762.20050324050924@wanadoo.fr> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1735169762.20050324050924@wanadoo.fr> Subject: Re: What's an easy way to replace a drive? 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: Thu, 24 Mar 2005 10:36:32 -0000 On 2005-03-24 05:09, Anthony Atkielski wrote: > The continuing problems I'm having with my SATA drives seem to center on > only one of the two drives, /dev/ad10, and since both drives are > identical (Western Digital WD1200JD 120-GB SATA drives), this is a good > indicator that the drive itself might be failing. So I've decided to > spend $83 and buy a replacement drive to see if that fixes the problem. > > Now, what's the easiest way to replace the drive? The drive I want to > replace contains only /var and /tmp. Are these mounted in single-user > mode? I was thinking perhaps I can just replace the drive, set up > identical slices on the new drive, then restore /var and /tmp from the > latest backup. Can I restore from tape in single-user mode? > > I don't have any extra connectors to which I can attach this drive > without removing one of the other drives, so I'm looking for a way to > fix it up by just removing the old drive and putting in the new one, > without the need to have both old and new drives online at the same > time. You'll have to use some sort of temporary storage for the data of the original /var and/or /tmp then. A tape or a local partition with a lot of free space will do just fine. If your other partitions have enough space to hold a compressed copy of the files, i.e. in var.cpio.gz and tmp.cpio.gz under /usr/backup, you can use that space as a temporary storage area. It takes a bit of planning and care, but it's relatively straightforward: 1. Boot single user 2. Mount all the file systems manually. This takes a bit of effort, but it's not too hard: # adjkerntz -i # swapon -a # fsck -p # mount -u / # mount -va 3. Copy over the files of /var and /tmp under /usr/backup: # mkdir /usr/backup # cd /var # find . | cpio -o | gzip -9c - > /usr/backup/var.cpio.gz # cd /tmp # find . | cpio -o | gzip -9c - > /usr/backup/tmp.cpio.gz 4. Make sure your backup copies are fine: # cd /usr/backup # zcat tmp.cpio.gz | cpio -i -tv # zcat var.cpio.gz | cpio -i -tv 5. Sync your disks, and halt the system. 6. While the system is turned off, swap disks. 7. Boot in single user mode again. 8. Mount everything (as before), except for /tmp and /var. You can either mount the file systems one by one, or mount the root file system as read-write, comment out the fstab entries for /var and /tmp and use `mount -a' as before. 9. Partition, label and newfs the new disk. One way of doing this from the command line. 10. Mount the partitions of the new disk in their new location. 11. Restore everything from /usr/backup: # cd /tmp # zcat /usr/backup/tmp.cpio.gz | cpio -i -dmvu # cd /var # zcat /usr/backup/var.cpio.gz | cpio -i -dmvu 12. Sync your disks & reboot. 13. Optionally, after you verify that everything works as expected, delete the compress CPIO archives from /usr/backup.