LVM extend
초기 hdd 2개로 구성된 lvm 에..
2개의 hdd 추가 후 lvm extend 설정
참고 페이지
http://docs.redhat.com/docs/ko-KR/Red_Hat_Enterprise_Linux/6/html/Logical_Volume_Manager_Administration/lv_extend.html
[root@test01 ~]# fdisk -l
Disk /dev/sda: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 274 2096482+ 82 Linux swap / Solaris
/dev/sda3 275 1305 8281507+ 83 Linux
Disk /dev/sdb: 104 MB, 104857600 bytes
255 heads, 63 sectors/track, 12 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/sdb doesn't contain a valid partition table
Disk /dev/sdc: 209 MB, 209715200 bytes
255 heads, 63 sectors/track, 25 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/sdc doesn't contain a valid partition table
Disk /dev/sdd: 314 MB, 314572800 bytes
255 heads, 63 sectors/track, 38 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/sdd doesn't contain a valid partition table
/dev/sdb
/dev/sdc
1. pv생성
2. vg생성
3. lv생성
1. pv 생성
[root@test01 ~]# pvcreate /dev/sdb1
Physical volume "/dev/sdb1" successfully created
[root@test01 ~]# pvcreate /dev/sdc1
Physical volume "/dev/sdc1" successfully created
[root@test01 ~]#
- 확인
[root@test01 ~]# pvs
/dev/hdc: open failed: No medium found
PV VG Fmt Attr PSize PFree
/dev/sdb1 lvm2 a- 94.10M 94.10M
/dev/sdc1 lvm2 a- 196.08M 196.08M
2. vg 생성
[root@test01 ~]# vgcreate --help
vgcreate: Create a volume group
vgcreate
[-A|--autobackup {y|n}]
[--addtag Tag]
[--alloc AllocationPolicy]
[-c|--clustered {y|n}]
[-d|--debug]
[-h|--help]
[-l|--maxlogicalvolumes MaxLogicalVolumes]
[-M|--metadatatype 1|2]
[--[vg]metadatacopies #copies]
[-p|--maxphysicalvolumes MaxPhysicalVolumes]
[-s|--physicalextentsize PhysicalExtentSize[bBsSkKmMgGtTpPeE]]
[-t|--test]
[-v|--verbose]
[--version]
[ PHYSICAL DEVICE OPTIONS ]
VolumeGroupName PhysicalDevicePath [PhysicalDevicePath...]
[root@test01 ~]#
[root@test01 ~]# vgcreate vg0 /dev/sdb1 /dev/sdc1
Volume group "vg0" successfully created
[root@test01 ~]# vgs
VG #PV #LV #SN Attr VSize VFree
vg0 2 0 0 wz--n- 284.00M 284.00M
[root@test01 ~]# lvcreate -l 100%FREE -n data vg0
Logical volume "data" created
[root@test01 ~]# lvs
LV VG Attr LSize Origin Snap% Move Log Copy% Convert
data vg0 -wi-a- 284.00M
파티션 ext3 로 포맷
[root@test01 ~]# mkfs -t ext3 /dev/vg0/data
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
72864 inodes, 290816 blocks
14540 blocks (5.00%) reserved for the super user
First data block=1
Maximum filesystem blocks=67633152
36 block groups
8192 blocks per group, 8192 fragments per group
2024 inodes per group
Superblock backups stored on blocks:
8193, 24577, 40961, 57345, 73729, 204801, 221185
Writing inode tables: done
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 25 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
마운트할 디렉토리 생성
[root@test01 ~]# mkdir /data
디렉토리에 마운트
[root@test01 ~]# mount /dev/vg0/data /data
df 로 마운트 된 장치및 용량 확인
[root@test01 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 7.7G 3.5G 3.9G 48% /
/dev/sda1 99M 12M 83M 13% /boot
tmpfs 506M 0 506M 0% /dev/shm
/dev/mapper/vg0-data 276M 11M 251M 4% /data
------------------------------------------------------------------------
VG 확장
1. fdisk
2. vgextend
[root@test01 ~]# fdisk -l
Disk /dev/sda: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 274 2096482+ 82 Linux swap / Solaris
/dev/sda3 275 1305 8281507+ 83 Linux
Disk /dev/sdb: 104 MB, 104857600 bytes
255 heads, 63 sectors/track, 12 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 1 12 96358+ 8e Linux LVM
Disk /dev/sdc: 209 MB, 209715200 bytes
255 heads, 63 sectors/track, 25 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdc1 1 25 200781 8e Linux LVM
Disk /dev/sdd: 314 MB, 314572800 bytes
255 heads, 63 sectors/track, 38 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/sdd doesn't contai unixODBC-devel-2.2.11-7.1.x86_64.rpmn a valid partition table
Disk /dev/sde: 104 MB, 104857600 bytes
255 heads, 63 sectors/track, 12 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/sde doesn't contain a valid partition table
fdisk 이용 LVM 으로 바꿔 주고.
---------------------------------------------------------------
Disk /dev/sdd: 314 MB, 314572800 bytes
255 heads, 63 sectors/track, 38 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdd1 1 38 305203+ 8e Linux LVM
Disk /dev/sde: 104 MB, 104857600 bytes
255 heads, 63 sectors/track, 12 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sde1 1 12 96358+ 8e Linux LVM
[root@test01 ~]# pvs
PV VG Fmt Attr PSize PFree
/dev/sdb1 vg0 lvm2 a- 92.00M 0
/dev/sdc1 vg0 lvm2 a- 192.00M 0
/dev/sdd1 lvm2 a- 298.05M 298.05M
/dev/sde1 lvm2 a- 94.10M 94.10M
[root@test01 ~]#
[root@test01 ~]# vgextend vg0 /dev/sdd1
Volume group "vg0" successfully extended
[root@test01 ~]# vgextend vg0 /dev/sde1
Volume group "vg0" successfully extended
[root@test01 ~]# vgs
VG #PV #LV #SN Attr VSize VFree
vg0 4 1 0 wz--n- 672.00M 388.00M
lvextend
lvs 로 지금 만들어져 있는 lv size 를 확인 한다.
[root@test01 ~]# lvs
LV VG Attr LSize Origin Snap% Move Log Copy% Convert
data vg0 -wi-a- 284.00M
lvextend 명령어를 이용하여 추가적으로 vgextend 한 용량을 확장 한다.
[root@test01 ~]# lvextend -l +100%FREE /dev/vg0/data
Extending logical volume data to 672.00 MB
Logical volume data successfully resized
lvs 로 확장한 용량을 확인 할수 있다.
[root@test01 ~]# lvs
LV VG Attr LSize Origin Snap% Move Log Copy% Convert
data vg0 -wi-a- 672.00M
논리 볼륨 삭제 (LV 논리 볼륨)
1. 마운트가 되어 있다면 마운트를 해지 한다.
2. lvremove 명령어를 이용하여 lv 를 삭제 한다.
[root@test01 ~]# lvremove /dev/vg0/data
Do you really want to remove active logical volume data? [y/n]: y
Logical volume "data" successfully removed
[root@test01 ~]# lvs
[root@test01 ~]#
lv가 삭제 된것을 확인할수 있다.
vg 삭제
root@test01 ~]# pvs
PV VG Fmt Attr PSize PFree
/dev/sdb1 vg0 lvm2 a- 92.00M 92.00M
/dev/sdc1 vg0 lvm2 a- 192.00M 192.00M
/dev/sdd1 vg0 lvm2 a- 296.00M 296.00M
/dev/sde1 vg0 lvm2 a- 92.00M 92.00M
[root@test01 ~]# vgremove vg0
Volume group "vg0" successfully removed
[root@test01 ~]# pvs
PV VG Fmt Attr PSize PFree
/dev/sdb1 lvm2 a- 94.10M 94.10M
/dev/sdc1 lvm2 a- 196.08M 196.08M
/dev/sdd1 lvm2 a- 298.05M 298.05M
/dev/sde1 lvm2 a- 94.10M 94.10M
[root@test01 ~]# vgcreate vg0 /dev/sdb1 /dev/sdc1 /dev/sdd1 /dev/sde1
용량에 따른 lv 설정
vg0 의 용량을 100% 사용하여 lv를 생성
lvcreate -l 100%FREE -n test02 vg0
vg0 의 용량 30% 사용하여 test0 용량을 생성
[root@test01 ~]# lvcreate -l 30%FREE -n test0 vg0
Logical volume "test0" created
[root@test01 ~]# lvs
LV VG Attr LSize Origin Snap% Move Log Copy% Convert
test0 vg0 -wi-a- 200.00M
[root@test01 ~]# vgs
VG #PV #LV #SN Attr VSize VFree
vg0 4 1 0 wz--n- 672.00M 472.00M
[root@test01 ~]#
vg0 의 용량 100MB 만 사용하여 test1 생성
[root@test01 ~]# lvcreate -L +100M -n test1 vg0
Logical volume "test1" created
[root@test01 ~]# lvs
LV VG Attr LSize Origin Snap% Move Log Copy% Convert
test0 vg0 -wi-a- 200.00M
test1 vg0 -wi-a- 100.00M