Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 24 Mar 2005 12:36:27 +0200
From:      Giorgos Keramidas <keramida@ceid.upatras.gr>
To:        freebsd-questions@freebsd.org
Subject:   Re: What's an easy way to replace a drive?
Message-ID:  <20050324103627.GA1469@orion.daedalusnetworks.priv>
In-Reply-To: <1735169762.20050324050924@wanadoo.fr>
References:  <1735169762.20050324050924@wanadoo.fr>

next in thread | previous in thread | raw e-mail | index | archive | help
On 2005-03-24 05:09, Anthony Atkielski <atkielski.anthony@wanadoo.fr> 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.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20050324103627.GA1469>