This chapter contains the following information:
Working with the UNIX shell in the Full Installation environment
How to invoke the UNIX shell from the Full Installation
Samples of the types of tasks that can be performed from the UNIX shell environment
How to use the UNIX shell to:
Restore UNIX file systems (UFS) or Advanced File Systems (AdvFS) from tape backups
Restore the system image from a damaged disk to a new disk and assign the old device name to the new device
Change the size of a disk partition
using the
disklabel
command
Returning to the Full Installation procedure from the UNIX shell environment
The
UNIX shell option is a way to access standard UNIX commands during a Full
Installation.
The primary purpose of the UNIX shell option is to provide a
way to perform disk and file system maintenance before or during a Full Installation.
The UNIX shell provides a way to access all UNIX commands that help you recover
from serious problems such as
/
(root) file system corruption
and enables you to perform general file system and disk maintenance tasks.
It is usually not necessary to access the UNIX shell during an installation,
but the option to do so is offered just in case you need it.
The base operating system distribution media (CD-ROM or RIS) contains
file systems that are laid out just as the software would be installed on
the system and provides direct access to the
/
,
/usr
, and
/var
directories.
The distribution
media contains a mixture of compressed and uncompressed software subsets.
This format makes all commands and utilities in the uncompressed software
subsets available in the UNIX shell even if your operating system is not yet
fully functional.
In effect, the mounted installation media is almost a full
operating system environment.
The UNIX shell option enables you to use the
installation media as a tool for disaster recovery.
You should perform system management activities in the UNIX shell only
if you have previous UNIX operating system experience.
3.2 Invoking the UNIX Shell
How you invoke the UNIX shell from the installation procedure depends upon whether you are using the graphical or text-based interface. When you invoke the UNIX shell option, the system is in a Bourne shell in single-user mode with superuser privileges. Refer to the Command and Shell User's Guide for more information about shells and privileges.
After you boot your system from the distribution media to start a Full
Installation, you will see an
Installation
window on systems
capable of graphical display.
To invoke the UNIX shell, select the
Shell Window
menu item from the
File
menu at
the top of the dialog box.
On systems that do not have graphics capabilities, there are two ways to invoke the UNIX shell from the text-based Full Installation interface. The first is to choose menu option 3 from the first screen of the text-based interface. The second method is to press [Ctrl/c] (at any time except during software subset loading).
Note
Any installation selections you have made before invoking the UNIX shell from the text-based interface are lost. Follow this procedure to restart the text-based installation and start the selection process again:
#
cd /
#
restart
Using the UNIX shell in the installation
environment provides most of the capabilities of a full operating system environment.
The difference between using the UNIX shell in the installation environment
and a normal operating system environment is that it works without a swap
device and with very limited capacity within the memory file systems (MFS)
that are available during a Full Installation.
These two factors mean that
tasks requiring large amounts of memory that create the need to swap, or tasks
requiring large amounts of disk space (such as
/tmp
space),
are likely to encounter failures in the installation environment.
Note
The
/
(root) file system is located on the CD-ROM or the RIS server, and after the installation distribution media is booted, it is mounted with read-only permissions. The memory file systems (MFS) at/var
,/dev
, and/devices
are mounted with read-write permissions. Any changes you make to files in/var
,/dev
, and/devices
are volatile and will not be saved when you halt the installation and return to the console prompt (>>>
).
Here is a sample of the types of tasks you can perform from the UNIX shell; some of these tasks are documented in this chapter:
Create new file systems with the
newfs
command for UNIX File Systems (UFS) or with the
mkfdmn
and
mkfset
commands for Advanced File Systems (AdvFS).
Restore file systems
with the
restore
command (for UFS) or the
vrestore
command (for AdvFS).
Modify disk partition tables
with the
disklabel
command on systems that do not
have graphics capabilities.
Otherwise, use the graphical Disk Configuration
Utility, which is accessed either by clicking on the
Edit Partitions...
button on the
File System Layout
window, or
by invoking the
/usr/sbin/diskconfig
utility at the shell
prompt.
Mount disks and
file systems
with the
mount
command.
Fix UFS file systems with the
fsck
command.
The
fsck
command is not required for AdvFS file systems.
View a file with the
ed
text editor.
By
default, the
EDITOR
environment variable is set to
ed
.
To enable the
vi
text editor:
On older systems with console firmware that supports curses capability:
#
TERM=vt100
[Footnote 4]#
export TERM
On newer systems with personal computer-like graphics:
#
TERM=pccons
#
export TERM
If you need to perform a task that requires swap space, you can turn swapping on in the UNIX shell. The only suggestion for turning on swap space in the UNIX shell environment is that you should not use a partition that contains data you want to preserve because it will be overwritten. To avoid this problem, use a disk partition that previously has been used for swap space.
Follow this procedure to turn on swapping in the UNIX shell:
Decide which device (that is, the device name and partition) you want to use for the swap area. Be careful not to choose an area that has data that you want to preserve.
Note
A disk partition that previously was used for swap space will be labeled as
swap
in the disklabel and can be used without harm.
Change to the
/dev/disk
directory:
#
cd /dev/disk
Turn the swap device on.
In this example, the swap device
is
dsk0b
:
#
swapon dsk0b
Verify that the swap device is turned on:
#
swapon -s
Note
The
restart
command, which is used to restart the installation from the UNIX shell, is no longer available after swap space has been enabled. To restart the installation, halt the system and reboot from the distribution media.
The UNIX shell can be used to perform
maintenance operations on existing file systems.
For instance, if the kernel
(the file called
vmunix
) in your
/
(root) file system becomes damaged and you have a good backup
copy of the kernel, you can mount your
/
file system and
replace the damaged kernel.
If you are using LSM volumes for the
/
file system, refer to
Installation Guide
for information about
how to restart LSM.
Follow this procedure to mount an existing root file system located
on
/dev/disk/dsk0a
to another mount point
Create a mount point in
/var
:
#
mkdir /var/mnt
Mount the file system:
For UNIX file systems (UFS), enter:
#
fsck -y /dev/disk/dsk0a
#
mount /dev/disk/dsk0a /var/mnt
For Advanced File Systems (AdvFS), enter:
#
mkdir -p /etc/fdmns/root_domain
#
cd /etc/fdmns/root_domain
#
ln -s /dev/disk/dsk0a dsk0a
#
mount root_domain#root /var/mnt
The existing
/
file system is accessible
at
/var/mnt
and can be modified at this point.
3.6 Restoring File Systems from Backup
The UNIX shell is ideal for restoring
damaged
/
(root) file systems, but you can use the UNIX
shell to restore file systems other than the
/
file system.
It is recommended to restore file systems from a full operating system
environment.
If such an environment is unavailable due to the need to restore
either
/var
or
/usr
, boot your system
to single-user mode by using your existing or restored
/
file system to provide more writable disk space than is available in the installation
environment.
Swap space can be made available in the UNIX shell as shown in
the instructions in
Section 3.4.
Section 3.6.1
describes how to restore UFS
file systems, and
Section 3.6.2
describes
how to restore AdvFS file systems.
Both sets of procedures assume that you
are restoring the file system to the same disk.
3.6.1 Restoring UNIX File Systems (UFS) from Tape Backup
Use the following procedure to restore a UNIX file system to the same disk on which it originally resided. The size of the partition you are restoring must be larger than the size of the dump file.
Note
The
disklabel
command used in the following procedure writes the default disk partition tables to the disk. Writing a label with customized partition table settings may affect the entire disk. If the disk you are restoring has customized partition table settings, use the instructions shown in Section 3.8 to recreate them. Refer to System Administration or to thedisklabel
(8) reference page for more information.
Read the disk label on the affected disk:
disklabel
-r disk
If the disk has a disk label, proceed to Step 3 to erase it. If the disk does not have a disk label, proceed to Step 4 to create one.
Zero out the disk label:
#
disklabel -z dsk0
Create a new disk partition
table with an
a
partition of at least 128 MB to hold the
root file system.
Follow the procedures in
Section 3.8,
and then continue with Step
5.
Create a new
/
file system by using the following command syntax:
newfs
raw_device disk_type
The
raw_device
parameter specifies
the full raw device pathname of the disk device on your system.
The
/
file system must reside on the
a
partition.
So, to create a new file system on an RZ26L disk on partition
a
,
enter the following command:
#
newfs /dev/rdisk/dsk0a rz26l
To prepare to mount the file system, create a mount point
in
/var
:
#
mkdir /var/mnt
Create mount points under the
/var
or
/tmp
directories because these are the
only directories that are writable from the UNIX shell.
Mount the file system by using the following command syntax:
mount
block_device
/var/mnt
The block_device parameter specifies the full block device pathname of the disk device. For example, to mount the file system created in the previous step, enter the following command:
#
mount /dev/disk/dsk0a /var/mnt
Verify that the tape device is powered up and is connected to the system.
Note
If the tape device was not powered up when the system initialized, it may not be visible to the system. In that case, shut down the system, power up the tape device, and reboot the system.
Determine whether or not a tape device special file exists. Use the following command to obtain information about all devices on the system:
#
hwmgr -view device
If the output from this command does not indicate the
presence of a device similar to
/dev/tape/tape0_d0
, create
the tape device special file as described in Step10.
Otherwise, skip to Step
11.
Create a device special file for the tape device:
#
/sbin/dn_setup -install_tape
Messages such as
+tape0
list the device names that are created during this operation.
The plus sign indicates that the device is being added.
When all tape device
special files are created, proceed to Step
11
to continue with the recovery of the damaged
/
file system.
Restore the file system.
If you are restoring dump files from a local file system, change to the
/var/mnt
directory, insert the medium containing the dump file,
and enter the
restore
command with the following command
syntax:
restore
-Yrf dumpfile
The dumpfile parameter specifies the pathname of the file containing the dump data. For a tape, enter the following commands:
#
cd /var/mnt
#
restore -Yrf /dev/tape/tape_device
3.6.2 Restoring Advanced File Systems (AdvFS) from Tape Backup
Use the following procedure to restore an AdvFS file system to the same disk on which it originally resided.
Note
The
disklabel
command used in this procedure writes the default disk partition tables to the disk. Writing a label with customized partition table settings may affect the entire disk. If the disk you are restoring has customized partition table settings, use the instructions shown in Section 3.8 to recreate them. Refer to System Administration or to thedisklabel
(8) reference page for more information.
If the disk does not have a label, which could occur if the
disk was physically damaged or replaced, write the default disk partition
tables and bootstrap programs.
The disk partitions and bootstrap programs
should be operational.
To determine if the disk has a valid label, use the
disklabel
command with the following syntax:
disklabel
-r disk
If the disk has a disk label, proceed to Step 3 to erase it. If the disk does not have a disk label, proceed to Step 4 to create one.
If the disk has a disk label, zero out the disk label:
#
disklabel -z dsk0
Proceed to Step 4.
Create a new disk
partition table with an
a
partition of at least 128 MB
to hold the root file system.
Follow the procedures in
Section 3.8,
and then continue with Step
5.
Create a new
/
(root) file domain by using the following command syntax:
mkfdmn
-r raw_disk domain
The
raw_device
parameter specifies
the full raw device pathname of the disk device on your system.
For example,
to create a new file system on an RZ26L partition
a
, enter
the following command:
#
mkfdmn -r /dev/rdisk/dsk0a root_domain
Create a
root
fileset in the
root_domain
file by using the following command:
#
mkfset
domain fileset
The domain parameter specifies the name of the domain in which to create the fileset. For example:
#
mkfset root_domain root
To prepare to mount the fileset, create a mount point in
/var
or
/tmp
:
#
mkdir /var/mnt
It is recommended
that you create mount points under the
/var
or
/tmp
directories because these are the only directories that are
writable from the UNIX shell.
Mount the
root
fileset by using the following
command syntax:
mount
domain#fileset mount_point
The
domain#fileset
parameter specifies
the
root
file domain and the
root
fileset.
For example, to mount the fileset created in the previous steps, enter the
following command:
#
mount root_domain#root /var/mnt
Verify that the tape device is powered up and is connected to the system.
Note
If the tape device was not powered up when the system initialized, it may not be visible to the system. In that case, shut down the system, power up the tape device, and reboot the system.
Determine whether or not a tape device special file exists. Use the following command to obtain information about all devices on the system:
#
hwmgr -view device
If the output from this command does not indicate the
presence of a device similar to
/dev/tape/tape0_d0
, create
the tape device special file as described in Step
11.
Otherwise, skip to Step
12.
Create a device special file for the tape device:
#
/sbin/dn_setup -install_tape
Messages such as
+tape0
list the device names that are created during this operation.
The plus sign indicates that the device is being added.
When all tape device
special files are created, proceed to Step
12
to continue with the recovery of the damaged
/
file system.
Restore the fileset
using the
vrestore
command.
To restore files from a local
file system, change to the
/var/mnt
directory, insert the
medium containing the dump file, and enter the
vrestore
command using the following syntax:
vrestore
-vxf dumpfile
The dumpfile parameter specifies the pathname of the file containing the dump data. Enter the following commands for a tape:
#
cd /var/mnt
#
vrestore -vxf /dev/tape/tape_device
Note
You can restore a UFS format dump tape to AdvFS (for instance if you are converting a UFS
/
file system to AdvFS) and you can make avdump
tape on UFS. The restore command you use depends on the format of the tape(dump
orvdump)
. Usevrestore
to restore AdvFS dumps performed with thevdump
command andrestore
to restore UFS dumps performed with thedump
command. The corresponding restore command is used regardless of the target file system type.
Verify the
/etc/fstab
and
/etc/fdmns
directories.
The
mkfdmn
command added
/etc/fdmns/root_domain
to the temporary
/
file
system in the UNIX shell, which is deleted when you reboot the system.
You can
use the UNIX shell to restore other file systems, but it is recommended that
you perform file system restores from a full operating system environment.
If such an environment is unavailable due to the need to restore either
/var
or
/usr
, you should boot your system to
single-user mode by using your existing or restored
/
file
system.
In the single-user mode, more disk space is available, and swap space
can be made available by issuing the following command:
#
swapon -a
3.7 Restoring the Root File System Image from a Damaged Disk to a New Disk
This procedure describes how to restore a saved root file system image from a bad or damaged disk to a new disk and rename the new disk with the old system disk name.
The process of introducing a new system disk is more complicated than
just updating the
/etc/fstab
file because the installation
kernel may assign a different device name to the devices on the system than
the ones that were assigned on the saved system image.
As a result, the restored
system image will disagree with the kernel used to restore the image, and
you cannot assume that it is possible to determine what the mapping is between
them.
Note
The following procedure assumes you have restored the system image to a new disk as described in Section 3.6 .
Halt the system:
#
shutdown -h now
Determine the console disk names on the system:
>>>
show dev
Boot the system to single user mode from the new disk with the restored image:
>>>
boot -fl s
console_disk_name
In single user mode, mount
the
/
file system as writable:
#
/sbin/mountroot
This process creates a device entry for the newly found disk. You will see several processing messages ending with output that is similar to the following:
+dskNa +dskNb +dskNc ...
In the previous example, N is the disk number assigned to the disk that is being seen for the first time and should be the disk that was restored. However, if more than one disk is shown in the output, you have added multiple disks since the system disk was last saved. Proceed to Step 5 to determine the disk name associated with the old damaged disk.
Determine the old boot disk name:
#
/sbin/consvar -g booted_dev
Output from this command is similar to the following.
booted_dev = dskN
In the previous command output,
booted_dev = dskN
is the
old_disk_name.
Exchange the old disk name with the new disk name:
#
dsfmgr -e
new_disk_name old_disk_name
In the command line, substitute new_disk_name with the disk name obtained in Step 4, and substitute old_disk_name with the disk name returned in Step 5.
Note
You will receive an error if the old, damaged disk has been removed and is not active. In that situation, use the move flag (
-m
) instead:#
dsfmgr -m
new_disk_name old_disk_name
Reset the boot device:
#
/sbin/consvar -s bootdef_dev=
new_disk_name
Optionally perform additional maintenance tasks, or if you are finished, boot the system to multiuser mode:
#
init 3
3.8 Changing the Size of a Disk Partition Using the disklabel Command
If you are using the text-based installation
interface, use the
disklabel
command to change the drive
identification or the disk partitions on the drive or to replace a damaged
label or bootstrap.
Refer to the
disklabel
(8)
reference page for more information.
To look at the existing disk partition layout, enter the
disklabel
command in the following format and replace the variable
n
with the unit number of the disk.
For example, to look at
the existing disk partition layout of disk, enter the following command:
#
disklabel -r /dev/disk/dsk
n
The following example uses an
rz26l
disk.
In this
example, the size of the
b
partition is decreased, and
the size of the
a
partition is increased to 128 MB which
is the minimum size to hold the
/
root file system.
Follow
this procedure to change the size of disk partitions:
Read the disk label on
dsk0
:
#
disklabel -r dsk0
Set the EDITOR environment variable to use the
ed
editor:
#
EDITOR=ed
#
export EDITOR
Note
If you have a VGA monitor and want to use the
vi
editor, you first have to set the following variables:#
TERM=vt100
#
export TERM
#
EDITOR=vi
#
export EDITOR
Then, use the corresponding
vi
commands instead of the commands shown in this procedure to make the disk label changes. The rest of this procedure uses theed
text editor.
Copy the disk label for
dsk0
to a temporary
file:
#
disklabel -r dsk0 > /tmp/old_disklabel
Edit the copy of the disk label to protect against introducing errors on the real disk label:
#
ed /tmp/old_disklabel
Display the disk label:
1,$p
Search for the
b
partition:
/b:
Information similar to the following is displayed:
b: 262144 131072 unused 1024 8192 # (Cyl. 164*- 492*)
Change the size of the
b
partition from
262144 sectors to 131072 sectors :
s/262144/131072/p
This reduces the size of the
b
partition from 128 MB to 64 MB.
The revised information is displayed:
b: 131072 131072 unused 1024 8192 # (Cyl. 164*- 402)
There is no need to modify cylinder information; cylinder information automatically is modified when you save and exit the file.
Change the offset of the
b
partition from
131072 sectors to 262144 sectors :
s/131073/262144/2p
This changes the offset of the
b
partition to start at position 262144.
The revised information
is:
b: 131072 262144 unused 1024 8192 # (Cyl. 164*- 402)
There is no need to modify cylinder information; cylinder information automatically is modified when you save and exit the file.
Search for the
a
partition:
/a:
Information similar to the following is displayed:
a: 131072 0 unused 0 0 # (Cyl. 0 -164*)
Because the size of the
b
partition was
reduced by 131072 sectors, the size of the
a
partition
should be increased by 131072 sectors.
Change the size of the
a
partition from 131072 sectors to 262144 sectors:
s/131072/262144/p
This increases the size of the
a
partition from 64 MB to 128 MB.
Display the disk label again to verify your changes:
1,$p
Save your edits and quit the editor:
wq
Apply the new disk label to the disk:
#
disklabel -R dsk0 /tmp/old_label
Display the newly customized disk label:
#
disklabel -r dsk0
Exit the shell or restart the Full Installation.
3.9 Returning to the Installation Procedure from the UNIX Shell
The
procedure for returning to Full Installation from the UNIX shell depends upon
whether you are using the text-based or graphical interface.
3.9.1 Text-Based Interface
If you entered the UNIX shell from the text-based interface, enter the following commands to invoke the Full Installation from the UNIX shell:
#
cd /
#
restart
If you have a system console with graphics capability and you want to restart the installation procedure with the text-based interface instead of the graphical user interface, enter the following command:
#
cd /
#
restart nogui
Any installation selections you made up to the point you exited to the
UNIX shell are lost.
When you restart the Full Installation, you have to make
your selections again.
3.9.2 Graphical Interface
If you entered the UNIX shell from the
File
menu
in the graphical interface, you can resume the Full Installation at any time
just by clicking back in the Full Installation window.
You do not have to
exit the shell window; however, if you want to exit the shell window, enter
exit
at the
#
prompt within the shell window.
If you entered the UNIX shell from the
Quit
button
on the Summary window, use the procedure shown in
Section 3.9.1
to restart the Full Installation.