LVMシステム上で、ファイルシステム(ext4)を作成してマウントします。
検証した環境
$ cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 11 (bullseye)"
NAME="Debian GNU/Linux"
VERSION_ID="11"
VERSION="11 (bullseye)"
VERSION_CODENAME=bullseye
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"
$ uname -r
5.15.56-v8+
マウントポイント用のディレクトリー作成
「/data」に対してマウントをするために、ディレクトリーを作成します。
$ sudo mkdir /data
$ ls -ld /data
drwxr-xr-x 2 root root 4096 Oct 10 18:06 /data
LV(Logical Volume:論理ボリューム)の作成
LV(論理ボリューム)を既存のVGに作成します。
$ sudo lvcreate -n lvdata -L 20g rootvg ・・・ VG(rootvg)にLV(lvdata)を20GiBで作成
$ sudo lvdisplay /dev/rootvg/lvdata ・・・ 確認
--- Logical volume ---
LV Path /dev/rootvg/lvdata
LV Name lvdata
VG Name rootvg
LV UUID xxxxxx-xxxx-xxxx-xxxx-xxxx-xxxx-xxxxxx
LV Write Access read/write
LV Creation host, time xxxxxxxx, 2022-10-10 17:19:06 +0900
LV Status available
# open 0
LV Size 20.00 GiB
Current LE 5120
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 254:8
ファイルシステム(ext4)の作成
$ sudo mkfs -t ext4 /dev/rootvg/lvdata
mke2fs 1.46.2 (28-Feb-2021)
Creating filesystem with 5242880 4k blocks and 1310720 inodes
Filesystem UUID: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000
Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
マウントの確認
マウントができるかを確認します。
$ sudo mount /dev/rootvg/lvdata /data
$ df -T /data
Filesystem Type 1K-blocks Used Available Use% Mounted on
/dev/mapper/rootvg-lvdata ext4 20466256 24 19401272 1% /data
自動マウントの設定
マシンリブートをしても、自動でマウントが出来るようにします。
$ cd /etc
$ sudo cp -a fstab BK-fstab.20221010
$ vi /etc/fstab
proc /proc proc defaults 0 0
PARTUUID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx /boot vfat defaults 0 2
/dev/rootvg/lvroot / ext4 defaults,noatime 0 1
/dev/rootvg/lvswap none swap sw 0 0
/dev/rootvg/lvdata /data ext4 defaults 0 0