August 18, 2012

Restoring Solaris steps using boot prompt commands

From the boot prompt (the 'OK' prompt) type:
OK boot cdrom -s
When the system has booted up, you should be at a shell prompt. You'll need to partition the disk using format.
# format c0t0d0

You will see the format menu. It is usually not necessary to actually format the disk, since almost all SCSI disks are preformatted at the factory. We simply need to repartition the disk. Select the partition option:
format> partition

You will see the partitioning menu. Enter the following commands, using the printout of your previous partition layout in that machine's logbook as a guide. (See comments about partition sizes later in this article if you don't have such a record.)

partition> 0
Enter partition id tag[root]:
Enter partition permission flags[wm]:
Enter new starting cyl[0]:
Enter partition size[??b, ??c, ??mb, ??gb]:
Repeat this process for all the other slices on the disk. Be sure to zero out any unused slices on the disk to avoid problems later. When you have finished partitioning the disk, you must label it.
partition> label
Ready to label disk, continue? Yes
You may now quit format.
partition> quit
format> quit
The next step is to create a new file system on the partitions you have just set up. You do not need to make a file system on the swap partition.
# newfs /dev/rdsk/c0t0d0s0
Note that you use the raw device, /dev/rdsk, for this. Repeat this step for any other slices on the drive, except slice 1. Slice 1 is usually used as swap space and does not need to be restored, nor does it require a file system. Next, we mount the root partition so that we can begin to restore to it.
# mount /dev/dsk/c0t0d0s0 /a
Change directories to /a:
# cd /a
Begin the restore process.
# ufsrestore xvf /dev/rmt/0n
You will see lots of messages from ufsrestore, followed by a list of files that are being extracted from the tape and put on the disk. When ufsrestore has read all the files from tape, it will ask you if you want to set the owner and mode on the files. You should answer "yes" to all these questions. ufsrestore has a number of options. The ones used here have the following meaning:
x = extract all files from the ufsdump
v = verbose mode; list the files as the come from the tape
f = file or device to use as input /dev/rmt/0n = do not rewind the tape.
This assumes that you have several filesystems dumped onto a single tape.
Once you have restored the root file system, continue restoring any other filesystems on the replaced disk. For example, suppose that you had made /var a separate file system on c0t0d0s3, and /var is the next ufsdump file on the tape. Then you would do the following:
# mount /dev/dsk/c0t0d0s3 /a/var
# cd /a/var
# ufsrestore xvf /dev/rmt/0n
Again, you will see a lot of messages from ufsrestore followed by a list of files that are being extracted. Answer "yes" to the questions asked by ufsrestore at the end of the procedure. When you have finished restoring all the disk slices on the replaced disk, unmount the partitions, making sure to start at the leaves of the hierarchy tree.
# umount /a/var
# umount /a
After you have restored all the files to the replaced disk, you must install the bootblock before you can boot the system from the new disk. In order for the system to boot, the boot(1M) program, called ufsboot, must be loaded on the boot disk by the bootblock program. This program must be placed in the boot area of the disk partition that will be booted. This bootblock program is different for each Sun platform. That is, an Ultra 1 will have a different bootblock program than a SPARCstation 20 or an Ultra Enterprise 5000. Copies of the program for the particular system can be found in /usr/ \
platform//lib/fs/ufs, where can be found using the uname -i command.
To install the bootblock, perform the following commands:
# cd /usr/platform/'uname -i'/lib/fs/ufs
# /usr/sbin/installboot bootblk /dev/rdsk/c0t0d0s0
Note that the back tics around the uname -i command are very important. They will cause the output of uname -i to be substituted in the command. If you use the wrong tics, this command will fail. Once you have completed these steps, you may halt the system and reboot from the new disk. The system should boot up completely and be in the same state as when it was dumped.
Restoring SunOS
The steps for restoring a SunOS system disk are the same as those for restoring a Solaris system disk:
1. Replace the drive
2. Partition the drive
3. Create new file system
4. Restore the data
5. Install the boot block
The specific commands used are, however, a little different. Booting the SunOS (aka Solaris 1.1.1) disk is a two-step process. First, you boot from CD-ROM:
OK boot cdrom
You will be asked to select the boot disk; choose your system disk, sd0. Next, you will be asked if you want to format the system disk. Answer "Yes" and partition the disk according to the partition information you have for the system disk. You do not need to format the disk, only partition it.
Next, you will be asked if you want to install the OS on the swap partition of the newly partitioned disk; answer "Yes". Finally, you will be asked if you want to reboot using the just-installed copy of SunOS; answer "Yes" again, and the system will boot up to a shell prompt. When you see the shell prompt, you will need to create a file system on the drive in question. You do this in nearly the same way you would in Solaris:
# newfs /dev/rsd0a
Next, mount the new file system on /a of the file system:
# mount /dev/sd0a /a
Now, we will restore the tape.
# cd /a
# restore -xvf /dev/rst0n


You will see a message "Creating nodes" and a list of directories on the tape as these directories are created on the disk. Then, you will see a list of the files as they are extracted. Finally, you will see the question "Set owner and mode?" Answer yes to this question. Repeat this process for any other partitions that were on the failed disk. For instance, if /usr was on sd0g, then you would:
# newfs /dev/rsd0g
# mount /dev/sd0g /a/usr
# cd /a/usr
# restore -xvf /dev/rst0n


The boot(8S) program is loaded from disk by bootblock code from the bootblock region of the disk partition. It is necessary for the bootblock program to know the block numbers on the disk that are occupied by the boot program. The installboot program copies the block numbers of the boot program into a table in the bootblock code, then writes the modified bootblock code onto the disk. Since the blocks where the boot program resides will probably change when you restore from tape, you must run installboot to put the correct blocks into the bootblock program.


Use these commands:
# cd /usr/kvm/mdec
# installboot -v /a/boot bootsd /dev/rsd0a
# umount /a/usr
# umount /a
Now, you can reboot your system with the new drive, and the system should be in the same state as when you dumped it.

No comments:

Post a Comment