追加したディスクをLVMシステムで作成し、マウントまでを行う方法です。
検証した環境
$ cat /etc/os-release
NAME="AlmaLinux"
VERSION="8.7 (Stone Smilodon)"
ID="almalinux"
ID_LIKE="rhel centos fedora"
VERSION_ID="8.7"
PLATFORM_ID="platform:el8"
PRETTY_NAME="AlmaLinux 8.7 (Stone Smilodon)"
ANSI_COLOR="0;34"
LOGO="fedora-logo-icon"
CPE_NAME="cpe:/o:almalinux:almalinux:8::baseos"
HOME_URL="https://almalinux.org/"
DOCUMENTATION_URL="https://wiki.almalinux.org/"
BUG_REPORT_URL="https://bugs.almalinux.org/"
ALMALINUX_MANTISBT_PROJECT="AlmaLinux-8"
ALMALINUX_MANTISBT_PROJECT_VERSION="8.7"
REDHAT_SUPPORT_PRODUCT="AlmaLinux"
REDHAT_SUPPORT_PRODUCT_VERSION="8.7"
$ uname -r
4.18.0-425.3.1.el8.x86_64
追加ディスクとパーティション設定
追加したディスクが認識されているかを確認します。
$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 16G 0 disk
├sda1 8:1 0 600M 0 part /boot/efi
├sda2 8:2 0 1G 0 part /boot
└sda3 8:3 0 14.4G 0 part
├almalinux-root 253:0 0 12.8G 0 lvm /
└almalinux-swap 253:1 0 1.6G 0 lvm [SWAP]
sdb 8:16 0 16G 0 disk ・・・ 追加したディスク
sr0 11:0 1 1024M 0 rom
パーティションの設定を行います。
# gdisk /dev/sdb
GPT fdisk (gdisk) version 1.0.3
Warning: Partition table header claims that the size of partition table
entries is 0 bytes, but this program supports only 128-byte entries.
Adjusting accordingly, but partition table may be garbage.
Warning: Partition table header claims that the size of partition table
entries is 0 bytes, but this program supports only 128-byte entries.
Adjusting accordingly, but partition table may be garbage.
Partition table scan:
MBR: not present
BSD: not present
APM: not present
GPT: not present
Creating new GPT entries.
Command (? for help): ? ・・・ コマンドの一覧表示
b back up GPT data to a file
c change a partition's name
d delete a partition
i show detailed information on a partition
l list known partition types
n add a new partition
o create a new empty GUID partition table (GPT)
p print the partition table
q quit without saving changes
r recovery and transformation options (experts only)
s sort partitions
t change a partition's type code
v verify disk
w write table to disk and exit
x extra functionality (experts only)
? print this menu
Command (? for help): p ・・・ パーティションテーブル表示
Disk /dev/sdb: 33554432 sectors, 16.0 GiB
Model: Virtual disk
Sector size (logical/physical): 512/512 bytes
Disk identifier (GUID): 2E764A43-0BE1-42F2-BB92-CE04B6CE08D9
Partition table holds up to 128 entries
Main partition table begins at sector 2 and ends at sector 33
First usable sector is 34, last usable sector is 33554398
Partitions will be aligned on 2048-sector boundaries
Total free space is 33554365 sectors (16.0 GiB)
Number Start (sector) End (sector) Size Code Name
Command (? for help): l ・・・ パーティションの種類一覧
0700 Microsoft basic data 0c01 Microsoft reserved 2700 Windows RE
3000 ONIE boot 3001 ONIE config 3900 Plan 9
4100 PowerPC PReP boot 4200 Windows LDM data 4201 Windows LDM metadata
4202 Windows Storage Spac 7501 IBM GPFS 7f00 ChromeOS kernel
7f01 ChromeOS root 7f02 ChromeOS reserved 8200 Linux swap
8300 Linux filesystem 8301 Linux reserved 8302 Linux /home
8303 Linux x86 root (/) 8304 Linux x86-64 root (/ 8305 Linux ARM64 root (/)
8306 Linux /srv 8307 Linux ARM32 root (/) 8400 Intel Rapid Start
8e00 Linux LVM a000 Android bootloader a001 Android bootloader 2
a002 Android boot a003 Android recovery a004 Android misc
a005 Android metadata a006 Android system a007 Android cache
a008 Android data a009 Android persistent a00a Android factory
a00b Android fastboot/ter a00c Android OEM a500 FreeBSD disklabel
a501 FreeBSD boot a502 FreeBSD swap a503 FreeBSD UFS
a504 FreeBSD ZFS a505 FreeBSD Vinum/RAID a580 Midnight BSD data
a581 Midnight BSD boot a582 Midnight BSD swap a583 Midnight BSD UFS
a584 Midnight BSD ZFS a585 Midnight BSD Vinum a600 OpenBSD disklabel
a800 Apple UFS a901 NetBSD swap a902 NetBSD FFS
a903 NetBSD LFS a904 NetBSD concatenated a905 NetBSD encrypted
a906 NetBSD RAID ab00 Recovery HD af00 Apple HFS/HFS+
af01 Apple RAID af02 Apple RAID offline af03 Apple label
af04 AppleTV recovery af05 Apple Core Storage af06 Apple SoftRAID Statu
af07 Apple SoftRAID Scrat af08 Apple SoftRAID Volum af09 Apple SoftRAID Cache
b300 QNX6 Power-Safe bc00 Acronis Secure Zone be00 Solaris boot
bf00 Solaris root bf01 Solaris /usr & Mac Z bf02 Solaris swap
bf03 Solaris backup bf04 Solaris /var bf05 Solaris /home
bf06 Solaris alternate se bf07 Solaris Reserved 1 bf08 Solaris Reserved 2
bf09 Solaris Reserved 3 bf0a Solaris Reserved 4 bf0b Solaris Reserved 5
c001 HP-UX data c002 HP-UX service e100 ONIE boot
e101 ONIE config ea00 Freedesktop $BOOT eb00 Haiku BFS
ed00 Sony system partitio ed01 Lenovo system partit ef00 EFI System
ef01 MBR partition scheme ef02 BIOS boot partition f800 Ceph OSD
f801 Ceph dm-crypt OSD f802 Ceph journal f803 Ceph dm-crypt journa
f804 Ceph disk in creatio f805 Ceph dm-crypt disk i fb00 VMWare VMFS
fb01 VMWare reserved fc00 VMWare kcore crash p fd00 Linux RAID
Command (? for help): n ・・・ 新しいパーティションの作成
Partition number (1-128, default 1): ・・・ [Enter]キー
First sector (34-33554398, default = 2048) or {+-}size{KMGTP}: ・・・ [Enter]キー
Last sector (2048-33554398, default = 33554398) or {+-}size{KMGTP}: ・・・ [Enter]キー
Current type is 'Linux filesystem'
Hex code or GUID (L to show codes, Enter = 8300): 8e00 ・・・ LinuxLVM
Changed type of partition to 'Linux LVM'
Command (? for help): p ・・・ パーティションテーブル表示
Disk /dev/sdb: 33554432 sectors, 16.0 GiB
Model: Virtual disk
Sector size (logical/physical): 512/512 bytes
Disk identifier (GUID): 2E764A43-0BE1-42F2-BB92-CE04B6CE08D9
Partition table holds up to 128 entries
Main partition table begins at sector 2 and ends at sector 33
First usable sector is 34, last usable sector is 33554398
Partitions will be aligned on 2048-sector boundaries
Total free space is 2014 sectors (1007.0 KiB)
Number Start (sector) End (sector) Size Code Name
1 2048 33554398 16.0 GiB 8E00 Linux LVM
Command (? for help): w ・・・ パーティションテーブルの書き込み
Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
PARTITIONS!!
Do you want to proceed? (Y/N): Y ・・・ 続行してもよいか?「Y」応答
OK; writing new GUID partition table (GPT) to /dev/sdb.
The operation has completed successfully.
パーティションが出来ているかを確認します。
$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 16G 0 disk
├sda1 8:1 0 600M 0 part /boot/efi
├sda2 8:2 0 1G 0 part /boot
└sda3 8:3 0 14.4G 0 part
├almalinux-root 253:0 0 12.8G 0 lvm /
└almalinux-swap 253:1 0 1.6G 0 lvm [SWAP]
sdb 8:16 0 16G 0 disk
└sdb1 8:17 0 16G 0 part
sr0 11:0 1 1024M 0 rom
LVMの論理ボリューム作成
作成したパーティションにLVMの論理ボリュームを作成します。
物理ボリューム(PV)の作成
作成したパーティションを指定して、物理ボリュームを作成します。
# pvcreate /dev/sdb1
Physical volume "/dev/sdb1" successfully created.
# pvdisplay /dev/sdb1
"/dev/sdb1" is a new physical volume of "<16.00 GiB"
--- NEW Physical volume ---
PV Name /dev/sdb1
VG Name
PV Size <16.00 GiB
Allocatable NO
PE Size 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID 9frlSL-vkJR-P42E-ZXXP-7nIc-2BJB-1rx9nj
ボリュームグループ(VG)の作成
作成した物理ボリューム全体を1つのボリュームグループとして作成します。
# vgcreate VG01 /dev/sdb1
Volume group "VG01" successfully created
# vgdisplay VG01
--- Volume group ---
VG Name VG01
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 <16.00 GiB
PE Size 4.00 MiB
Total PE 4095
Alloc PE / Size 0 / 0
Free PE / Size 4095 / <16.00 GiB
VG UUID f9Tjrn-wIUJ-xDsA-5SCu-C11n-C6Lq-G4zjwg
論理ボリュームの作成
作成したボリュームグループ上で、10GiB分の論理ボリュームを作成します。
# lvcreate -l +2560 -n lvtest VG01 ・・・ 10240MiB / 4MiB = 2560
Logical volume "lvtest" created.
# lvdisplay /dev/VG01/lvtest
--- Logical volume ---
LV Path /dev/VG01/lvtest
LV Name lvtest
VG Name VG01
LV UUID SHmGvq-XE3N-5Bos-fn6E-oVnB-5gbm-fQrrox
LV Write Access read/write
LV Creation host, time test, 2023-02-26 01:34:32 +0900
LV Status available
# open 0
LV Size 10.00 GiB
Current LE 2560
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 253:2
ファイルシステムの作成
RHEL標準のxfsファイルシステムで作成します。
製品によっては、ext4に限定しているものもあるようですので、注意してください。
# mkfs -t xfs /dev/VG01/lvtest
meta-data=/dev/VG01/lvtest isize=512 agcount=4, agsize=655360 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=1, sparse=1, rmapbt=0
= reflink=1 bigtime=0 inobtcount=0
data = bsize=4096 blocks=2621440, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0, ftype=1
log =internal log bsize=4096 blocks=2560, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
マウントポイントの作成と自動マウント
マウントポイントの作成を行います。
# mkdir /test
# mount /dev/VG01/lvtest /test
# df /test
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/mapper/VG01-lvtest 10475520 106088 10369432 2% /test
UUIDを確認します。
# blkid /dev/VG01/lvtest
/dev/VG01/lvtest: UUID="a35f7c04-74fc-48e8-a7bd-1574dff0fe77" TYPE="xfs"
自動マウントの設定を行います。
# cp -a /etc/fstab /etc/BK-fstab.20230226 ・・・ バックアップを取得
# /etc/fstab
#
# /etc/fstab
# Created by anaconda on Sun Feb 19 19:19:01 2023
#
# 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.
#
# After editing this file, run 'systemctl daemon-reload' to update systemd
# units generated from this file.
#
UUID=94f9f433-bd6e-4ee7-9e92-4d386230f4c2 / xfs defaults 0 0
UUID=27c30734-1f80-4bb3-a29a-d2e5ca11b2c9 /boot xfs defaults 0 0
UUID=6202-75DA /boot/efi vfat umask=0077,shortname=winnt 0 2
UUID=1fba21d9-9439-4c53-9f18-27d6f8d68843 none swap defaults 0 0
UUID=a35f7c04-74fc-48e8-a7bd-1574dff0fe77 /test xfs defaults 0 0 ・・・ 追記
自動でマウントが行われるかをマシンリブートで確認します。
# systemctl reboot