물리디스크를 Volume 그룹으로 묶고 Logical Volume으로 분할 관리하는 기술입니다.
아래는 따라할수 있게 할수 있는 명령어 정리입니다.
VMware에서 하드디스크를 2개 추가해 작업진행하시면 됩니다.
저는 CentOS7.9로 했습니다.
[root@localhost ~]# fdisk /dev/sdf
Welcome to fdisk (util-linux 2.23.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Device does not contain a recognized partition table
Building a new DOS disklabel with disk identifier 0xbb9a27d4.
Command (m for help): n
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p): #enter
Using default response p
Partition number (1-4, default 1):#enter
First sector (2048-2097151, default 2048): #enter
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-2097151, default 2097151): #enter
Using default value 2097151
Partition 1 of type Linux and of size 1023 MiB is set
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
[root@localhost ~]# fdisk /dev/sdf
Welcome to fdisk (util-linux 2.23.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Command (m for help): t
Selected partition 1
Hex code (type L to list all codes): 8e
Changed type of partition 'Linux' to 'Linux LVM'
Command (m for help): p
Disk /dev/sdf: 1073 MB, 1073741824 bytes, 2097152 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 label type: dos
Disk identifier: 0xbb9a27d4
Device Boot Start End Blocks Id System
/dev/sdf1 2048 2097151 1047552 8e Linux LVM
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
#fdisk /dev/sde도 위와 같이 진행해준다.
[root@localhost ~]# pvcreate /dev/sde1
Physical volume "/dev/sde1" successfully created.
[root@localhost ~]# pvcreate /dev/sdf1
Physical volume "/dev/sdf1" successfully created.
[root@localhost ~]# blkid
/dev/sda1: UUID="e4e6f6d7-f885-517f-78c2-c2823cd06cee" UUID_SUB="fc4ccd90-e929-53ea-9ce1-ac5a4348512c" LABEL="localhost:root" TYPE="linux_raid_member"
/dev/sda2: UUID="f617973b-5dd0-6db5-63e6-96cfef25305a" UUID_SUB="2f5c75a3-d8c5-52d2-91b5-7601b8c6adb5" LABEL="localhost:swap" TYPE="linux_raid_member"
/dev/sdb1: UUID="e4e6f6d7-f885-517f-78c2-c2823cd06cee" UUID_SUB="bdc3bf82-2987-5b8b-220a-b0bf16ccec26" LABEL="localhost:root" TYPE="linux_raid_member"
/dev/sdb2: UUID="f617973b-5dd0-6db5-63e6-96cfef25305a" UUID_SUB="486f08af-6b22-9519-c08b-30b5daf8738f" LABEL="localhost:swap" TYPE="linux_raid_member"
/dev/sdc1: UUID="3c382a5e-77c6-3f78-4d25-ff3a611a82fa" UUID_SUB="5a7629ab-7323-76ab-095a-4bf658699d1c" LABEL="localhost.localdomain:1" TYPE="linux_raid_member"
/dev/sdd1: UUID="3c382a5e-77c6-3f78-4d25-ff3a611a82fa" UUID_SUB="d49fd1c0-a9ed-3b17-e35a-4cab9319f142" LABEL="localhost.localdomain:1" TYPE="linux_raid_member"
/dev/md127: UUID="a39e5c54-04dd-4a84-8b0b-5fe38623a37c" TYPE="swap"
/dev/md126: UUID="ad60c1ea-c410-4db2-a16c-683218d3cf9d" TYPE="xfs"
/dev/md1: UUID="b1f304ea-f1d3-42b7-9f8a-6bf1768ef2bf" TYPE="ext4"
/dev/sde1: UUID="fhHhNg-Sf9k-maNu-0B6p-99dh-dyuC-B71SR0" TYPE="LVM2_member"
/dev/sdf1: UUID="VMpXXd-kvAt-vw7a-haBB-wKuC-n3hc-pGnOMc" TYPE="LVM2_member"
[root@localhost ~]# vgcreate VG /dev/sde1 /dev/sdf1
Volume group "VG" successfully created
[root@localhost ~]# vgdisplay
--- Volume group ---
VG Name VG
System ID
Format lvm2
Metadata Areas 2
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 2
Act PV 2
VG Size 1.99 GiB
PE Size 4.00 MiB
Total PE 510
Alloc PE / Size 0 / 0
Free PE / Size 510 / 1.99 GiB
VG UUID KfF1Yz-KlHt-4OTm-CRmt-aIPb-yMdp-EGLJ3w
[root@localhost ~]# lvcreate -L 1.98GB -n LV VG
Rounding up size to full physical extent 1.98 GiB
Logical volume "LV" created.
[root@localhost ~]# lvscan
ACTIVE '/dev/VG/LV' [1.98 GiB] inherit
[root@localhost ~]# mkfs.xfs /dev/VG/LV
meta-data=/dev/VG/LV isize=512 agcount=4, agsize=129792 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=0, sparse=0
data = bsize=4096 blocks=519168, 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
[root@localhost ~]# blkid
/dev/sda1: UUID="e4e6f6d7-f885-517f-78c2-c2823cd06cee" UUID_SUB="fc4ccd90-e929-53ea-9ce1-ac5a4348512c" LABEL="localhost:root" TYPE="linux_raid_member"
/dev/sda2: UUID="f617973b-5dd0-6db5-63e6-96cfef25305a" UUID_SUB="2f5c75a3-d8c5-52d2-91b5-7601b8c6adb5" LABEL="localhost:swap" TYPE="linux_raid_member"
/dev/sdb1: UUID="e4e6f6d7-f885-517f-78c2-c2823cd06cee" UUID_SUB="bdc3bf82-2987-5b8b-220a-b0bf16ccec26" LABEL="localhost:root" TYPE="linux_raid_member"
/dev/sdb2: UUID="f617973b-5dd0-6db5-63e6-96cfef25305a" UUID_SUB="486f08af-6b22-9519-c08b-30b5daf8738f" LABEL="localhost:swap" TYPE="linux_raid_member"
/dev/sdc1: UUID="3c382a5e-77c6-3f78-4d25-ff3a611a82fa" UUID_SUB="5a7629ab-7323-76ab-095a-4bf658699d1c" LABEL="localhost.localdomain:1" TYPE="linux_raid_member"
/dev/sdd1: UUID="3c382a5e-77c6-3f78-4d25-ff3a611a82fa" UUID_SUB="d49fd1c0-a9ed-3b17-e35a-4cab9319f142" LABEL="localhost.localdomain:1" TYPE="linux_raid_member"
/dev/md127: UUID="a39e5c54-04dd-4a84-8b0b-5fe38623a37c" TYPE="swap"
/dev/md126: UUID="ad60c1ea-c410-4db2-a16c-683218d3cf9d" TYPE="xfs"
/dev/md1: UUID="b1f304ea-f1d3-42b7-9f8a-6bf1768ef2bf" TYPE="ext4"
/dev/sde1: UUID="fhHhNg-Sf9k-maNu-0B6p-99dh-dyuC-B71SR0" TYPE="LVM2_member"
/dev/sdf1: UUID="VMpXXd-kvAt-vw7a-haBB-wKuC-n3hc-pGnOMc" TYPE="LVM2_member"
/dev/mapper/VG-LV: UUID="adc6ff80-700e-4ed8-b071-ab4b908bbd32" TYPE="xfs"
[root@localhost ~]# mount /dev/VG/LV /VGTest
[root@localhost ~]# vi /etc/fstab
#
# /etc/fstab
# Created by anaconda on Thu Dec 9 10:18:26 2021
#
# 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
#
UUID=ad60c1ea-c410-4db2-a16c-683218d3cf9d / xfs defaults 0 0
UUID=a39e5c54-04dd-4a84-8b0b-5fe38623a37c swap swap defaults 0 0
#UUID=3c382a5e-77c63f78-4d25ff3a-611a82fa /test ext4 defaults 0 0
/dev/md1 /test ext4 defaults 0 0
/dev/VG/LV /VGTest xfs defaults 0 0
LVM증축하기
#disk추가후 동일한 선행 작업을 한다.
[root@localhost ~]# fdisk /dev/sdg
Welcome to fdisk (util-linux 2.23.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Device does not contain a recognized partition table
Building a new DOS disklabel with disk identifier 0xbb9a27d4.
Command (m for help): n
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p): #enter
Using default response p
Partition number (1-4, default 1):#enter
First sector (2048-2097151, default 2048): #enter
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-2097151, default 2097151): #enter
Using default value 2097151
Partition 1 of type Linux and of size 1023 MiB is set
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
[root@localhost ~]# fdisk /dev/sdg
Welcome to fdisk (util-linux 2.23.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Command (m for help): t
Selected partition 1
Hex code (type L to list all codes): 8e
Changed type of partition 'Linux' to 'Linux LVM'
Command (m for help): p
Disk /dev/sdg: 1073 MB, 1073741824 bytes, 2097152 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 label type: dos
Disk identifier: 0xbb9a27d4
Device Boot Start End Blocks Id System
/dev/sdg1 2048 2097151 1047552 8e Linux LVM
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
#새로운 disk를 확장등록 해줌.
[root@localhost ~]# vgextend VG /dev/sdg1
Physical volume "/dev/sdg1" successfully created.
Volume group "VG" successfully extended
[root@localhost ~]# vgdisplay
--- Volume group ---
VG Name VG
System ID
Format lvm2
Metadata Areas 3
Metadata Sequence No 3
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 1
Open LV 1
Max PV 0
Cur PV 3
Act PV 3
VG Size <2.99 GiB
PE Size 4.00 MiB
Total PE 765
Alloc PE / Size 507 / 1.98 GiB
Free PE / Size 258 / <1.01 GiB
VG UUID KfF1Yz-KlHt-4OTm-CRmt-aIPb-yMdp-EGLJ3w
[root@localhost ~]# lvextend -L 2.98GB /dev/VG/LV
Rounding size to boundary between physical extents: 2.98 GiB.
Size of logical volume VG/LV changed from 1.98 GiB (507 extents) to 2.98 GiB (763 extents).
Logical volume VG/LV successfully resized.
[root@localhost ~]# lvscan
ACTIVE '/dev/VG/LV' [2.98 GiB] inherit
[root@localhost ~]# xfs_growfs /dev/VG/LV
meta-data=/dev/mapper/VG-LV isize=512 agcount=4, agsize=129792 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=0 spinodes=0
data = bsize=4096 blocks=519168, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal bsize=4096 blocks=2560, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
data blocks changed from 519168 to 781312
댓글 영역