2012年12月10日月曜日

3TB ディスクから CentOS 6.3 をブート

バックアップ用に 3TB のディスク (WD30EZRX/K) を購入しました。

まずは、Windows 7 で採取した CrystalDiskInfo の結果です。
ZALMAN ZM-HE350 U3E というケースに格納し、ThinkPad T510 に eSATA 接続しています。WD30EZRX/K は NCQ に対応していますが、このケース経由だと NCQ が使えません (他のドライブでも確認・経験済み) 。その点はちょっと残念。

さて、CentOS 6.3 ならば、UEFI 非対応のマシン (ThinkPad T510 も勿論非対応) でも、3TB ディスクからブート可能という情報がありましたので、実際にやってみました。他のドライブが繋がっているとヤヤコシイので、一旦 3TB ディスク以外は外してインストールしました。その後に、内臓 SSD などを戻しています。また、ThinkPad の BIOS でブートオーダーを変更して起動しました。
# parted -s /dev/sdc print
Model: ATA WDC WD30EZRX-00D (scsi)
Disk /dev/sdc: 3001GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt

Number  Start   End     Size    File system     Name                  Flags
 1      1049kB  211MB   210MB   ext4                                  boot
 2      211MB   21.2GB  21.0GB  ext4
 3      21.2GB  23.3GB  2097MB  linux-swap(v1)
 4      23.3GB  3001GB  2977GB  ntfs            Basic data partition

# df
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/sdc2             20158332   4737476  14396856  25% /
tmpfs                  3986236       260   3985976   1% /dev/shm
/dev/sdc1               198337     51449    136648  28% /boot

# ls -l /dev/root
lrwxrwxrwx. 1 root root 4 Dec  9 22:10 /dev/root -> sdc2

# uname -a
Linux xxxx 2.6.32-279.14.1.el6.i686 #1 SMP Tue Nov 6 21:05:14 UTC 2012 i686 i686 i386 GNU/Linux
このように、うまく動作しました。
Fedora 16 以降なら、grub2 を使って GPT ラベルを付与したディスクからブート可能とは知ってましたが、grub1 でも対応パッチがあるようで、CentOS 6.3 の grub に取り込まれていたようです。

2012年12月1日土曜日

中古 SSD の SecureErase

某ショップにて中古の Intel SSD 320 600G を入手しました。GB単価が安かった(約50円)ため、思わず衝動買い。

中古ということで、総書き込み量はそれなりかと思っていたのですが、初回接続時にWindows7からCrystalDiskInfoで見てみると、次のような具合でした。
注: DeLOCK 42492 という eSATA/USB3.0 両対応のケースを使ったのですが、そのケース経由だと NCQ が使えないようです。下の CentOS6 のデータは、ケースから取り出して eSATA-SATA ケーブルで接続した場合です。SATA 電源は USB から供給。DeLOCK ケースはちょっと残念。

次は、CentOS6 で起動後の smartctl および hdparm のデータです。
# uname -a
Linux xxx 2.6.32-279.14.1.el6.x86_64 #1 SMP Tue Nov 6 23:43:09 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux

# dmesg | egrep 'ata5|sdc'
ata5: SATA max UDMA/133 irq_stat 0x00400040, connection status changed irq 29
ata5: SATA link up 3.0 Gbps (SStatus 123 SControl 300)
ata5.00: ACPI cmd ef/02:00:00:00:00:a0 (SET FEATURES) succeeded
ata5.00: ACPI cmd f5/00:00:00:00:00:a0 (SECURITY FREEZE LOCK) filtered out
ata5.00: ATA-8: INTEL SSDSA2CW600G3, 4PC10362, max UDMA/133
ata5.00: 1172123568 sectors, multi 16: LBA48 NCQ (depth 31/32)
ata5.00: ACPI cmd ef/02:00:00:00:00:a0 (SET FEATURES) succeeded
ata5.00: ACPI cmd f5/00:00:00:00:00:a0 (SECURITY FREEZE LOCK) filtered out
ata5.00: configured for UDMA/133
ata5.00: configured for UDMA/133
ata5: EH complete
sd 5:0:0:0: [sdc] 1172123568 512-byte logical blocks: (600 GB/558 GiB)
sd 5:0:0:0: [sdc] Write Protect is off
sd 5:0:0:0: [sdc] Mode Sense: 00 3a 00 00
sd 5:0:0:0: [sdc] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
 sdc:
sd 5:0:0:0: [sdc] Attached SCSI disk

# smartctl -a /dev/sdc
smartctl 5.42 2011-10-20 r3458 [x86_64-linux-2.6.32-279.14.1.el6.x86_64] (local build)
Copyright (C) 2002-11 by Bruce Allen, http://smartmontools.sourceforge.net

=== START OF INFORMATION SECTION ===
Model Family:     Intel 320 Series SSDs
Device Model:     INTEL SSDSA2CW600G3
Serial Number:    CVPR??????????????
LU WWN Device Id: 5 001517 bb28?????
Firmware Version: 4PC10362
User Capacity:    600,127,266,816 bytes [600 GB]
Sector Size:      512 bytes logical/physical
Device is:        In smartctl database [for details use: -P show]
ATA Version is:   8
ATA Standard is:  ATA-8-ACS revision 4
Local Time is:    Fri Nov 30 22:03:19 2012 JST
SMART support is: Available - device has SMART capability.
SMART support is: Enabled

Error SMART Thresholds Read failed: scsi error aborted command
Smartctl: SMART Read Thresholds failed.

=== START OF READ SMART DATA SECTION ===
SMART overall-health self-assessment test result: PASSED

General SMART Values:
Offline data collection status:  (0x00) Offline data collection activity
     was never started.
     Auto Offline Data Collection: Disabled.
Self-test execution status:      (  17) The self-test routine was aborted by
     the host.
Total time to complete Offline 
data collection:   (    1) seconds.
Offline data collection
capabilities:     (0x75) SMART execute Offline immediate.
     No Auto Offline data collection support.
     Abort Offline collection upon new
     command.
     No Offline surface scan supported.
     Self-test supported.
     Conveyance Self-test supported.
     Selective Self-test supported.
SMART capabilities:            (0x0003) Saves SMART data before entering
     power-saving mode.
     Supports SMART auto save timer.
Error logging capability:        (0x01) Error logging supported.
     General Purpose Logging supported.
Short self-test routine 
recommended polling time:   (   1) minutes.
Extended self-test routine
recommended polling time:   (   1) minutes.
Conveyance self-test routine
recommended polling time:   (   1) minutes.
SCT capabilities:         (0x003d) SCT Status supported.
     SCT Error Recovery Control supported.
     SCT Feature Control supported.
     SCT Data Table supported.

SMART Attributes Data Structure revision number: 5
Vendor Specific SMART Attributes with Thresholds:
ID# ATTRIBUTE_NAME          FLAG     VALUE WORST THRESH TYPE      UPDATED  WHEN_FAILED RAW_VALUE
  3 Spin_Up_Time            0x0020   100   100   ---    Old_age   Offline      -       0
  4 Start_Stop_Count        0x0030   100   100   ---    Old_age   Offline      -       0
  5 Reallocated_Sector_Ct   0x0032   100   100   ---    Old_age   Always       -       0
  9 Power_On_Hours          0x0032   100   100   ---    Old_age   Always       -       1
 12 Power_Cycle_Count       0x0032   100   100   ---    Old_age   Always       -       5
170 Reserve_Block_Count     0x0033   100   100   ---    Pre-fail  Always       -       0
171 Program_Fail_Count      0x0032   100   100   ---    Old_age   Always       -       0
172 Erase_Fail_Count        0x0032   100   100   ---    Old_age   Always       -       0
183 Runtime_Bad_Block       0x0030   100   100   ---    Old_age   Offline      -       0
184 End-to-End_Error        0x0032   100   100   ---    Old_age   Always       -       0
187 Reported_Uncorrect      0x0032   100   100   ---    Old_age   Always       -       0
192 Unsafe_Shutdown_Count   0x0032   100   100   ---    Old_age   Always       -       1
199 UDMA_CRC_Error_Count    0x0030   100   100   ---    Old_age   Offline      -       0
225 Host_Writes_32MiB       0x0032   100   100   ---    Old_age   Always       -       17887
226 Workld_Media_Wear_Indic 0x0032   100   100   ---    Old_age   Always       -       20
227 Workld_Host_Reads_Perc  0x0032   100   100   ---    Old_age   Always       -       94
228 Workload_Minutes        0x0032   100   100   ---    Old_age   Always       -       116
232 Available_Reservd_Space 0x0033   100   100   ---    Pre-fail  Always       -       0
233 Media_Wearout_Indicator 0x0032   100   100   ---    Old_age   Always       -       0
241 Host_Writes_32MiB       0x0032   100   100   ---    Old_age   Always       -       17887
242 Host_Reads_32MiB        0x0032   100   100   ---    Old_age   Always       -       3

SMART Error Log Version: 1
No Errors Logged

SMART Self-test log structure revision number 1
No self-tests have been logged.  [To run self-tests, use: smartctl -t]


Note: selective self-test log revision number (0) not 1 implies that no selective self-test has ever been run
SMART Selective self-test log data structure revision number 0
Note: revision number not 1 implies that no selective self-test has ever been run
 SPAN  MIN_LBA  MAX_LBA  CURRENT_TEST_STATUS
    1        0        0  Not_testing
    2        0        0  Not_testing
    3        0        0  Not_testing
    4        0        0  Not_testing
    5        0        0  Not_testing
Selective self-test flags (0x0):
  After scanning selected spans, do NOT read-scan remainder of disk.
If Selective self-test is pending on power-up, resume after 0 minute delay.

# hdparm -I /dev/sdc

/dev/sdc:

ATA device, with non-removable media
 Model Number:       INTEL SSDSA2CW600G3                     
 Serial Number:      CVPR??????????????  
 Firmware Revision:  4PC10362
 Transport:          Serial, ATA8-AST, SATA 1.0a, SATA II Extensions, SATA Rev 2.5, SATA Rev 2.6
Standards:
 Used: unknown (minor revision code 0x0029) 
 Supported: 8 7 6 5 
 Likely used: 8
Configuration:
 Logical  max current
 cylinders 16383 16383
 heads  16 16
 sectors/track 63 63
 --
 CHS current addressable sectors:   16514064
 LBA    user addressable sectors:  268435455
 LBA48  user addressable sectors: 1172123568
 Logical  Sector size:                   512 bytes
 Physical Sector size:                   512 bytes
 device size with M = 1024*1024:      572325 MBytes
 device size with M = 1000*1000:      600127 MBytes (600 GB)
 cache/buffer size  = unknown
 Nominal Media Rotation Rate: Solid State Device
Capabilities:
 LBA, IORDY(can be disabled)
 Queue depth: 32
 Standby timer values: spec'd by Standard, no device specific minimum
 R/W multiple sector transfer: Max = 16 Current = 16
 DMA: mdma0 mdma1 mdma2 udma0 udma1 udma2 udma3 udma4 udma5 *udma6 
      Cycle time: min=120ns recommended=120ns
 PIO: pio0 pio1 pio2 pio3 pio4 
      Cycle time: no flow control=120ns  IORDY flow control=120ns
Commands/features:
 Enabled Supported:
    * SMART feature set
      Security Mode feature set
    * Power Management feature set
    * Write cache
    * Look-ahead
    * Host Protected Area feature set
    * WRITE_BUFFER command
    * READ_BUFFER command
    * NOP cmd
    * DOWNLOAD_MICROCODE
      SET_MAX security extension
    * 48-bit Address feature set
    * Device Configuration Overlay feature set
    * Mandatory FLUSH_CACHE
    * FLUSH_CACHE_EXT
    * SMART error logging
    * SMART self-test
    * General Purpose Logging feature set
    * WRITE_{DMA|MULTIPLE}_FUA_EXT
    * 64-bit World wide name
    * IDLE_IMMEDIATE with UNLOAD
    * WRITE_UNCORRECTABLE_EXT command
    * {READ,WRITE}_DMA_EXT_GPL commands
    * Segmented DOWNLOAD_MICROCODE
    * Gen1 signaling speed (1.5Gb/s)
    * Gen2 signaling speed (3.0Gb/s)
    * Native Command Queueing (NCQ)
    * Phy event counters
      Device-initiated interface power management
    * Software settings preservation
    * SMART Command Transport (SCT) feature set
    * SCT LBA Segment Access (AC2)
    * SCT Error Recovery Control (AC3)
    * SCT Features Control (AC4)
    * SCT Data Tables (AC5)
    * Data Set Management TRIM supported
    * reserved 69[5]
    * Deterministic read after TRIM
Security: 
 Master password revision code = 65534
  supported
 not enabled
 not locked
 not frozen
 not expired: security count
  supported: enhanced erase
 2min for SECURITY ERASE UNIT. 2min for ENHANCED SECURITY ERASE UNIT.
Logical Unit WWN Device Identifier: 5001517bb28?????
 NAA  : 5
 IEEE OUI : 001517
 Unique ID : bb28?????
Integrity word not set (found 0x0000, expected 0x4fa5)


おそらくは、ゼロ書き込みによるデータ消去後であろう?とは思いましたが、せっかくの機会 (中古SSDは初挑戦) なので、オールゼロになっているのか確認してみたところ、SSD 上に残っていた文字列は、次の3行のみでした。
Delete End
2012/09/21/11:46:19
某ショップの会社名
さて、それなら SecureErase を実施したほうが、性能上良いはずなので、実際やりました。
# cat /sys/block/sdc/device/model 
INTEL SSDSA2CW60

# hdparm --user-master u --security-set-pass password /dev/sdc
security_password="password"

/dev/sdc:
 Issuing SECURITY_SET_PASS command, password="password", user=user, mode=high
# hdparm --user-master u --security-erase-enhanced password /dev/sdc
security_password="password"

/dev/sdc:
 Issuing SECURITY_ERASE command, password="password", user=user
SecureErase は1分ぐらい (ちょっとよそ見している間) で終わってしまいました。

ちなみに、Win7 上の Intel SSD Toolbox も試してみたのですが、わたしの環境では、どうしても frozen 状態が解除できず、実行できませんでした。

ThinkPad T510 に eSATA 接続の環境ですが、Toolbox の指示に従って、eSATA の先の SSD 電源を落としたり、刺しなおしたりしてみましたが、ダメでした。それなのに、デュアルブートにしてある CentOS6 では、frozen にはならず、簡単に SecureErase できました。

■関連記事
SecureErase を実施してみた
SecureErase のために frozen 状態を解除する方法

2012年11月24日土曜日

ZVOL を KVM ゲストに割り当てる

CentOS 6 + ZFS on Linux 0.6.0-rc12 において、ZVOL を KVM ゲストに割り当てる実験をしてみました。

目当ては、スパースボリューム (sparse volume) です。次は、man zfs(8) からの抜粋です。
           Though not recommended, a "sparse volume" (also known as "thin pro-
           visioning") can be created by specifying the -s option to  the  zfs
           create  -V command, or by changing the reservation after the volume
           has been created. A "sparse volume" is a volume where the  reserva-
           tion is less then the volume size. Consequently, writes to a sparse
           volume can fail with ENOSPC when the pool is low on  space.  For  a
           sparse volume, changes to volsize are not reflected in the reserva-
           tion.
スパースボリュームを作成するには、zfs create -V の際、同時に -s オプションを指定します。
# zfs create -s -V 30G tank1/zvol
# ls -l /dev/zvol/tank1/zvol 
lrwxrwxrwx 1 root root 9 Nov 24 10:46 /dev/zvol/tank1/zvol -> ../../zd0
# ls -l /dev/zd0 
brw-rw---- 1 qemu qemu 230, 0 Nov 24 11:03 /dev/zd0
# grep zd0 /proc/partitions 
 230        0   31457280 zd0
この zvol を KVM ゲストに割り当てて、CentOS 6.3 をインストールした直後のディスク消費量は次の通りです。なお、インストールオプションには、Software Development Workstation を選択しています。
# zfs list
NAME         USED  AVAIL  REFER  MOUNTPOINT
tank1       5.25G  53.3G   156K  /tank1
tank1/zvol  5.24G  53.3G  5.24G  -
# zfs get all tank1/zvol
NAME        PROPERTY              VALUE                  SOURCE
tank1/zvol  type                  volume                 -
tank1/zvol  creation              Sat Nov 24 10:01 2012  -
tank1/zvol  used                  5.24G                  -
tank1/zvol  available             53.3G                  -
tank1/zvol  referenced            5.24G                  -
tank1/zvol  compressratio         1.00x                  -
tank1/zvol  reservation           none                   default
tank1/zvol  volsize               30G                    local
tank1/zvol  volblocksize          8K                     -
tank1/zvol  checksum              on                     default
tank1/zvol  compression           off                    default
tank1/zvol  readonly              off                    default
tank1/zvol  copies                1                      default
tank1/zvol  refreservation        none                   default
tank1/zvol  primarycache          all                    default
tank1/zvol  secondarycache        all                    default
tank1/zvol  usedbysnapshots       0                      -
tank1/zvol  usedbydataset         5.24G                  -
tank1/zvol  usedbychildren        0                      -
tank1/zvol  usedbyrefreservation  0                      -
tank1/zvol  logbias               latency                default
tank1/zvol  dedup                 off                    default
tank1/zvol  mlslabel              none                   default
tank1/zvol  sync                  standard               default
tank1/zvol  refcompressratio      1.00x                  -
tank1/zvol  written               5.24G                  -
ZFS プールの空きや KVM ゲストのディスク使用量を気にかける必要はありますが、こんな具合にディスク消費量を節約できました。もっとも、節約だけであれば、スパースファイルでも同じことであり、実際、ext4 上にスパースファイルとして同様にインストールすると、ほぼ同じ消費量になります。
# df -Th /
Filesystem    Type    Size  Used Avail Use% Mounted on
/dev/sda6     ext4     20G   16G  2.5G  87% /
# ls -lsh /var/lib/libvirt/images/cent6vm64.img 
5.2G -rw-------. 1 root root 12G Aug 19 15:47 /var/lib/libvirt/images/cent6vm64.img
ZVOL を使う利点は、ZFS の豊富な機能 (compression, dedup, secondarycache, スナップショット) をゲスト毎に使い分けられる点ではないかと思います。また、運用上、スパースファイル方式よりも分かり易い (zfs list で各ゲストへの分配状況を俯瞰できる) かなとも思います。

ちなみに、LVM2 にも同様の機能を組み込もうとして、開発途上の模様です。CentOS 6 の man lvcreate(8) より抜粋です。
       -T, --thin, --thinpool ThinPoolLogicalVolume{Name|Path}
              Creates  thin  pool  or thin logical volume or both.  Specifying
              the optional argument --size will cause the creation of the thin
              pool  logical volume.  Specifying the optional argument --virtu-
              alsize will cause the creation of the thin logical  volume  from
              given  thin  pool  volume.  Specifying both arguments will cause
              the creation of both thin pool and thin volume using this  pool.
              Requires  device mapper kernel driver for thin provisioning from
              kernel 3.2 or newer.  Note: Thin types are currently  considered
              Tech  Preview.   For  more information on Tech Preview features,
              visit: https://access.redhat.com/support/offerings/techpreview/.
LVM2 (device-mapper) を使うと、運用が煩雑になる印象があるのですが、おそらくは、ZVOL より性能は上 (レイヤ増によるオーバーヘッドが少ない) だろうと思いますし、将来の選択肢として、頭の片隅に。

2012-11-25追記
さらに、compression による効果を試しました。zvol の compression プロパティを on にしてから、ゲストの CentOS 6.3 をインストールした結果です。
# zfs set compression=on tank1/zvol
... このあとで、ゲストをインストール ...
# zfs list
NAME         USED  AVAIL  REFER  MOUNTPOINT
tank1       3.60G  55.0G   156K  /tank1
tank1/zvol  3.60G  55.0G  3.60G  -
# zfs get all tank1/zvol
NAME        PROPERTY              VALUE                  SOURCE
tank1/zvol  type                  volume                 -
tank1/zvol  creation              Sat Nov 24 14:38 2012  -
tank1/zvol  used                  3.60G                  -
tank1/zvol  available             55.0G                  -
tank1/zvol  referenced            3.60G                  -
tank1/zvol  compressratio         1.76x                  -
tank1/zvol  reservation           none                   default
tank1/zvol  volsize               30G                    local
tank1/zvol  volblocksize          8K                     -
tank1/zvol  checksum              on                     default
tank1/zvol  compression           on                     local
tank1/zvol  readonly              off                    default
tank1/zvol  copies                1                      default
tank1/zvol  refreservation        none                   default
tank1/zvol  primarycache          all                    default
tank1/zvol  secondarycache        all                    default
tank1/zvol  usedbysnapshots       0                      -
tank1/zvol  usedbydataset         3.60G                  -
tank1/zvol  usedbychildren        0                      -
tank1/zvol  usedbyrefreservation  0                      -
tank1/zvol  logbias               latency                default
tank1/zvol  dedup                 off                    default
tank1/zvol  mlslabel              none                   default
tank1/zvol  sync                  standard               default
tank1/zvol  refcompressratio      1.76x                  -
tank1/zvol  written               3.60G                  -
圧縮により 1.64G ほどディスク消費を節約できています。
compression プロパティは、いつでも変更可能であり、ゲストのインストール時やアップデート時のみ、compression=on にして、ゲストの通常運用時には、compressoin=off にしておくといった使い方も可能です。

2012-12-06追記
重複排除 (dedup) についても、試してみました。zvol01 および zvol02 を用意して、dedup=verify を設定してから、各 zvol をそれぞれ KVM ゲストに割り当てて、CentOS 6.3 をインストールした場合の結果です。
# grep tank1/zvol01 /etc/libvirt/qemu/cent6zvol01.xml 
      <source dev='/dev/zvol/tank1/zvol01'/>
# grep tank1/zvol02 /etc/libvirt/qemu/cent6zvol02.xml 
      <source dev='/dev/zvol/tank1/zvol02'/>
# zfs get compression
NAME          PROPERTY     VALUE     SOURCE
tank1         compression  off       default
tank1/zvol01  compression  off       default
tank1/zvol02  compression  off       default
# zfs get dedup
NAME          PROPERTY  VALUE          SOURCE
tank1         dedup     off            default
tank1/zvol01  dedup     verify         local
tank1/zvol02  dedup     verify         local
# zfs list
NAME           USED  AVAIL  REFER  MOUNTPOINT
tank1         11.5G  51.4G   156K  /tank1
tank1/zvol01  5.60G  51.4G  5.60G  -
tank1/zvol02  5.52G  51.4G  5.52G  -
# zpool list
NAME    SIZE  ALLOC   FREE    CAP  DEDUP  HEALTH  ALTROOT
tank1  59.5G  7.10G  52.4G    11%  1.68x  ONLINE  -
重複排除により 4G ほど削減できています。重複排除は zpool の括りで行われるようで、効果確認は zpool コマンドで行います。
dedup プロパティについても、いつでも変更可能なので、インストール時だけ dedup=verify にして、通常運用時は dedup=off という使い方も可能です。ここでは試しませんでしたが、compression=on との同時利用も可能です。
人気ブログランキングへ にほんブログ村 IT技術ブログへ