Best way to replace a drive with a clone
Steven Stern
subscribed-lists at sterndata.com
Sat Jul 31 23:45:30 UTC 2010
On 07/31/2010 03:21 PM, Jussi Lehtola wrote:
> On Sat, 2010-07-31 at 12:59 -0500, Steven Stern wrote:
>> According to the SMART stats, the single drive in my Fedora server is
>> starting to fail. Rather than backup, do a clean install, and rebuild,
>> I'd like to try to clone the existing drive to a new one, then swap in
>> the new one.
>>
>> What are the restrictions on doing this and the best way to accomplish
>> it? I have the Clonezilla Live CD that I use for backup. Will that do
>> it?
>>
>> Or will a straight dd do it?
>> add new drive as PATA slave /dev/sdb
>> dd -if /dev/sda -of /dev/sdb
>> remove /dev/sda
>> change the jumpers on /dev/sdb to match what was /dev/sda
>> reboot
>>
>> In the dd procedure, I'm not sure what to do if sdb is larger than sda.
>
> What I normally do is boot the system e.g. with the Fedora install CD in
> rescue mode, which automatically mounts the old system, and then I
>
> 1. partition new drive
> 2. format partitions on new drive
> 3. mount new filesystem tree in e.g. /mnt/newroot
> 4. run
> # rsync -au /mnt/sysimage/ /mnt/newroot/
> 5. edit fstab in new etc to reflect new partitions
> 6. install grub on new drive
> 7. unmount and reboot
>
> This way you can easily change the sizes of partitions and also their
> file systems, which can be handy if you want to take advantage of new
> file system features. And, you only copy the data, not empty space (I
> don't think dd does this, although smarter tools should do it).
>
> Also, if you're running SELinux run
> # touch /mnt/newroot/.autorelabel
> before rebooting, since rsync doesn't preserve security contexts..
Cool. Thanks.
--
-- Steve
More information about the users
mailing list