2011年2月1日火曜日

FreeBSD 8.0→8.2に伴いzfsを更新してみる

このエントリーをブックマークに追加 このエントリーを含むはてなブックマーク
FreeBSD 8.0で構築したzfsを、FreeBSD 8.2にupgradeした際に正しく更新することは出来るのか? という話です。zfsbootとか複雑なことをしていない限り、あっさり更新出来るはず。ちょっとvmware上で試してみました。

FreeBSD 8.0-RELEASE (i386) の環境構築


まず8.0-RELEASEを入れ、カーネルをリコンパイルします。GENERICに書くので /usr/src を make update したときは注意すること。

options KVA_PAGES=512

次にzfsを有効にする。(vmware)

vm.kmem_size="768M"
vm.kmem_size_max="768M"
vfs.zfs.arc_max="80M"

そして

# bsdlabel /dev/ad0s1
# /dev/ad0s1:
8 partitions:
# size offset fstype [fsize bsize bps/cpg]
a: 1048576 0 4.2BSD 0 0 0
b: 6223488 1048576 swap
c: 41942817 0 unused 0 0 # "raw" part, don't edit
d: 5208064 7272064 4.2BSD 0 0 0
e: 1048576 12480128 4.2BSD 0 0 0
f: 8388608 13528704 4.2BSD 0 0 0
g: 20025505 21917312 4.2BSD 0 0 0
# bsdlabel /dev/ad1
bsdlabel: /dev/ad1: no valid label found

ad0s1g と ad1 がzfspool候補。

# zpool create zp0 ad0s1g
# zpool create zp1 ad1

# zpool list
NAME SIZE USED AVAIL CAP HEALTH ALTROOT
zp0 9.50G 72K 9.50G 0% ONLINE -
zp1 7.94G 72K 7.94G 0% ONLINE -

こうなる。

# df
Filesystem 1K-blocks Used Avail Capacity Mounted on
/dev/ad0s1a 507630 208682 258338 45% /
devfs 1 1 0 100% /dev
/dev/ad0s1e 507630 12 467008 0% /tmp
/dev/ad0s1f 4058062 2226374 1507044 60% /usr
/dev/ad0s1d 2521070 37264 2282122 2% /var
zp0 9805696 0 9805696 0% /zp0
zp1 8192896 0 8192896 0% /zp1

/usr/src, /usr/portsをzfsに置いておく。

# cd /usr
# tar -cpf - src | ( cd /zp0/ ; tar -xf - )
# tar -cpf - ports | ( cd /zp1/ ; tar -xf - )
# mv ports ports.orig
# ln -s /zp0/src src
# ln -s /zp1/ports ports

これで試行準備完了。

ここからFreeBSD 8.2

RELENG_8_2 に更新。/usr/src/Makefileの教えに従い滞りなく終了。sysutils/py-zfs は8.2に上げてから導入or更新。

Before:(8.0-RELEASE-p6)

%zpool status -v
pool: zp0
state: ONLINE
scrub: none requested
config:

NAME STATE READ WRITE CKSUM
zp0 ONLINE 0 0 0
ad0s1g ONLINE 0 0 0

errors: No known data errors

pool: zp1
state: ONLINE
scrub: none requested
config:

NAME STATE READ WRITE CKSUM
zp1 ONLINE 0 0 0
ad1 ONLINE 0 0 0

errors: No known data errors

%zpool upgrade
This system is currently running ZFS pool version 13.

All pools are formatted using this version.

%zfs upgrade
This system is currently running ZFS filesystem version 3.

All filesystems are formatted with the current version.

After:(8.2-RC3)

# zpool status -v
pool: zp0
state: ONLINE
status: The pool is formatted using an older on-disk format. The pool can
still be used, but some features are unavailable.
action: Upgrade the pool using 'zpool upgrade'. Once this is done, the
pool will no longer be accessible on older software versions.
scrub: none requested
config:

NAME STATE READ WRITE CKSUM
zp0 ONLINE 0 0 0
ad0s1g ONLINE 0 0 0

errors: No known data errors

pool: zp1
state: ONLINE
status: The pool is formatted using an older on-disk format. The pool can
still be used, but some features are unavailable.
action: Upgrade the pool using 'zpool upgrade'. Once this is done, the
pool will no longer be accessible on older software versions.
scrub: none requested
config:

NAME STATE READ WRITE CKSUM
zp1 ONLINE 0 0 0
ad1 ONLINE 0 0 0

errors: No known data errors

# zpool upgrade
This system is currently running ZFS pool version 15.

The following pools are out of date, and can be upgraded. After being
upgraded, these pools will no longer be accessible by older software versions.

VER POOL
--- ------------
13 zp0
13 zp1

Use 'zpool upgrade -v' for a list of available versions and their associated
features.

# zfs upgrade
This system is currently running ZFS filesystem version 4.

The following filesystems are out of date, and can be upgraded. After being
upgraded, these filesystems (and any 'zfs send' streams generated from
subsequent snapshots) will no longer be accessible by older software versions.


VER FILESYSTEM
--- ------------
3 zp0
3 zp1

ということでupgrade推奨されるので…(例によってバックアップはしっかりとりましょう)

# zfs upgrade -a
zp0: can not be upgraded; the pool version needs to first be upgraded
to version 15

zp1: can not be upgraded; the pool version needs to first be upgraded
to version 15

0 filesystems upgraded
これはzpoolのupgradeをする前に zfs をupgradeしようとしたのでエラーになった。順番が重要です。

# zpool upgrade -a
This system is currently running ZFS pool version 15.

Successfully upgraded 'zp0'

Successfully upgraded 'zp1'
数秒で終わる。

# zfs upgrade -a
2 filesystems upgraded
十数秒で終わる。

# zpool upgrade
This system is currently running ZFS pool version 15.

All pools are formatted using this version.

# zfs upgrade
This system is currently running ZFS filesystem version 4.

All filesystems are formatted with the current version.

# zpool status
pool: zp0
state: ONLINE
scrub: none requested
config:

NAME STATE READ WRITE CKSUM
zp0 ONLINE 0 0 0
ad0s1g ONLINE 0 0 0

errors: No known data errors

pool: zp1
state: ONLINE
scrub: none requested
config:

NAME STATE READ WRITE CKSUM
zp1 ONLINE 0 0 0
ad1 ONLINE 0 0 0

errors: No known data errors
かくて滞りなくOSの更新もzfsの更新も終了。


注意事項、というか、正直よく分かっていない事項として、8.0→8.2になった際に物理ドライブの位置が変更されてしまった場合に(ad0がad4になったり、別のデバイス名になったら)どうなるのだろう?という点。zfsとして読み込めていれば問題はないのでしょうか?

0 件のコメント: