UsMan's WoRkSpAce

Tuesday, December 26, 2006

Proactively replacing boot disk under Solaris Volume Manager (SVM)

Below is the procedure to pro-actively replace alternate mirrored boot disk that has reported errors without SVM detecting it. Disk has not been put in maintenance state by SVM. However 'iostat -En' is reporting a few hard errors.

Assumption: There are five meta slices on the disk, d0, d1, d3, d4 and d6.

1) Detach sub-mirrors from the disk by using metadetach command such as 'metadetach d0 d20'.
2) Delete state database replicas on the disk by using 'metadb -d c1t1d0s7' where c1t1d0s7 is the slice containing meta database. It can be determined by running metadb command without an option.
3) Replace the disk
4) New disk should be partitioned into exactly the same slices as the primary disk by using format command. Select the primary disk and enter 'p' for partition table. Choose 'n' to save partition table and give it a name. Then choose the new alternate disk and press 's' to select the previously saved partition table. New disk will be partitioned. Label the disk by using 'l' in the partition menu.
5) Create state database replicas on the new disk by using 'metadb -afc3 c1t1d0s7'
6) Attach sub-mirrors to the new disk by running 'metattach d0 d20' command and following it up for other sub-mirrors
7) SVM will start syncing of sub-mirrors to the new disk. Verify syncing progress from 'metastat' command. Syncing may take around 15-20 minutes per 1 GB of file system.

Thursday, December 14, 2006

Screen: keep processes running despite losing a network connection

Screen is a full-screen window manager with VT100/ANSI terminal emulation. It multiplexes a physical terminal between several processes (e.g shells). It keep the processes/shells running despite a drop in network connection. After connection to a remote server using telnet or ssh, execute screen command. Following command options can then be used to manipulate screen sessions.

Ctrl + a + c: creates a new screen session
Ctrl + a + n: switch to next screen session
Ctrl + a + p: switch to previous screen session
Ctrl + a + d: detach from a screen session without killing running shells or processes

Typing exit within a screen shell closes a screen session. If a connection drops, active screen session will continue running on the remote server. Log back to the remote server, execute 'screen -ls' to view currently running sessions and connect to one of them, using 'screen -r [session id]'.

Screen is available on Linux, BSD unix and Mac OS X.

The other method to continue running remote processes is to use 'nohup [command name] &'. However it runs the command in the background and not interactively.