On Wed, Oct 26, 2005 at 12:42:04PM +0200, Han Boetes wrote:
> Hi,
> 
> I just wrote this article about migrating to a new HD after the
> old one got too flakey.
> 
> I maintain the original over here:
> 
>   http://www.xs4all.nl/~hanb/documents/hd-migration
> 
> 
> HD MIGRATION:
> 
> It started with my HD failing to sync when I was rebooting. And
> some odd errormessages I saw. So I was holding my breath hoping
> for it to be something else or just an incident. But it only got
> worse. So After a reboot and nearly loosing a lot of important
> stuff I decided to make the switch. And after a struggle with cp
> and rsync I had everything set like I should I found out that an
> old lilo was still haunting the MBR and I knew no way to get rid
> of it since I had no floppy. So, I could start all over again.
> 
> I decided to write it all down so noone would have to suffer the
> same as me. After some tips on #OpenBSD I found the following
> procedure:
> 
> My original harddisk was wd0 and the usb2 external drive sd0 is
> the new drive, which I will swap with the old drive after all is
> done.
> 
> # I use the whole disk and this is the command I had to use in the
> # first instance to get rid of lilo.
> 
> fdisk -i sd0
> 
> # Now I could also reconsider my partitiontable and I increased my
> # /var partition which I wanted to do for a long time. You can
> # also add or remove partitions if you like that. After having the
> # right partition table in my mind I disklabel. It's a pretty
> # straightforward tool, so I won't bother explaining how it works.
> 
> disklabel -e sd0
> 
> # newfs is also really simple.
> 
> newfs /dev/sd0a
> newfs /dev/sd0d
> # etc, etc.
> 
> # And then I mounted the new filesystem. The extra options speed
> # up the copying of files.
> 
> mkdir /mnt/new
> mount -o async,noatime,softdep /dev/sd0a /mnt/new
> cd /mnt/new
> mount -o async,noatime,softdep /dev/sd0d tmp
> mount -o async,noatime,softdep /dev/sd0e var
> mount -o async,noatime,softdep /dev/sd0f usr
> mount -o async,noatime,softdep /dev/sd0g home
> 
> # First I prepared the dirs I didn't want to copy.
> 
> mkdir dev
> cp /dev/MAKEDEV dev
> cd dev
> ./MAKEDEV all
> cd ..
> 
> mkdir altroot kern mnt proc stand tmp
> 
> # Also make sure you set the right permissions for /tmp
> 
> chmod 1777 /tmp
> 
> # There are two ways I found pretty comfortable to copy dirs. cp
> # -Rp is fast. rsync shows what's going on, and you can easily
> # update the remaining differences. So if you don't want to use
> # rsync you'll have to do the copying in single user mode.
> 
> cp -Rp /etc .
> rsync -aP /var .
> 
> # And so on and so forth for all remaining dirs and files and
> # symlinks in /
> 
> # Actually right before I swapped the drives I went into single
> # usermode and copied over the last changes to /var and /home with
> # rsync.
> 
> # Then I installed the bootloader.
> 
> cp usr/mdec/boot .
> cd usr/mdec
> ./installboot /mnt/new/boot ./biosboot sd0
> 
> # After that I switched the drives, double-checking the
> # master/slave selector. And I booted with the new and HD and
> # rejoiced.

some thoughts:
1. make backups: dump(8) and restore(8) are your friends.
2. wouldn't it be much easier to use the installer to install OpenBSD onto
   the new hard disk, boot from the new disk when finished, mount your old
   disk and copy over files as desired? (you could consider unplugging
   the old disk if it is going bad, and plug it back in when you're
   ready to start copying.)

-- 
steven

Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm

Reply via email to