ZFSブートをがんばってみる

VirtualBox環境のインストールでは、ZFSルートにできなかったけれど、まだZFSルートでブートな環境は構築できる。
ということで、進めてみる。
使うのは新しくついた機能のところにあるSolaris Live Upgrade ( LU )。
LU自体はSolaris 8位からあって、8への移行のために2.6や7にも提供されていた気がする。

基本的には、

  • 普通にSolaris 10をインストールする
  • ZFSルート用のディスクを用意
  • ZFSルート用のZFSストレージプールを作成する
  • lucreateでZFSルートなBoot Environment ( BE )を作成する *1
  • luactivateで利用するBEを切り替える

という感じ。
※HWの要件にも注意。メモリ768MB以上1GB推奨。HDD16GB以上。らしい。

実際にはマニュアルを見てやっていかないと、悩むことになる。というか、悩んだ。
マニュアルSolaris 10 System Administrator Collection >> Solaris ZFS Administration Guide >> 4. Installing and Booting a ZFS Root File Systemを見てみる、と。

普通にSolaris 10をインストールする

は、特に書くことないね。1つ前のエントリでも書いてないし。

ZFSルート用のディスクを用意

VirtualBoxでディスクを追加するだけ。今回は「プライマリ スレーブ」の位置に追加。ディスク容量は最初に作ったのと同じ16GB。
Solaris上からはc0d1と見える。最初に作った方はc0d0。

ZFSルート用のZFSストレージプールを作成する

何も考えずに作ったストレージプールだと、次のlucreateのところで次のようなエラーに出会うorz

ERROR: ZFS pool <rpool> does not support boot environments

ということで、マニュアルをよく読むと

Before you create the new pool, make sure that the disks to be used in the pool have an SMI (VTOC) label instead of an EFI label

EFIラベルではダメよ、と書いてある訳だ。で、追加したディスクのラベルを確認してみるとEFIと書いてあるYO!

# fdisk c0d1
             Total disk size is 2088 cylinders
             Cylinder size is 16065 (512 byte) blocks

                                               Cylinders
      Partition   Status    Type          Start   End   Length    %
      =========   ======    ============  =====   ===   ======   ===
          1                 EFI               0  2088    2089    100

fdiskコマンドで一旦EFIパーティションを削除して、新たにSolarisパーティションを作成したところ

             Total disk size is 2088 cylinders
             Cylinder size is 16065 (512 byte) blocks

                                               Cylinders
      Partition   Status    Type          Start   End   Length    %
      =========   ======    ============  =====   ===   ======   ===
          1       Active    Solaris2          1  2087    2087    100

気を取り直してZFSストレージプールを作成し直し。ディスクは1つなのでミラーなどにはしていない。

# zpool create rpool c0d1s0
# 

lucreateでZFSルートなBoot Environment ( BE )を作成する

「ufs」がDVDからインストールしたBE。「zfs」が新たに今回作成するZFSルート用のBE。「rpool」が先に作成したストレージプール。
実行したら終わるのを辛抱強く待ちましょう。だって長いんだもん。

# lucreate -c ufs -n zfs -p rpool
Checking GRUB menu...
System has findroot enabled GRUB
Analyzing system configuration.
Comparing source boot environment <ufs> file systems with the file 
system(s) you specified for the new boot environment. Determining which 
file systems should be in the new boot environment.
Updating boot environment description database on all BEs.
Updating system configuration files.
The device </dev/dsk/c0d1s0> is not a root device for any boot environment; cannot get BE ID.
Creating configuration for boot environment <zfs>.
Source boot environment is <ufs>.
Creating boot environment <zfs>.
Creating file systems on boot environment <zfs>.
Creating <zfs> file system for </> in zone <global> on <rpool/ROOT/zfs>.
Populating file systems on boot environment <zfs>.
Checking selection integrity.
Integrity check OK.
Populating contents of mount point </>.
Copying.
Creating shared file system mount points.
Creating compare databases for boot environment <zfs>.
Creating compare database for file system </rpool/ROOT>.
Creating compare database for file system </>.
Updating compare databases on boot environment <zfs>.
Making boot environment <zfs> bootable.
Updating bootenv.rc on ABE <zfs>.
File </boot/grub/menu.lst> propagation successful
Copied GRUB menu from PBE to ABE
No entry for BE <zfs> in GRUB menu
Population of boot environment <zfs> successful.
Creation of boot environment <zfs> successful.
# 

多分これであっているんじゃないかな?1度もlucreateを実行していない状態だとインストールした時の状態はBEとして登録されていない。lucreateを適当に何度か実行すればBEとして登録されるので、適当に。

luactivateで利用するBEを切り替える

それでは最後のBEの切り替え。サクっと実行。

# luactivate zfs
System has findroot enabled GRUB
Generating boot-sign, partition and slice information for PBE <ufs>
A Live Upgrade Sync operation will be performed on startup of boot environment <zfs>.

Generating boot-sign for ABE <zfs>
NOTE: File </etc/bootsign> not found in top level dataset for BE <zfs>
Generating partition and slice information for ABE <zfs>
Boot menu exists.
Generating multiboot menu entries for PBE.
Generating multiboot menu entries for ABE.
Disabling splashimage
Re-enabling splashimage
No more bootadm entries. Deletion of bootadm entries is complete.
GRUB menu default setting is unaffected
Done eliding bootadm entries.

**********************************************************************

The target boot environment has been activated. It will be used when you 
reboot. NOTE: You MUST NOT USE the reboot, halt, or uadmin commands. You 
MUST USE either the init or the shutdown command when you reboot. If you 
do not use either init or shutdown, the system will not boot using the 
target BE.

**********************************************************************

In case of a failure while booting to the target BE, the following process 
needs to be followed to fallback to the currently working boot environment:

1. Boot from the Solaris failsafe or boot in Single User mode from Solaris 
Install CD or Network.

2. Mount the Parent boot environment root slice to some directory (like 
/mnt). You can use the following command to mount:

     mount -Fufs /dev/dsk/c0d0s0 /mnt

3. Run <luactivate> utility with out any arguments from the Parent boot 
environment root slice, as shown below:

     /mnt/sbin/luactivate

4. luactivate, activates the previous working boot environment and 
indicates the result.

5. Exit Single User mode and reboot the machine.

**********************************************************************

Modifying boot archive service
Propagating findroot GRUB for menu conversion.
File </etc/lu/installgrub.findroot> propagation successful
File </etc/lu/stage1.findroot> propagation successful
File </etc/lu/stage2.findroot> propagation successful
File </etc/lu/GRUB_capability> propagation successful
Deleting stale GRUB loader from all BEs.
File </etc/lu/installgrub.latest> deletion successful
File </etc/lu/stage1.latest> deletion successful
File </etc/lu/stage2.latest> deletion successful
Activation of boot environment <zfs> successful.
# 

というわけで、再起動後はZFSルートでブートな環境になったのでした。めでたしめでたし(^o^)

# lustatus
Boot Environment           Is       Active Active    Can    Copy      
Name                       Complete Now    On Reboot Delete Status    
-------------------------- -------- ------ --------- ------ ----------
ufs                        yes      yes    no        no     -         
zfs                        yes      no     yes       no     -         
# 


ちなみにluactivateで切り替える前はこんな感じ。

# lustatus
Boot Environment           Is       Active Active    Can    Copy      
Name                       Complete Now    On Reboot Delete Status    
-------------------------- -------- ------ --------- ------ ----------
ufs                        yes      yes    yes       no     -         
zfs                        yes      no     no        yes    -         
#

*1:GUIインストーラと同様にluコマンドもZFS未対応だから