Solaris 11.1(及更高版本)

执行“bootadm install-bootloader -v -P {name-f-root-ZFS-pool}”。
这将检查引导块并将其放在一边,如果引导块已经安装并且版本合适。

# bootadm install-bootloader -v -P rpool 
Installing loader on /dev/rdsk/c0t5001517959450300d0s0 with `/sbin/installboot -F zfs -u 0.5.11,5.11-0.175.3.0.0.30.0 //usr/platform/sun4v/lib/fs/zfs/bootblk /dev/rdsk/c0t5001517959450300d0s0'... 
Output from "/sbin/installboot -F zfs -u 0.5.11,5.11-0.175.3.0.0.30.0 //usr/platform/sun4v/lib/fs/zfs/bootblk /dev/rdsk/c0t5001517959450300d0s0" was: 
<STDERR>: 
bootblock version installed on /dev/rdsk/c0t5001517959450300d0s0 is more recent or identical 
Use -f to override or install without the -u option 
<END OF OUTPUT>

我们可以解析此命令的 stderr 输出以获取模式“更近或者相同”以确认正确的引导块

# bootadm install-bootloader -v  -P rpool  2>&1 | egrep "is more recent or identical" 
bootblock version installed on /dev/rdsk/c0t5001517959450300d0s0 is more recent or identical
更多: zhilu jiaocheng

对于 Solaris 11

installboot -i 选项(带有 -e 或者 -V )检查是否存在引导块,如果存在,则打印有关引导块的添加信息。

请参阅下面的“用法”输出:

# installboot
Usage: installboot [-h|-f|-F fstype|-u verstr] bootblk raw-device
installboot [-e|-V] -i -F zfs raw-device 
installboot -M -F zfs raw-device attach-raw-device
fstype is one of: 'ufs', 'hsfs' or 'zfs'

-e 仅返回版本字符串和 MD5 哈希,例如:

# installboot -ei -F zfs /dev/rdsk/c0t5000CCA012AD763Cd0s0
0.5.11,5.11-0.175.3.0.0.30.40452
5076df7715eaf2658f5d80ee533e09d1

而 -V 打印整个扩展信息结构:

# installboot -Vi -F zfs /dev/rdsk/c0t5000CCA012AD763Cd0s0
Boot Block Extended Info Header:
magic: EXTINFO
version: 1
flags: 0
extended version string offset: 71
extended version string size: 32
hashing type: 1 (MD5)
hash offset: 54
hash size: 16
Extended version string: 0.5.11,5.11-0.175.3.0.0.30.40452
MD5 hash: 5076df7715eaf2658f5d80ee533e09d1

如果磁盘不包含引导块,输出将类似于以下内容:

# installboot -iV -F zfs /dev/rdsk/c0t600144F0002128A65EDA582243930003d0s0
No extended information found

对于 Solaris 10

下面是带有 UFS 的 Solaris 10u4. 带有 UFS 的 Solaris 10u6 和带有 ZFS 引导块的 Solaris 10u6 的输出。
bootblk 版本从 s10u6 开始更改。
这就是 s10u6 和更早版本之间的输出不同的原因。

S10U1 到 U5 UFS root:

# dd if=/dev/rdsk/c0t0d0s0 bs=1b count=1 iseek=1 | od -c -N 3
1+0 records in
1+0 records out
0000000 375 003 J
0000003

S10U6,UFS root:

# dd if=/dev/rdsk/c0t0d0s0 bs=1b count=1 iseek=1 | od -c -N 3
1+0 records in
1+0 records out
0000000 375 003 X
0000003

S10U6,ZFS root:

# dd if=/dev/rdsk/c0t0d0s0 bs=1b count=1 iseek=1 | od -c -N 3
1+0 records in
1+0 records out
0000000 375 003 326
0000003

根据区域设置,输出有时可能会在没有八进制转换的情况下出现。
因此,如果我们看到类似于下面的字符,请不要认为 bootblk 已损坏。

# dd if=/dev/rdsk/c1t0d0s0 bs=1b count=1 iseek=1 | od -c -N 3
00000001+0   ý 003   Ö

转换为八进制的那些字符是:

ý == 375 (octal) 
Ö == 326 (octal)

.. 在上面的例子中仍然匹配一个有效的 bootblk。

如何检查引导盘上是否安装了 Bootblk

如果系统因怀疑的 bootblk 问题而无法启动,或者我们怀疑操作系统中的某些内容不断覆盖 bootblk,这在故障排除时非常有用。

日期:2020-09-17 00:15:04 来源:oir作者:oir