CONTENTS


Lastmodified 2017-04-01 (土) 17:37:14


G7 のZpoolをAFTへ

ZFSの容量が足りなくなって、AFTなディスクを買ったので、Zpoolを作り直す。

ZFSのは、プールを作ったあとからashiftの値は変更できないし、AFTのディスクを512bとして使うとパフォーマンスが著しく低下するし。

http://poyo.hatenablog.jp/entry/archives/611

# df -h
Filesystem     Size    Used   Avail Capacity  Mounted on
/dev/ada0p2    222G    7.5G    197G     4%    /
devfs          1.0K    1.0K      0B   100%    /dev
# zpool destroy tank
# zpool create tank raidz1 ada1 ada2 ada3
# zpool status
  pool: tank
 state: ONLINE
  scan: none requested
config:

        NAME        STATE     READ WRITE CKSUM
        tank        ONLINE       0     0     0
          raidz1-0  ONLINE       0     0     0
            ada1    ONLINE       0     0     0
            ada2    ONLINE       0     0     0
            ada3    ONLINE       0     0     0
# zdb
tank:
   version: 5000
   name: 'tank'
   state: 0
   txg: 4
   pool_guid: 2476688524590953763
   hostid: 1489282663
   hostname: 'g7.kuji-clinic.net'
   vdev_children: 1
   vdev_tree:
       type: 'root'
       id: 0
       guid: 2476688524590953763
       create_txg: 4
       children[0]:
           type: 'raidz'
           id: 0
           guid: 5106231588131236623
           nparity: 1
           metaslab_array: 34
           metaslab_shift: 36
           ashift: 12                  ← OK
           asize: 9001764126720
           is_log: 0
           create_txg: 4
           children[0]:
               type: 'disk'
               id: 0
               guid: 2710842930662410753
               path: '/dev/ada1'
               phys_path: '/dev/ada1'
               whole_disk: 1
               create_txg: 4
           children[1]:
               type: 'disk'
               id: 1
               guid: 3868498965116297723
               path: '/dev/ada2'
               phys_path: '/dev/ada2'
               whole_disk: 1
               create_txg: 4
           children[2]:
               type: 'disk'
               id: 2
               guid: 11787258634698744109
               path: '/dev/ada3'
               phys_path: '/dev/ada3'
               whole_disk: 1
               create_txg: 4
   features_for_read:
       com.delphix:hole_birth
       com.delphix:embedded_data
# zfs set mountpoint=/usr/home tank

流儀に則ってリンクを作る

g7# ln -s /usr/home/ /home

と、こうなる

root@g7:/boot/zfs # df -h
Filesystem     Size    Used   Avail Capacity  Mounted on
/dev/ada0p2    222G    7.5G    197G     4%    /
devfs          1.0K    1.0K      0B   100%    /dev
tank           5.2T    128K    5.2T     0%    /usr/home

【確認事項】

/boot/loader.conf

vfs.zfs.prefetch_disable=0

/etc/rc.conf

zfs_enable="YES"

/boot/loader.conf

zfs_load="YES"

G7 down 2014/04/30

バックアップは、blackhole.smb.net にあるんですが・・・

/usr/Backups/G7_kuji-clinic_net/usr/home

Zpoolと接続?

root@g7:~ # df
Filesystem  1K-blocks    Used     Avail Capacity  Mounted on
/dev/ada0p2 232575736 1888064 212081616     1%    /
devfs               1       1         0   100%    /dev
root@g7:~ # zpool status
no pools available

と言われるが、3基で構成したZpoolが有るはずなので、

root@g7:~ # zpool import
   pool: tank
     id: 12555809847404181753
  state: ONLINE
 status: The pool was last accessed by another system.
 action: The pool can be imported using its name or numeric identifier and
        the '-f' flag.
   see: http://illumos.org/msg/ZFS-8000-EY
 config:

        tank        ONLINE
          raidz1-0  ONLINE
            ada1    ONLINE
            ada2    ONLINE
            ada3    ONLINE

と、確かにある。が、

root@g7:~ # zpool status -x
no pools available

と言われる。ここで、

root@g7:~ # zpool import -f tank

としてから、

root@g7:~ # zpool status -x
all pools are healthy

となって、見える様になる。

root@g7:~ # zpool status
 pool: tank
 state: ONLINE
status: The pool is formatted using a legacy 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 software that does not support feature
        flags.
  scan: none requested
config:

        NAME        STATE     READ WRITE CKSUM
        tank        ONLINE       0     0     0
          raidz1-0  ONLINE       0     0     0
            ada1    ONLINE       0     0     0
            ada2    ONLINE       0     0     0
            ada3    ONLINE       0     0     0

errors: No known data errors
root@g7:~ # zfs set mountpoint=/usr/home tank
root@g7:~ # df
Filesystem  1K-blocks     Used     Avail Capacity  Mounted on
/dev/ada0p2 232575736  1897176 212072504     1%    /
devfs               1        1         0   100%    /dev
tank        478467304 64759779 413707525    14%    /usr/home
  993  18:00   freebsd-update fetch
  994  18:01   zpool status
  995  18:02   freebsd-update install
  996  18:02   reboot
  997  18:12   shutdown now
  998  18:54   top
  999  18:56   df
 1000  18:59   reboot
 1001  19:02   top
 1002  19:02   cat /var/log/messages
 1003  19:03   zpool status
 1004  19:08   zpool status -x
 1005  19:10   zpool import
 1006  19:11   zpool status -x
 1007  19:12   zpool import
 1008  19:13   cd /boot/zfs
 1009  19:15   zfs set mountpoint=/usr/home tank
 1010  19:15   zpool create tank raidz1 ada1 ada2 ada3
 1011  19:16   zpool status -x
 1012  19:17   zpool import
 1013  19:17   zfs set mountpoint=/usr/home tank
 1014  19:18   zpool create tank raidz1 ada1 ada2 ada3
 1015  19:19   df -h
 1016  19:19   zpool export tank
 1017  19:19   zpool import tank
 1018  19:20   zpool import -f tank
 1019  19:20   df
 1020  19:26   zfs set mountpoint=/usr/home tank
 1021  19:26   df
 1022  19:45   history

G7 FreeBSD9.1R-p3

ML110 G7 OSレスモデル 6473360-AHZN (HP(旧コンパック))のデフォルトMemoryは2GB、HDD250GB

2013年6月1日現在の時点で当該モデル上でZFSrootな環境では、リブートに失敗する。っていうかシャットダウン出来ない。

http://www.nekolove.jp/wp/archives/2012/11/20121108105449.php

そこで、システムはUFSで、ユーザのデータ(/usr/home)はZFSで行くことにする。

デフォルト同梱の250GBのHDDへ、FreeBSD9.1RをDVD1を用いて普通に?UFSででインストール。このとき、一般ユーザを作らなければ/usr/homeはない。

root@g7:/boot/zfs # df -h
Filesystem     Size    Used   Avail Capacity  Mounted on
/dev/ada0p2    220G    3.6G    199G     2%    /
devfs          1.0k    1.0k      0B   100%    /dev

の様になっている。勿論、/以下には、/usr/home やリンクはない。

で、ここで500GBのHDD3基を残りのベイに挿して、

zpool create tank raidz1 ada1 ada2 ada3

する。と、

root@g7:/boot/zfs # zpool status
  pool: tank
 state: ONLINE
  scan: none requested
config:

        NAME        STATE     READ WRITE CKSUM
        tank        ONLINE       0     0     0
          raidz1-0  ONLINE       0     0     0
            ada1    ONLINE       0     0     0
            ada2    ONLINE       0     0     0
            ada3    ONLINE       0     0     0

errors: No known data errors

このtankを/usr/homeにする

g7# zfs set mountpoint=/usr/home tank

流儀に則ってリンクを作る

g7# ln -s /usr/home/ /home

と、こうなる

root@g7:/boot/zfs # df -h
Filesystem     Size    Used   Avail Capacity  Mounted on
/dev/ada0p2    220G    3.6G    199G     2%    /
devfs          1.0k    1.0k      0B   100%    /dev
tank           912G     40k    912G     0%    /usr/home

で、これだけだと、rebootすると、

messagesにこんなログも吐いて

Jun  1 12:48:43 g7 kernel: ZFS NOTICE: Prefetch is disabled by default if less than 4GB of RAM is present;
Jun  1 12:48:43 g7 kernel: to enable, add "vfs.zfs.prefetch_disable=0" to /boot/loader.conf.
Jun  1 12:48:43 g7 kernel: ZFS filesystem version 5
Jun  1 12:48:43 g7 kernel: ZFS storage pool version 28

/usr/home がdfで見えなくなります。

Filesystem     Size    Used   Avail Capacity  Mounted on
/dev/ada0p2    220G    3.6G    199G     2%    /
devfs          1.0k    1.0k      0B   100%    /dev

このとき、

g7# cd /boot/zfs
g7# zpool export tank
g7# zpool import tank

すれば、

tank           912G     40k    912G     0%    /usr/home

が再び現れます。(^_^;


コレの回避策は、4GB以上メモリーを積むか、

/boot/loader.conf

vfs.zfs.prefetch_disable=0

のどちらか・・・です。

というのは、ウソでした(^^ゞ

8GBのメモリーを積んでみました。起動時に

ZFS NOTICE: Prefetch is disabled by default if less than 4GB of RAM is present;

というログは消えましたが、

root@G7:/dev # df -h
Filesystem     Size    Used   Avail Capacity  Mounted on
/dev/ada0p2    220G    3.5G    199G     2%    /
devfs          1.0k    1.0k      0B   100%    /dev
tank           912G     40k    912G     0%    /usr/home

最下段のtankの行は出てきません。/etc/fstabに書くのかな・・・じゃなくて(^^ゞ

https://www.bsdconsulting.co.jp/DOWNLOAD/FREEBSDSTUDY-013.SATO.pdf

によれば、

/etc/fstab は見ない。

/etc/rc.conf

zfs_enable="YES"

/boot/loader.conf

zfs_load="YES"

を書くべし。とのことでした。

要するに、カーネルモジュールを自分で明示的に起動しなさい、ということでした(^^ゞ

GEOM: ada1: the primary GPT table is corrupt or invalid.

買ったばかりのHDDをベイに挿しただけだと、/var/log/messages にこんな・・・

Jun  6 18:04:18 G7 kernel: GEOM: ada1: the primary GPT table is corrupt or invalid.
Jun  6 18:04:18 G7 kernel: GEOM: ada1: using the secondary instead -- recovery strongly advised.
Jun  7 06:37:48 G7 kernel: GEOM: ada2: the primary GPT table is corrupt or invalid.
Jun  7 06:37:48 G7 kernel: GEOM: ada2: using the secondary instead -- recovery strongly advised.
Jun  7 06:37:48 G7 kernel: GEOM: ada3: the primary GPT table is corrupt or invalid.
Jun  7 06:37:48 G7 kernel: GEOM: ada3: using the secondary instead -- recovery strongly advised.
Jun  7 06:37:48 G7 kernel: Trying to mount root from ufs:/dev/ada0p2 [rw]...

なんかマズイ風味

root@G7:/root # gpart show /dev/ada1
gpart: No such geom: /dev/ada1.

確かに、GPT table ありません。

root@G7:/root # gpart create -s gpt ada1
gpart: geom 'ada1': Operation not permitted

あれ?

root@G7:/root # gpart create -s gpt /dev/ada1
gpart: geom 'ada1': Operation not permitted

ん?こういうのは、これで良かった様な・・・

root@G7:/root # sysctl kern.securelevel
kern.securelevel: -1
root@G7:/root # sysctl kern.geom.debugflags=0x10
kern.geom.debugflags: 0 -> 16

これでどうだ?

root@G7:/root # gpart create -s gpt /dev/ada1
ada1 created

できたヽ(^。^)丿

root@G7:/root # gpart create -s gpt /dev/ada2
ada2 created
root@G7:/root # gpart create -s gpt /dev/ada3
ada3 created

他のも出来たので、

root@G7:/root # sysctl kern.geom.debugflags=0
kern.geom.debugflags: 16 -> 0

と元へとかえす。ちょっと強引だったか(^^ゞ


HDDの物理的ベイとデバイス認識のズレ

システムは、、/dev/ada0上にあって、物理的には一番ベイにある。で、ada1~3の三基のHDDでraidz1を組むということなのだけど、実際にHDDを2番ベイに一基増やすと、

Jun  6 10:04:49 G7 kernel: ada0 at ata2 bus 0 scbus0 target 0 lun 0
Jun  6 10:04:49 G7 kernel: ada0: <VB0250EAVER HPG9> ATA-8 SATA 2.x device
Jun  6 10:04:49 G7 kernel: ada0: 300.000MB/s transfers (SATA 2.x, UDMA5, PIO 8192bytes)
Jun  6 10:04:49 G7 kernel: ada0: 238475MB (488397168 512 byte sectors: 16H 63S/T 16383C)
Jun  6 10:04:49 G7 kernel: ada0: Previously was known as ad4
Jun  6 10:04:49 G7 kernel: ada1 at ata2 bus 0 scbus0 target 1 lun 0
Jun  6 10:04:49 G7 kernel: ada1: <WDC WD5000AZLX-00K4KA0 80.00A80> ATA-8 SATA 3.x device
Jun  6 10:04:49 G7 kernel: ada1: 600.000MB/s transfers (SATA 3.x, UDMA5, PIO 8192bytes)
Jun  6 10:04:49 G7 kernel: ada1: 476940MB (976773168 512 byte sectors: 16H 63S/T 16383C)

の様になる。で、その隣の3番ベイにHitachのHDDをさすと・・・

Jun  6 10:04:49 G7 kernel: ada0 at ata2 bus 0 scbus0 target 0 lun 0
Jun  6 10:04:49 G7 kernel: ada0: <VB0250EAVER HPG9> ATA-8 SATA 2.x device
Jun  6 10:04:49 G7 kernel: ada0: 300.000MB/s transfers (SATA 2.x, UDMA5, PIO 8192bytes)
Jun  6 10:04:49 G7 kernel: ada0: 238475MB (488397168 512 byte sectors: 16H 63S/T 16383C)
Jun  6 10:04:49 G7 kernel: ada0: Previously was known as ad4
Jun  6 10:04:49 G7 kernel: ada1 at ata2 bus 0 scbus0 target 1 lun 0
Jun  6 10:04:49 G7 kernel: ada1: <Hitachi HDP725050GLA360 GM4OA52A> ATA-8 SATA 2.x device
Jun  6 10:04:49 G7 kernel: ada1: 300.000MB/s transfers (SATA 2.x, UDMA5, PIO 8192bytes)
Jun  6 10:04:49 G7 kernel: ada1: 476940MB (976773168 512 byte sectors: 16H 63S/T 16383C)
Jun  6 10:04:49 G7 kernel: ada1: Previously was known as ad5
Jun  6 10:04:49 G7 kernel: ada2 at ata3 bus 0 scbus1 target 0 lun 0
Jun  6 10:04:49 G7 kernel: ada2: <WDC WD5000AZLX-00K4KA0 80.00A80> ATA-8 SATA 3.x device
Jun  6 10:04:49 G7 kernel: ada2: 600.000MB/s transfers (SATA 3.x, UDMA5, PIO 8192bytes)
Jun  6 10:04:49 G7 kernel: ada2: 476940MB (976773168 512 byte sectors: 16H 63S/T 16383C)
Jun  6 10:04:49 G7 kernel: ada2: Previously was known as ad6
Jun  6 11:18:19 G7 kernel: ada0 at ata2 bus 0 scbus0 target 0 lun 0
Jun  6 11:18:19 G7 kernel: ada0: <VB0250EAVER HPG9> ATA-8 SATA 2.x device
Jun  6 11:18:19 G7 kernel: ada0: 300.000MB/s transfers (SATA 2.x, UDMA5, PIO 8192bytes)
Jun  6 11:18:19 G7 kernel: ada0: 238475MB (488397168 512 byte sectors: 16H 63S/T 16383C)
Jun  6 11:18:19 G7 kernel: ada0: Previously was known as ad4
Jun  6 11:18:19 G7 kernel: ada1 at ata2 bus 0 scbus0 target 1 lun 0
Jun  6 11:18:19 G7 kernel: ada1: <Hitachi HDP725050GLA360 GM4OA52A> ATA-8 SATA 2.x device
Jun  6 11:18:19 G7 kernel: ada1: 300.000MB/s transfers (SATA 2.x, UDMA5, PIO 8192bytes)
Jun  6 11:18:19 G7 kernel: ada1: 476940MB (976773168 512 byte sectors: 16H 63S/T 16383C)
Jun  6 11:18:19 G7 kernel: ada1: Previously was known as ad5
Jun  6 11:18:19 G7 kernel: ada2 at ata3 bus 0 scbus1 target 0 lun 0
Jun  6 11:18:19 G7 kernel: ada2: <WDC WD5000AZLX-00K4KA0 80.00A80> ATA-8 SATA 3.x device
Jun  6 11:18:19 G7 kernel: ada2: 600.000MB/s transfers (SATA 3.x, UDMA5, PIO 8192bytes)
Jun  6 11:18:19 G7 kernel: ada2: 476940MB (976773168 512 byte sectors: 16H 63S/T 16383C)
Jun  6 11:18:19 G7 kernel: ada2: Previously was known as ad6
Jun  6 11:18:19 G7 kernel: ada3 at ata3 bus 0 scbus1 target 1 lun 0
Jun  6 11:18:19 G7 kernel: ada3: <Hitachi HDP725050GLA360 GM4OA5CA> ATA-8 SATA 2.x device
Jun  6 11:18:19 G7 kernel: ada3: 300.000MB/s transfers (SATA 2.x, UDMA5, PIO 8192bytes)
Jun  6 11:18:19 G7 kernel: ada3: 476940MB (976773168 512 byte sectors: 16H 63S/T 16383C)
Jun  6 11:18:19 G7 kernel: ada3: Previously was known as ad7

こうなってしまう。WDのHDDが、ada1からada2に変わっている。自動認識した順番だそうな・・・(´・ω・`)

トラブル時などに混乱しないように、物理的ベイと一致させて固定化したい所。

http://wiki.rookie-inc.com/os/nas4free/fixdevicenum

http://www.freebsd.org/doc/ja/books/handbook/device-hints.html

http://wirednoize.net/freebsd/index.php?FreeBSD%208.2%20Release%20AHCI%20to%20CAM

device.hintsに記述して、デバイス番号を固定化するヨロシ

hint.scbus.0.at="ahcich10"
hint.ada.0.at="scbus0"
hint.scbus.1.at="ahcich11"
hint.ada.1.at="scbus1"
hint.scbus.0.at="ahcich12"
hint.ada.2.at="scbus0"
hint.scbus.1.at="ahcich13"
hint.ada.3.at="scbus1"
echo 'hint.scbus.0.at="ahcich0"' >> /boot/device.hints
echo 'hint.ada.0.at="scbus0"'    >> /boot/device.hints
echo 'hint.scbus.1.at="ahcich1"' >> /boot/device.hints
echo 'hint.ada.1.at="scbus1"'    >> /boot/device.hints
echo 'hint.scbus.2.at="ahcich2"' >> /boot/device.hints
echo 'hint.ada.2.at="scbus2"'    >> /boot/device.hints
echo 'hint.scbus.3.at="ahcich3"' >> /boot/device.hints
echo 'hint.ada.3.at="scbus3"'    >> /boot/device.hints
echo 'hint.scbus.4.at="ahcich4"' >> /boot/device.hints
echo 'hint.ada.4.at="scbus4"'    >> /boot/device.hints
echo 'hint.scbus.5.at="ahcich5"' >> /boot/device.hints
echo 'hint.ada.5.at="scbus5"'    >> /boot/device.hints

Total access 3978:本日 1:昨日 0

Counter: 3978, today: 1, yesterday: 0

トップ   編集 凍結 差分 履歴 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2017-04-01 (土) 17:37:14