* You are viewing the archive for the ‘solaris utilities’ Category

Mirroring root disk using SVM

There are about 487359 documents on the Internet about how to mirror root disk in Solaris. So, here is 487360th.

The assumptions are following: the first disk has Solaris already installed, root slice is slice 1, and the disks are identical with the same size and geometry. If they have different cylinder, head, sector count or different size you will have to fiddle with sizing slices more.

The first step is to recreate the same slice arrangement on the second disk:

bash-3.00# prtvtoc /dev/rdsk/c1t0d0s2 | fmthard -s - /dev/rdsk/c1t1d0s2
fmthard: New volume table of contents now in place.

You can check both disks have the same VTOC using prtvtoc command

bash-3.00# prtvtoc /dev/rdsk/c1t0d0s2
* /dev/rdsk/c1t0d0s2 partition map
*
* Dimensions:
* 512 bytes/sector
* 424 sectors/track
* 24 tracks/cylinder
* 10176 sectors/cylinder
* 14089 cylinders
* 14087 accessible cylinders
*
* Flags:
* 1: unmountable
* 10: read-only
*
* First Sector Last
* Partition Tag Flags Sector Count Sector Mount Directory
0 3 01 0 4100928 4100927
1 2 00 4100928 20484288 24585215
2 5 00 0 143349312 143349311
3 8 00 24585216 118672512 143257727
7 0 00 143257728 91584 143349311

Now we have to create state database replicas on slice 7. We will be adding two replicas to each slice:

bash-3.00# metadb -a -f -c3 /dev/dsk/c1t0d0s7
bash-3.00# metadb -a -f -c3 /dev/dsk/c1t1d0s7

Database replicas are crucial part of SVM. Here is some important information about how they work, how many you need, etc.

Since the database replicas are in place we can start creating metadevices. The following commands will create metadevice d31 from slice c1t0d0s3, and metadevice d32 from slice c1t1d0s3. Then we create mirror d30 with d31 attached as a submirror. Finally we will attach submirror d32 to mirror d30. Once d32 is attached, the mirror d30 will automatically start syncing.

bash-3.00# metainit -f d31 1 1 c1t0d0s3
d31: Concat/Stripe is setup
bash-3.00# metainit -f d32 1 1 c1t1d0s3
d32: Concat/Stripe is setup
bash-3.00# metainit d30 -m d31
d30: Mirror is setup
bash-3.00# metattach d30 d32
d30: submirror d32 is attached

The procedure is the same for all other mirrors you might want to create. Root filesystem is slightly different. First you will have to create your submirrors. Then you will have to attach submirror with existing root filesystem, in this case d11, to the new mirror metadevice d10. Then you will have to run metaroot command. It will alter / entry in /etc/vfstab. Finally, you flush the filesystem using lockfs command and reboot.

bash-3.00# metainit -f d11 1 1 c1t0d0s1
d31: Concat/Stripe is setup
bash-3.00# metainit -f d12 1 1 c1t1d0s1
d32: Concat/Stripe is setup
bash-3.00# metainit d10 -m d11
d30: Mirror is setup
bash-3.00# metaroot d10
bash-3.00# lockfs -fa
bash-3.00# reboot

When the system reboots, you can attach the second submirror to d10 as follows:

bash-3.00# metattach d10 d12

You can check the sync progress using metastat command. Once all mirrors are synced up the next step is to configure the new swap metadevice, in my case d0, to be crash dump device. This is done using dumpadm command:

bash-3.00# dumpadm
Dump content: kernel pages
Dump device: /dev/dsk/c1t0d0s0 (dedicated)
Savecore directory: /var/crash/ultra
Savecore enabled: yes
bash-3.00# dumpadm -d /dev/md/dsk/d0

The final step is to modify PROM. First we need to find out which two physical devices c1t0d0 and c1t1d0 refer to:

bash-3.00# ls -l /dev/dsk/c1t0d0s1
lrwxrwxrwx 1 root root 43 Mar 4 14:38 /dev/dsk/c1t0d0s1 -> ../../devices/pci@1c,600000/scsi@2/sd@0,0:b
bash-3.00# ls -l /dev/dsk/c1t1d0s1
lrwxrwxrwx 1 root root 43 Mar 4 14:38 /dev/dsk/c1t1d0s1 -> ../../devices/pci@1c,600000/scsi@2/sd@1,0:b

The physical device path is everything starting from /pci…. Please make a note of sd towards the end of the device string. When creating device aliases below, sd will have to be changed to disk.

Now we create two device aliases called root and backup_root. Then we set boot-device to be root and backup_root. The :b refers to slice 1(root) on that particular disk.

bash-3.00# eeprom "use-nvramrc?=true"
bash-3.00# eeprom "nvramrc=devalias root /pci@1c,600000/scsi@2/disk@0,0 devalias backup_root /pci@1c,600000/scsi@2/disk@1,0"
bash-3.00# eeprom "boot-device=root:b backup_root:b net"

Now we can test that the system boot from both root and backup_root devices.

There is one more optional step. Adding two kernel tunables to /etc/system file. The first one is md_mirror:md_resync_bufsz which will speed up mirror resync. The second one is md:mirrored_root_flag. When this flag is enabled the system will boot even if less than majority of database replicas is available. Personally, I do not use the second tunable. More on these can be found in Solaris Tunable Parameters Reference Guide. Continue Reading

Moving boot disk to a different target or controller

I had a need for a system that can boot two different versions of Solaris from two different disks. Both disks were on target 0 when Solaris was installed on them. But when I moved one of the disks to be target 1, obviously there was going to be a problem with booting from that disk.

There is a simple way to get the disk booting from the new target. Here are the steps to take:

  1. Boot the system off a DVD or CD or jumpstart server in single user mode
  2. Mount the root filesystem on the disk in question and edit vfstab to reflect the new controller/target setup

The last step is to regenerate /etc/path_to_inst and device links in /dev. Searching the internet for some unrelated info I found out devfsadm has an undocumented -p switch that recreates path_to_inst file. The -r switch specifies location of root filesystem.

bash-3.00# devfsadm -r /mnt -p /mnt/etc/path_to_inst

Now you can reboot and the drive should be bootable again. Continue Reading

Sun Cluster's scconf

Using scconf you can view some useful information about Sun Cluster configuration such as information about cluster transport, disksets, etc.
Using multiple v’s you can increase output verbosity. It’s pretty useful especially if you inherited the cluster.
I added this command to my previous list, as well.

root@node1 # scconf -p -v
Cluster name: cluster
Cluster ID: 0x4538908A
Cluster install mode: disabled
Cluster private net: 172.16.0.0
Cluster private netmask: 255.255.0.0
Cluster new node authentication: unix
Cluster new node list: <. - Exclude all nodes>
Cluster transport heart beat timeout: 10000
Cluster transport heart beat quantum: 1000
Cluster nodes: node1 node2

Cluster node name: node1
(node1) Node ID: 1
(node1) Node enabled: yes
(node1) Node private hostname: clusternode1-priv
(node1) Node quorum vote count: 1
(node1) Node reservation key: 0x4538908A00000001
(node1) Node transport adapters: ce2 ce0

(node1) Node transport adapter: ce2
(node1:ce2) Adapter enabled: yes
(node1:ce2) Adapter transport type: dlpi
(node1:ce2) Adapter property: device_name=ce
(node1:ce2) Adapter property: device_instance=2
(node1:ce2) Adapter property: lazy_free=1
(node1:ce2) Adapter property: dlpi_heartbeat_timeout=10000
(node1:ce2) Adapter property: dlpi_heartbeat_quantum=1000
(node1:ce2) Adapter property: nw_bandwidth=80
(node1:ce2) Adapter property: bandwidth=70
(node1:ce2) Adapter property: netmask=255.255.255.128
(node1:ce2) Adapter property: ip_address=172.16.0.129
(node1:ce2) Adapter port names: 0

(node1:ce2) Adapter port: 0
(node1:ce2@0) Port enabled: yes

(node1) Node transport adapter: ce0
(node1:ce0) Adapter enabled: yes
(node1:ce0) Adapter transport type: dlpi
(node1:ce0) Adapter property: device_name=ce
(node1:ce0) Adapter property: device_instance=0
(node1:ce0) Adapter property: lazy_free=1
(node1:ce0) Adapter property: dlpi_heartbeat_timeout=10000
(node1:ce0) Adapter property: dlpi_heartbeat_quantum=1000
(node1:ce0) Adapter property: nw_bandwidth=80
(node1:ce0) Adapter property: bandwidth=70
(node1:ce0) Adapter property: netmask=255.255.255.128
(node1:ce0) Adapter property: ip_address=172.16.1.1
(node1:ce0) Adapter port names: 0

(node1:ce0) Adapter port: 0
(node1:ce0@0) Port enabled: yes

Cluster node name: node2
(node2) Node ID: 2
(node2) Node enabled: yes
(node2) Node private hostname: clusternode2-priv
(node2) Node quorum vote count: 1
(node2) Node reservation key: 0x4538908A00000002
(node2) Node transport adapters: ce2 ce0

(node2) Node transport adapter: ce2
(node2:ce2) Adapter enabled: yes
(node2:ce2) Adapter transport type: dlpi
(node2:ce2) Adapter property: device_name=ce
(node2:ce2) Adapter property: device_instance=2
(node2:ce2) Adapter property: lazy_free=1
(node2:ce2) Adapter property: dlpi_heartbeat_timeout=10000
(node2:ce2) Adapter property: dlpi_heartbeat_quantum=1000
(node2:ce2) Adapter property: nw_bandwidth=80
(node2:ce2) Adapter property: bandwidth=70
(node2:ce2) Adapter property: netmask=255.255.255.128
(node2:ce2) Adapter property: ip_address=172.16.0.130
(node2:ce2) Adapter port names: 0

(node2:ce2) Adapter port: 0
(node2:ce2@0) Port enabled: yes

(node2) Node transport adapter: ce0
(node2:ce0) Adapter enabled: yes
(node2:ce0) Adapter transport type: dlpi
(node2:ce0) Adapter property: device_name=ce
(node2:ce0) Adapter property: device_instance=0
(node2:ce0) Adapter property: lazy_free=1
(node2:ce0) Adapter property: dlpi_heartbeat_timeout=10000
(node2:ce0) Adapter property: dlpi_heartbeat_quantum=1000
(node2:ce0) Adapter property: nw_bandwidth=80
(node2:ce0) Adapter property: bandwidth=70
(node2:ce0) Adapter property: netmask=255.255.255.128
(node2:ce0) Adapter property: ip_address=172.16.1.2
(node2:ce0) Adapter port names: 0

(node2:ce0) Adapter port: 0
(node2:ce0@0) Port enabled: yes

Cluster transport junctions: switch1 switch2

Cluster transport junction: switch1
(switch1) Junction enabled: yes
(switch1) Junction type: switch
(switch1) Junction port names: 1 2

(switch1) Junction port: 1
(switch1@1) Port enabled: yes

(switch1) Junction port: 2
(switch1@2) Port enabled: yes

Cluster transport junction: switch2
(switch2) Junction enabled: yes
(switch2) Junction type: switch
(switch2) Junction port names: 1 2

(switch2) Junction port: 1
(switch2@1) Port enabled: yes

(switch2) Junction port: 2
(switch2@2) Port enabled: yes

Cluster transport cables

Endpoint Endpoint State
-------- -------- -----
Transport cable: node1:ce2@0 switch1@1 Enabled
Transport cable: node1:ce0@0 switch2@1 Enabled
Transport cable: node2:ce2@0 switch1@2 Enabled
Transport cable: node2:ce0@0 switch2@2 Enabled

Quorum devices: d9

Quorum device name: d9
(d9) Quorum device votes: 1
(d9) Quorum device enabled: yes
(d9) Quorum device name: /dev/did/rdsk/d9s2
(d9) Quorum device hosts (enabled): node1 node2
(d9) Quorum device hosts (disabled):
(d9) Quorum device access mode: scsi2

Device group name: dskset1-dg
(appset1-dg) Device group type: SVM
(appset1-dg) Device group failback enabled: no
(appset1-dg) Device group node list: node1, node2
(appset1-dg) Device group ordered node list: yes
(appset1-dg) Device group desired number of secondaries: 1
(appset1-dg) Device group diskset name: dskset1-dg
Continue Reading

Booting alternate device using reboot command

The other day after mirroring root disk I needed to test new devalias I made for backup root disk to see if the system would boot from it. Since my servers are headless and I was not “inclined” to console into it I wondered if it was somehow possible to reboot the system and have it boot from alternate boot device.

Knowing it’s possible to do reboot — -rv and such, I fired up the reboot man page. It turns out one can reboot system using:

root@ultra# reboot -- backup_root

This will cause the system too boot from backup_root device alias. Of course, the device alias had to be valid, which it was. Otherwise, I would end up forcing myself to console to the server.

You can also pass in the boot command some flags. For example to boot system from backup_root with -rv boot flags you would do:

root@ultra# reboot -- backup_root -rv Continue Reading

Using CVS with SMF

Most services in Solaris 10 are controlled by SMF. SMF uses xml files to define services it manages. I had a need to quickly create a service manifest for CVS. The inetconv command takes an input file with inetd.conf format and converts it into basic SMF manifest and imports it into the SMF repository. In the case of CVS I created cvs_inetd file with following content:

cvspserver stream tcp nowait root /export/apps/cvs -f --allow-root=/export/cvs_repos/primary --allow-root=/export/cvs_repos/secondary pserver

Then I converted and imported the file using the following:

root@ultra# inetconv -f -i ./cvs_inetd
cvspserver -> /var/svc/manifest/network/cvspserver-tcp.xml
Importing cvspserver-tcp.xml ...Done
root@ultra#

The resulting CVS manifest was saved in /var/svc/manifest/network. Later, if needed, you can view, modify, etc. the service manifest properties using svccfg and svcprop commands. The -f switch above causes CVS manifest in /var/svc/manifest/network be overwritten, if it exists.

Also, make sure cvspserver is defined in /etc/services. Continue Reading

Page 3 of 512345