1383 文字
7 分
Ubuntu 19にてLVMでディスクを追加

新規にディスクをぶっ刺した上で、OS上で認識されているディスクのラベルを探します

root@dell ~/a/storcli_all_os# fdisk -l
Disk /dev/loop0: 54.9 MiB, 57532416 bytes, 112368 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/loop1: 89.1 MiB, 93417472 bytes, 182456 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/loop2: 89.1 MiB, 93429760 bytes, 182480 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/sda: 836.6 GiB, 898319253504 bytes, 1754529792 sectors
Disk model: RAID 5/6 SAS 6G
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: A0B1AE4D-C4FF-4FDB-90F1-53AD283B479A
Device Start End Sectors Size Type
/dev/sda1 2048 1050623 1048576 512M EFI System
/dev/sda2 1050624 2549759 1499136 732M Linux filesystem
/dev/sda3 2549760 1754527743 1751977984 835.4G Linux LVM
Disk /dev/sdb: 1.8 TiB, 1999844147200 bytes, 3905945600 sectors
Disk model: RAID 5/6 SAS 6G
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk /dev/mapper/dell--vg-root: 834.5 GiB, 895974637568 bytes, 1749950464 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk /dev/mapper/dell--vg-swap_1: 976 MiB, 1023410176 bytes, 1998848 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes

新しく追加したディスクは、容量から察するに/dev/sdbということがわかります。Disk model: RAID 5/6 SAS 6Gと書いてある理由は謎です。Raid1のはずですが。しかも、OSには隠蔽されているはずなのに。一元的にRaidコントローラが表示してしまっているだけなのかもしれません。

partedでパーティションを切っておきます。

パーティション単位ではなく、ディスク自体をPhysical Volumeとして追加できるのですが、ぶっ壊れたときに復元しやすくなるはずなので、パーティションを作ります。

root@dell ~/a/storcli_all_os# parted /dev/sdb
GNU Parted 3.2
Using /dev/sdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) mkpart primary 0
Error: /dev/sdb: unrecognised disk label
(parted) help
align-check TYPE N check partition N for TYPE(min|opt) alignment
help [COMMAND] print general help, or help on COMMAND
mklabel,mktable LABEL-TYPE create a new disklabel (partition table)
mkpart PART-TYPE [FS-TYPE] START END make a partition
name NUMBER NAME name partition NUMBER as NAME
print [devices|free|list,all|NUMBER] display the partition table, available devices, free space, all found partitions, or a particular partition
quit exit program
rescue START END rescue a lost partition near START and END
resizepart NUMBER END resize partition NUMBER
rm NUMBER delete partition NUMBER
select DEVICE choose the device to edit
disk_set FLAG STATE change the FLAG on selected device
disk_toggle [FLAG] toggle the state of FLAG on selected device
set NUMBER FLAG STATE change the FLAG on partition NUMBER
toggle [NUMBER [FLAG]] toggle the state of FLAG on partition NUMBER
unit UNIT set the default unit to UNIT
version display the version number and copyright information of GNU Parted
(parted)

Ubuntu 19で作られるVGはGPT対応で作られているようなので、新しいディスクもGPT対応にしておきます。

(parted) mklabel gpt

では、パーティションを作成します。パーセントで表記したほうが確実です。

(parted) mkpart
Partition name? []?
File system type? [ext2]?
Start? 0%
End? 100%
(parted) p
Model: LSI RAID 5/6 SAS 6G (scsi)
Disk /dev/sdb: 1999844MB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
1 1.05MB 1999843MB 1999842MB ext2
(parted)

物理ディスクは準備できたので、次はLVMの設定。まず、Phisical Volumeを作ります。

Terminal window
root@dell ~/a/storcli_all_os# pvcreate /dev/sdb1
WARNING: ext4 signature detected on /dev/sdb1 at offset 1080. Wipe it? [y/n]: y
Wiping ext4 signature on /dev/sdb1.
Physical volume "/dev/sdb1" successfully created.
root@dell ~/a/storcli_all_os# pvs
PV VG Fmt Attr PSize PFree
/dev/sda3 dell-vg lvm2 a-- <835.41g 12.00m
/dev/sdb1 lvm2 --- <1.82t <1.82t

次に、Logical Volumeを作ります。

Terminal window
root@dell ~/a/storcli_all_os# vgcreate data-vg /dev/sdb1
Volume group "data-vg" successfully created
root@dell ~/a/storcli_all_os# vgdisplay
--- Volume group ---
VG Name dell-vg
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 3
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV 2
Max PV 0
Cur PV 1
Act PV 1
VG Size <835.41 GiB
PE Size 4.00 MiB
Total PE 213864
Alloc PE / Size 213861 / 835.39 GiB
Free PE / Size 3 / 12.00 MiB
VG UUID jqTTRM-hZOZ-uT9x-9ke5-bAuw-78dI-RI3xZf
--- Volume group ---
VG Name data-vg
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 1
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 0
Open LV 0
Max PV 0
Cur PV 1
Act PV 1
VG Size <1.82 TiB
PE Size 4.00 MiB
Total PE 476799
Alloc PE / Size 0 / 0
Free PE / Size 476799 / <1.82 TiB
VG UUID NUtldx-SilL-6GHG-9eAZ-5rdN-oPxr-6XlhmK

Logical Volumeを作ります。

Terminal window
# lvcreate -n data -l 100%FREE data-vg

次に、フォーマット。他のパーティションがext4なので、それに続きます。

root@dell ~/a/storcli_all_os# mkfs.ext4 /dev/data-vg/data
mke2fs 1.44.6 (5-Mar-2019)
Creating filesystem with 488242176 4k blocks and 122060800 inodes
Filesystem UUID: eb6cb760-73e3-4fd0-8453-66383c3ac4b9
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968,
102400000, 214990848
Allocating group tables: done
Writing inode tables: done
Creating journal (262144 blocks): done
Writing superblocks and filesystem accounting information: done
root@dell ~/a/storcli_all_os# mkdir /mnt/data
root@dell ~/a/storcli_all_os# mount /dev/data-vg/data /mnt/data
root@dell ~/a/storcli_all_os# df -h|grep data
/dev/mapper/data--vg-data 1.8T 77M 1.7T 1% /mnt/data

一応ベンチマーク。SATAのraid10がdata。SASのRaid5 2台に比べると4倍くらい遅い。SATA遅すぎ。デスクトップワークステーションを買うならSASがよさげ。

Terminal window
root@dell ~# hdparm -t /dev/mapper/data--vg-data
/dev/mapper/data--vg-data:
SG_IO: bad/missing sense data, sb[]: 70 00 05 00 00 00 00 0d 00 00 00 00 20 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
Timing buffered disk reads: 684 MB in 3.00 seconds = 227.99 MB/sec
root@dell ~# hdparm -t /dev/mapper/dell--vg-root
/dev/mapper/dell--vg-root:
SG_IO: bad/missing sense data, sb[]: 70 00 05 00 00 00 00 0d 00 00 00 00 20 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
Timing buffered disk reads: 1636 MB in 3.00 seconds = 545.06 MB/sec

独り言#

物理ハードディスクから、OSでディスクを扱うまでに抽象化がたくさん入っていて設定が面倒!昔は物理ディスクをそのままマウントしていたのに。そのぶん、自由度は高いですがね。まとめると以下。

  • 物理ディスク
  • Raidコントローラによる物理ディスクの仮想化
  • OSによるPhysical Volumeによる仮想化
  • OSによるLogical Volumeによる仮想化
  • OSによってLogical Volumeのマウント
Ubuntu 19にてLVMでディスクを追加
https://blog.teraren.com/posts/lvmでディスクを追加/
作者
Yuki Matsukura
公開日
2019-12-21
ライセンス
CC BY-NC-SA 4.0

コメント