Opensourcetechブログ

OpensourcetechによるNGINX/Kubernetes/Zabbix/Neo4j/Linuxなどオープンソース技術に関するブログです。

CentOS7でLVMを構成する


LinuCエヴァンジェリストの鯨井貴博@opensourcetechです。

CentOS7でLVMを構成してインストールする方法に関するメモです。


20GB HDDを以下のように構成します。

/boot 1GB  
swap  1GB  
/ora  5GB  
/     残り全て  


パーティションを自分で構成するを選択し、完了とします。
f:id:opensourcetech:20201119095810p:plain:w400
f:id:opensourcetech:20201119101602p:plain:w400

+マークをクリックし、まず/boot(1,000MB)を作成。
ファイルシステムは、ext4にしています。
デバイスタイプは、/bootにはLVMは適用できないので、標準パーティションとします。
f:id:opensourcetech:20201119101726p:plain:w400
f:id:opensourcetech:20201119101838p:plain:w400
f:id:opensourcetech:20201119102206p:plain:w400

続いて、swap領域。
1,000MBにしました。
f:id:opensourcetech:20201119102333p:plain:w400
f:id:opensourcetech:20201119102441p:plain:w400
f:id:opensourcetech:20201119102721p:plain:w400

続いてアプリケーション用として/oraを5,000MB。
f:id:opensourcetech:20201119103600p:plain:w400
f:id:opensourcetech:20201119103749p:plain:w400

そして、残り全てを/にアサインします。
f:id:opensourcetech:20201119103837p:plain:w400
f:id:opensourcetech:20201119103929p:plain:w400

そして、左上にある完了変更を許可するをクリックします。
f:id:opensourcetech:20201119105100p:plain:w400

あとは、その他項目を設定しインストールすればOKですね。
f:id:opensourcetech:20201119105221p:plain:w400
f:id:opensourcetech:20201119105401p:plain:w400
f:id:opensourcetech:20201119110412p:plain:w400


再起動後、コンソールからLVM周りの確認。

[root@testcent7 ~]# df -h
ファイルシス                      サイズ  使用  残り 使用% マウント位置
devtmpfs                            908M     0  908M    0% /dev
tmpfs                               919M     0  919M    0% /dev/shm
tmpfs                               919M  8.6M  911M    1% /run
tmpfs                               919M     0  919M    0% /sys/fs/cgroup
/dev/mapper/centos_testcent7-root    13G  1.3G   11G   10% /
/dev/sda1                           969M  120M  783M   14% /boot
/dev/mapper/centos_testcent7-ora    4.7G   20M  4.5G    1% /ora
tmpfs                               184M     0  184M    0% /run/user/0

[root@testcent7 ~]# cat /etc/fstab

#
# /etc/fstab
# Created by anaconda on Thu Nov 19 10:53:23 2020
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
/dev/mapper/centos_testcent7-root /                       ext4    defaults        1 1
UUID=466bcb2f-24af-4dfb-8cf9-0543fc3aacd5 /boot                   ext4    defaults        1 2
/dev/mapper/centos_testcent7-ora /ora                    ext4    defaults        1 2
/dev/mapper/centos_testcent7-swap swap                    swap    defaults        0 0

[root@testcent7 ~]# mount
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime,seclabel)
proc on /proc type proc (rw,nosuid,nodev,noexec,relatime)
devtmpfs on /dev type devtmpfs (rw,nosuid,seclabel,size=929108k,nr_inodes=232277,mode=755)
securityfs on /sys/kernel/security type securityfs (rw,nosuid,nodev,noexec,relatime)
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev,seclabel)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,seclabel,gid=5,mode=620,ptmxmode=000)
tmpfs on /run type tmpfs (rw,nosuid,nodev,seclabel,mode=755)
tmpfs on /sys/fs/cgroup type tmpfs (ro,nosuid,nodev,noexec,seclabel,mode=755)
cgroup on /sys/fs/cgroup/systemd type cgroup (rw,nosuid,nodev,noexec,relatime,seclabel,xattr,release_agent=/usr/lib/systemd/systemd-cgroups-agent,name=systemd)
pstore on /sys/fs/pstore type pstore (rw,nosuid,nodev,noexec,relatime)
cgroup on /sys/fs/cgroup/memory type cgroup (rw,nosuid,nodev,noexec,relatime,seclabel,memory)
cgroup on /sys/fs/cgroup/hugetlb type cgroup (rw,nosuid,nodev,noexec,relatime,seclabel,hugetlb)
cgroup on /sys/fs/cgroup/pids type cgroup (rw,nosuid,nodev,noexec,relatime,seclabel,pids)
cgroup on /sys/fs/cgroup/cpuset type cgroup (rw,nosuid,nodev,noexec,relatime,seclabel,cpuset)
cgroup on /sys/fs/cgroup/cpu,cpuacct type cgroup (rw,nosuid,nodev,noexec,relatime,seclabel,cpuacct,cpu)
cgroup on /sys/fs/cgroup/net_cls,net_prio type cgroup (rw,nosuid,nodev,noexec,relatime,seclabel,net_prio,net_cls)
cgroup on /sys/fs/cgroup/freezer type cgroup (rw,nosuid,nodev,noexec,relatime,seclabel,freezer)
cgroup on /sys/fs/cgroup/devices type cgroup (rw,nosuid,nodev,noexec,relatime,seclabel,devices)
cgroup on /sys/fs/cgroup/perf_event type cgroup (rw,nosuid,nodev,noexec,relatime,seclabel,perf_event)
cgroup on /sys/fs/cgroup/blkio type cgroup (rw,nosuid,nodev,noexec,relatime,seclabel,blkio)
configfs on /sys/kernel/config type configfs (rw,relatime)
/dev/mapper/centos_testcent7-root on / type ext4 (rw,relatime,seclabel,data=ordered)
selinuxfs on /sys/fs/selinux type selinuxfs (rw,relatime)
debugfs on /sys/kernel/debug type debugfs (rw,relatime)
systemd-1 on /proc/sys/fs/binfmt_misc type autofs (rw,relatime,fd=34,pgrp=1,timeout=0,minproto=5,maxproto=5,direct,pipe_ino=11696)
mqueue on /dev/mqueue type mqueue (rw,relatime,seclabel)
hugetlbfs on /dev/hugepages type hugetlbfs (rw,relatime,seclabel)
/dev/sda1 on /boot type ext4 (rw,relatime,seclabel,data=ordered)
/dev/mapper/centos_testcent7-ora on /ora type ext4 (rw,relatime,seclabel,data=ordered)
tmpfs on /run/user/0 type tmpfs (rw,nosuid,nodev,relatime,seclabel,size=188196k,mode=700)



物理ボリューム(PV)の確認。

[root@testcent7 ~]# pvs
  PV         VG               Fmt  Attr PSize   PFree
  /dev/sda2  centos_testcent7 lvm2 a--  <19.02g    0
[root@testcent7 ~]# pvdisplay
  --- Physical volume ---
  PV Name               /dev/sda2
  VG Name               centos_testcent7
  PV Size               19.02 GiB / not usable 3.00 MiB
  Allocatable           yes (but full)
  PE Size               4.00 MiB
  Total PE              4869
  Free PE               0
  Allocated PE          4869
  PV UUID               5rYKa6-EGJF-qekg-MVKs-ervq-OB3a-Rda1Mh



ボリュームグループ(VG)の確認。

[root@testcent7 ~]# vgs
  VG               #PV #LV #SN Attr   VSize   VFree
  centos_testcent7   1   3   0 wz--n- <19.02g    0
[root@testcent7 ~]# vgdisplay
  --- Volume group ---
  VG Name               centos_testcent7
  System ID
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  4
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                3
  Open LV               3
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               <19.02 GiB
  PE Size               4.00 MiB
  Total PE              4869
  Alloc PE / Size       4869 / <19.02 GiB
  Free  PE / Size       0 / 0
  VG UUID               HGXu0n-72bU-OsB4-3HRz-yoZp-dOrH-c3OqNF



論理ボリューム(LV)の確認。

[root@testcent7 ~]# lvs
  LV   VG               Attr       LSize    Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  ora  centos_testcent7 -wi-ao----    4.88g
  root centos_testcent7 -wi-ao----   13.16g
  swap centos_testcent7 -wi-ao---- 1000.00m
[root@testcent7 ~]# lvdisplay
  --- Logical volume ---
  LV Path                /dev/centos_testcent7/root
  LV Name                root
  VG Name                centos_testcent7
  LV UUID                uKwexU-4F1B-eta6-VHqD-rg7P-FWab-a2asLy
  LV Write Access        read/write
  LV Creation host, time testcent7, 2020-11-19 10:53:21 +0900
  LV Status              available
  # open                 1
  LV Size                13.16 GiB
  Current LE             3369
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     8192
  Block device           253:0

  --- Logical volume ---
  LV Path                /dev/centos_testcent7/ora
  LV Name                ora
  VG Name                centos_testcent7
  LV UUID                pp1GY8-KZS1-Xhmt-5Geq-2MMu-pcZz-mLETpR
  LV Write Access        read/write
  LV Creation host, time testcent7, 2020-11-19 10:53:21 +0900
  LV Status              available
  # open                 1
  LV Size                4.88 GiB
  Current LE             1250
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     8192
  Block device           253:2

  --- Logical volume ---
  LV Path                /dev/centos_testcent7/swap
  LV Name                swap
  VG Name                centos_testcent7
  LV UUID                GQcEBY-hTXd-WdoA-XE0L-9wfr-R2sA-H9wUEO
  LV Write Access        read/write
  LV Creation host, time testcent7, 2020-11-19 10:53:22 +0900
  LV Status              available
  # open                 2
  LV Size                1000.00 MiB
  Current LE             250
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     8192
  Block device           253:1



これくらい確認しておけば、とりあえずはOKかと思います。

Opensourcetech by Takahiro Kujirai