綾小路龍之介の素人思考

[linux] HDDのGPTパーティション作成とフォーマット

3TBのHDDを1パーティションで利用するにはfdiskでは作成できないgptパーティションが必要。これはgpartedで作成。ext3ファイルシステムを作成するまでの記録。

パーティション情報の削除とちょっとしたベンチマーク。

# dd if=/dev/zero of=/dev/sdz bs=512 count=1
1+0 records in
1+0 records out
512 bytes (512 B) copied, 0.00312751 s, 164 kB/s
# dd if=/dev/zero of=/dev/sdz bs=100M count=10
10+0 records in
10+0 records out
1048576000 bytes (1.0 GB) copied, 81.2974 s, 12.9 MB/s

partedでgptパーティションを作成し、作成したパーティションを確認

# parted /dev/sdz
GNU Parted 2.3
Using /dev/sdz
Welcome to GNU Parted! Type 'help' to view a list of
commands.
(parted) mklabel gpt
(parted) unit s
(parted) mkpart primary ext3 2048s -1s
Warning: You requested a partition from 2048s to 5860533167s.
The closest location we can manage is 2048s to 5860533134s.
Is this still acceptable to you?
Yes/No? Yes
(parted) align-check optimal 1
1 aligned
(parted) print
Model: ATA WDC WD30EZRX-00D (scsi)
Disk /dev/sdz: 5860533168s
Sector size (logical/physical): 512B/4096B
Partition Table: gpt

Number  Start  End          Size         File system  Name
Flags
 1      2048s  5860533134s  5860531087s
primary

(parted) quit
Information: You may need to update /etc/fstab.

このHDDは物理セクタのサイズが4096バイトで、論理セクタのサイズが512バイト。4096バイトの物理セクタをソフトウェアによって512バイトの論理セクタに変換して読み書きが行われている。このようなAFT(512e)対応ディスクのパフォーマンスを発揮させるには、パーティションの開始位置を4096バイト(8論理セクタ、1物理セクタ)の倍数にしておく。2048 論理セクタにしてあるのは、windowsのパーティションツールにあわせて。

旧来のfdiskでも確認は可能。gptパーティションの作成はできない。

# fdisk -l /dev/sdz

WARNING: GPT (GUID Partition Table) detected on '/dev/sdz'!
The util fdisk doesn't support GPT. Use GNU Parted.


Disk /dev/sdz: 3000.6 GB, 3000592982016 bytes
255 heads, 63 sectors/track, 364801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x00000000

   Device Boot      Start         End      Blocks   Id
System
/dev/sdz1               1      267350  2147483647+  ee  GPT
Partition 1 does not start on physical sector boundary.

mkfsでext3ファイルシステムを作成。timeで時間測定すると、3TBでも17分程度。

# time mkfs -t ext3 /dev/sdz1
mke2fs 1.42.5 (29-Jul-2012)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
183148544 inodes, 732566385 blocks
36628319 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=0
22357 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
        4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968,
        102400000, 214990848, 512000000, 550731776, 644972544

Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information:
done


real    17m19.657s
user    0m27.718s
sys     7m41.249s

mkfsコマンドに-cオプションを2回渡すと破壊的読み書きテストを行うことができる。破壊的読み書きテストを行うと飛躍的に時間が延びる。約4.5日間程度。

# time mkfs -t ext3 -c -c /dev/sdz1
mke2fs 1.42.5 (29-Jul-2012)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
183148544 inodes, 732566385 blocks
36628319 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=0
22357 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
        4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968,
        102400000, 214990848, 512000000, 550731776, 644972544

Testing with pattern 0xaa: done
Reading and comparing: done
Testing with pattern 0x55: done
Reading and comparing: done
Testing with pattern 0xff: done
Reading and comparing: done
Testing with pattern 0x00: done
Reading and comparing: done
Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done


real    6309m18.468s
user    507m23.319s
sys     609m4.104s

ブロックサイズなどを見るには以下 tune2fs も dumpe2fs も使えるけど、dumpe2fs の方が情報が多い。ブロックサイズは物理セクタサイズと同じバイト数にするといいんじゃないかな? (パフォーマンス的な意味で)

# tune2fs -l /dev/sdz1
# dumpe2fs -h /dev/sdz1
# diff <(dumpe2fs -h /dev/sdz1) <(tune2fs -l /dev/sdz1)
dumpe2fs 1.42.12 (29-Aug-2014)
0a1
> tune2fs 1.42.12 (29-Aug-2014)
45,50d45
< Journal features:         journal_incompat_revoke
< Journal size:             128M
< Journal length:           32768
< Journal sequence:         0x00475a9b
< Journal start:            16652
<

hddの状態によって、ファイルシステムの作成時間の比較に影響を与えると思われるので、最後にhdparmで状況確認。

# hdparm -i /dev/sdz

/dev/sdz:

 Model=WDC WD30EZRX-00DC0B0, FwRev=80.00A80, SerialNo=***************
 Config={ HardSect NotMFM HdSw>15uSec SpinMotCtl Fixed DTR>5Mbs FmtGapReq }
 RawCHS=16383/16/63, TrkSize=0, SectSize=0, ECCbytes=0
 BuffType=unknown, BuffSize=unknown, MaxMultSect=16, MultSect=16
 CurCHS=16383/16/63, CurSects=16514064, LBA=yes, LBAsects=5860533168
 IORDY=on/off, tPIO={min:120,w/IORDY:120}, tDMA={min:120,rec:120}
 PIO modes:  pio0 pio3 pio4
 DMA modes:  mdma0 mdma1 mdma2
 UDMA modes: udma0 udma1 udma2 udma3 udma4 *udma5 udma6
 AdvancedPM=no WriteCache=enabled
 Drive conforms to: Unspecified:  ATA/ATAPI-1,2,3,4,5,6,7

 * signifies the current active mode

# hdparm -Tt /dev/sd?

/dev/sda:
 Timing cached reads:   328 MB in  2.01 seconds = 163.15 MB/sec
 Timing buffered disk reads: 264 MB in  3.01 seconds =  87.70 MB/sec

/dev/sdb:
 Timing cached reads:   326 MB in  2.01 seconds = 162.29 MB/sec
 Timing buffered disk reads: 258 MB in  3.00 seconds =  85.97 MB/sec

/dev/sdc:
 Timing cached reads:   326 MB in  2.00 seconds = 162.91 MB/sec
 Timing buffered disk reads: 240 MB in  3.02 seconds =  79.46 MB/sec

/dev/sdd:
 Timing cached reads:   328 MB in  2.00 seconds = 163.72 MB/sec
 Timing buffered disk reads: 234 MB in  3.02 seconds =  77.49 MB/sec

/dev/sde:
 Timing cached reads:   214 MB in  2.01 seconds = 106.62 MB/sec
 Timing buffered disk reads:   6 MB in  5.61 seconds =   1.07 MB/sec

/dev/sdf:
 Timing cached reads:   326 MB in  2.00 seconds = 162.98 MB/sec
 Timing buffered disk reads: 234 MB in  3.02 seconds =  77.57 MB/sec

/dev/sdg:
 Timing cached reads:   306 MB in  2.00 seconds = 152.71 MB/sec
 Timing buffered disk reads:  46 MB in  3.01 seconds =  15.30 MB/sec

# hdparm -Tt /dev/sd?

/dev/sda:
 Timing cached reads:   322 MB in  2.01 seconds = 160.28 MB/sec
 Timing buffered disk reads: 232 MB in  3.02 seconds =  76.85 MB/sec

/dev/sdb:
 Timing cached reads:   306 MB in  2.00 seconds = 152.94 MB/sec
 Timing buffered disk reads: 240 MB in  3.00 seconds =  79.91 MB/sec

/dev/sdc:
 Timing cached reads:   308 MB in  2.01 seconds = 153.12 MB/sec
 Timing buffered disk reads: 232 MB in  3.02 seconds =  76.90 MB/sec

/dev/sdd:
 Timing cached reads:   318 MB in  2.00 seconds = 158.83 MB/sec
 Timing buffered disk reads: 264 MB in  3.02 seconds =  87.48 MB/sec

/dev/sde:
 Timing cached reads:   318 MB in  2.00 seconds = 158.69 MB/sec
 Timing buffered disk reads: 264 MB in  3.01 seconds =  87.82 MB/sec

/dev/sdf:
 Timing cached reads:   324 MB in  2.01 seconds = 161.48 MB/sec
 Timing buffered disk reads:  64 MB in  5.10 seconds =  12.55 MB/sec

/dev/sdg:
 Timing cached reads:   300 MB in  2.01 seconds = 149.57 MB/sec
 Timing buffered disk reads:  48 MB in  3.12 seconds =  15.36 MB/sec

/etc/fstabに適当なエントリを追加。書き込みできるユーザ向けにオーナーを変更。

# cat <<EOT >> /etc/fstab
UUID=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX       /path/to/mount/point       ext3    defaults        0       1
EOT
# mount /path/to/mount/point
# chown ******:****** /path/to/mount/point
$ df -aT /path/to/mount/point
Filesystem     Type  1K-blocks   Used  Available Use% Mounted on
*********      ext3 2884284060 205940 2737564844   1% /path/to/mount/point

リファレンス

  1. Man page of MKFS
  2. parted(8): partition change program - Linux man page
  3. Man page of HDPARM
  4. 4KB セクター・ディスクで Linux を使用する: 実用的なアドバイス

ソーシャルブックマーク

  1. はてなブックマーク
  2. Google Bookmarks
  3. del.icio.us

ChangeLog

  1. Posted: 2010-07-03T05:30:46+09:00
  2. Modified: 2010-07-03T05:30:46+09:00
  3. Generated: 2017-04-29T23:09:20+09:00