Migrating a Solaris Install to a New Disk
From Docupedia
Date: 6/14/2007
Contents |
Overview
This how-to covers moving a working Solaris install from one disk to another, with all other hardware remaining constant. I found this useful for upgrading an older workstation from a small disk to a much larger one without having to rebuild the install (which is sometimes very undesirable on a system that has been around for a while).
I do this by copying the files across using 'ufsdump'-- it might be possible with a straight 'dd', but I haven't tried this and don't see a need to.
This is not really necessary if the disks are of the same size or you are keeping the partitions the same size--- using Solaris Volume Manager / Solstice Disk Suite to mirror the drive across would probably be more straightforward.
Partition the New Disk
The new disk must be partitioned before we can make the move. I find it easiest to use approximately the same layout but with larger partitions, similar to the following:
--OLD DISK--
* First Sector Last
* Partition Tag Flags Sector Count Sector Mount Directory
0 2 00 0 6291936 6291935 /
1 7 00 6291936 6291936 12583871 /var
2 5 01 0 39849264 39849263
3 3 01 12583872 6291936 18875807 swap
5 0 00 18875808 16778160 35653967 /opt
7 8 00 35653968 4195296 39849263 /import
--NEW DISK--
* First Sector Last
* Partition Tag Flags Sector Count Sector Mount Directory
0 2 00 0 20975280 20975279 /
1 7 00 20975280 10489680 31464959 /var
2 5 01 0 156292560 156292559
3 3 01 31464960 8392560 39857519 swap
5 0 00 39857520 20975280 60832799 /opt
6 0 00 60832800 73403280 134236079 /app
7 8 00 134236080 22056480 156292559 /import
We need to run newfs on each of the new partitions (minus s2 and the swap partition) as well, which looks like this:
/usr/sbin/newfs /dev/rdsk/c0t0d0s0
Moving the Data
I've used two methods for doing this, one simple and the other less so. The simple method is doing a direct disk-to-disk copy. The less-simple method is useful when, for whatever reason, you cannot have both disks plugged in at the same time and involves storing dumpfiles of the original disk's data somewhere on the network in between steps.
Disk-to-Disk Copying
You must boot off of something other than one of these two disks and into single user mode for this to work. A network boot or a bootable CD works fine. The steps themselves are quite easy, and will look something like this:
### Assume that c0t0d0* is the old disk, and c0t2d0* is the new disk. ### mount /dev/dsk/c0t2d0s0 /mnt cd /mnt ufsdump f - /dev/dsk/c0t0d0s0 | ufsrestore xf - ### You may be prompted to select a volume, enter '1'. Answer 'y' to any other prompts. ### cd / umount /mnt ### Repeat as appropriate for all partitions. ###
Disk-to-Network-to-Disk Copying
This is approximately the same as the other way, but with some network storage in the middle. If you happen to have one partition with a lot of free space, you could mount that partition and pipe the ufsdump-s of the other partitions into files on the lots-of-freespace partition, and THEN ftp them over to a remote host (ftp is available in a network / bootable CD booted environment).
Otherwise, use your choice of rcp, nc, or whatever to pipe the dumps directly into files on remote systems. I used 'nc' last time I had to do this (after ftp-ing it from another server into /tmp, since it's not available in the network-booted environment), approximately like the following:
### On the machine that will be storing the dumps: ### nc -l -p 6543 > c0t0d0s0.ufsdump ### On the machine being upgraded: ### ufsdump f - /dev/dsk/c0t0d0s0 | /tmp/nc IP#.IP#.IP#.IP# 6543 ### When the dump is done, it will output "DUMP FINISHED" or similar. You can ctrl-c to kill off 'nc'... the receiving side will detect the broken connection and exit ### ### as well. You'll need to restart it (and redirect to a new filename of course) before beginning the next dump. ###
Once you have all of the dumps stored on the network somewhere, you can bring them back over onto the new disk and extract them. The network / bootable CD booted environment has the 'ftp' program in it, so that's probably the easiest way to get them back. 'ufsrestore' will extract the dump into the directory you are currently in--- you cannot target it at a disk partition. In other words you must mount the partition, cd into it, and then perform the ufs restore. It ought to look something like this:
mount /dev/dsk/c0t0d0s0 /mnt cd /mnt ufsrestore xf /tmp/c0t0d0s0.ufsdump ### Some prompts here ... ### mount /dev/dsk/c0t0d0s1 /mnt/var cd /mnt/var ufsrestore xf /tmp/c0t0d0s1.ufsdump ### And so on ... ###
Initializing the Boot Sector
The last step is initializing the boot sector of the new disk so that it will be bootable. I 'love' that there is a tool for this in Solaris that is standalone! At any rate, the tool in question is 'installboot' and it has its own manpage. The following commands ought to work though:
mount /dev/dsk/c0t0d0s0 /mnt /mnt/usr/sbin/installboot /mnt/usr/platform/`uname -i`/lib/fs/ufs/bootblk /dev/rdsk/c0t0d0s0
