LVM
하드디스크 3개를 추가 하고
fdisk -l 명령어를 통해 장치를 확인 한다.
[root@test01 ~]# fdisk -l
Disk /dev/hda: 10.4 GB, 10485760000 bytes
255 heads, 63 sectors/track, 1274 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/hda1 * 1 13 104391 83 Linux
/dev/hda2 14 274 2096482+ 82 Linux swap / Solaris
/dev/hda3 275 1274 8032500 83 Linux
Disk /dev/hdb: 104 MB, 104857600 bytes
255 heads, 63 sectors/track, 12 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/hdb doesn't contain a valid partition table
Disk /dev/hdd: 104 MB, 104857600 bytes
255 heads, 63 sectors/track, 12 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/hdd doesn't contain a valid partition table
Disk /dev/vda: 104 MB, 104857600 bytes
16 heads, 63 sectors/track, 203 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes
Disk /dev/vda doesn't contain a valid partition table
[root@test01 ~]#
-----------------------------------
/dev/hdb
/dev/hdd
/dev/vda
3개의 hdd 가 추가 된것을 확인 할수 있다.
-----------------------------------
/dev/hdb 장치에 파티션을 만든다
파티션 타입은 Linux LVM 으로 바꾼다.
[root@test01 ~]# fdisk /dev/hdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that, of course, the previous
content won't be recoverable.
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-12, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-12, default 12):
Using default value 12
Command (m for help): t
Selected partition 1
Hex code (type L to list codes): L
0 Empty 1e Hidden W95 FAT1 80 Old Minix bf Solaris
1 FAT12 24 NEC DOS 81 Minix / old Lin c1 DRDOS/sec (FAT-
2 XENIX root 39 Plan 9 82 Linux swap / So c4 DRDOS/sec (FAT-
3 XENIX usr 3c PartitionMagic 83 Linux c6 DRDOS/sec (FAT-
4 FAT16 <32M 40 Venix 80286 84 OS/2 hidden C: c7 Syrinx
5 Extended 41 PPC PReP Boot 85 Linux extended da Non-FS data
6 FAT16 42 SFS 86 NTFS volume set db CP/M / CTOS / .
7 HPFS/NTFS 4d QNX4.x 87 NTFS volume set de Dell Utility
8 AIX 4e QNX4.x 2nd part 88 Linux plaintext df BootIt
9 AIX bootable 4f QNX4.x 3rd part 8e Linux LVM e1 DOS access
a OS/2 Boot Manag 50 OnTrack DM 93 Amoeba e3 DOS R/O
b W95 FAT32 51 OnTrack DM6 Aux 94 Amoeba BBT e4 SpeedStor
c W95 FAT32 (LBA) 52 CP/M 9f BSD/OS eb BeOS fs
e W95 FAT16 (LBA) 53 OnTrack DM6 Aux a0 IBM Thinkpad hi ee EFI GPT
f W95 Ext'd (LBA) 54 OnTrackDM6 a5 FreeBSD ef EFI (FAT-12/16/
10 OPUS 55 EZ-Drive a6 OpenBSD f0 Linux/PA-RISC b
11 Hidden FAT12 56 Golden Bow a7 NeXTSTEP f1 SpeedStor
12 Compaq diagnost 5c Priam Edisk a8 Darwin UFS f4 SpeedStor
14 Hidden FAT16 <3 61 SpeedStor a9 NetBSD f2 DOS secondary
16 Hidden FAT16 63 GNU HURD or Sys ab Darwin boot fb VMware VMFS
17 Hidden HPFS/NTF 64 Novell Netware b7 BSDI fs fc VMware VMKCORE
18 AST SmartSleep 65 Novell Netware b8 BSDI swap fd Linux raid auto
1b Hidden W95 FAT3 70 DiskSecure Mult bb Boot Wizard hid fe LANstep
1c Hidden W95 FAT3 75 PC/IX be Solaris boot ff BBT
Hex code (type L to list codes): 8e
Changed system type of partition 1 to 8e (Linux LVM)
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: Re-reading the partition table failed with error 16: 장치나 자원이 동작 중.
The kernel still uses the old table.
The new table will be used at the next reboot.
Syncing disks.
---------
/dev/hdd
---------
[root@test01 ~]# fdisk /dev/hdd
Command (m for help): p
Disk /dev/hdd: 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
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-12, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-12, default 12):
Using default value 12
Command (m for help): t
Selected partition 1
Hex code (type L to list codes): 8e
Changed system type of partition 1 to 8e (Linux LVM)
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
[root@test01 ~]#
------------
/dev/vda
------------
[root@test01 ~]# fdisk /dev/vda
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that, of course, the previous
content won't be recoverable.
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-203, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-203, default 203):
Using default value 203
Command (m for help): t
Selected partition 1
Hex code (type L to list codes): 8e
Changed system type of partition 1 to 8e (Linux LVM)
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
[root@test01 ~]#
------------------------------------------------
[root@test01 ~]# fdisk -l
Disk /dev/hda: 10.4 GB, 10485760000 bytes
255 heads, 63 sectors/track, 1274 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/hda1 * 1 13 104391 83 Linux
/dev/hda2 14 274 2096482+ 82 Linux swap / Solaris
/dev/hda3 275 1274 8032500 83 Linux
Disk /dev/hdb: 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/hdb1 1 12 96358+ 8e Linux LVM
Disk /dev/hdd: 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/hdd1 1 12 96358+ 8e Linux LVM
Disk /dev/vda: 104 MB, 104857600 bytes
16 heads, 63 sectors/track, 203 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes
Device Boot Start End Blocks Id System
/dev/vda1 1 203 102280+ 8e Linux LVM
[root@test01 ~]#
--------------------------------
pvcreate 명령어로 pv 를 생성해 준다.
--------------------------------
[root@test01 ~]# pvcreate /dev/hdb1
Physical volume "/dev/hdb1" successfully created
[root@test01 ~]# pvcreate /dev/hdd1
Physical volume "/dev/hdd1" successfully created
[root@test01 ~]# pvcreate /dev/vda1
Physical volume "/dev/vda1" successfully created
[root@test01 ~]#
PV (physical Volume : 물리적 볼륨) 정보 확인
생성한 물리적 볼륨에 대한 정보를 확인 하는 것은 pvdisplay 명령어로 확인한다.
------------
pvdisplay
------------
[root@test01 ~]# pvdisplay
/dev/hdc: open failed: 매개물이 없음
"/dev/vda1" is a new physical volume of "99.88 MB"
--- NEW Physical volume ---
PV Name /dev/vda1
VG Name
PV Size 99.88 MB
Allocatable NO
PE Size (KByte) 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID X0Wfni-xewX-Itan-uIcX-iH8P-4whO-Eh8yFd
"/dev/hdb1" is a new physical volume of "94.10 MB"
--- NEW Physical volume ---
PV Name /dev/hdb1
VG Name
PV Size 94.10 MB
Allocatable NO
PE Size (KByte) 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID wNdRe9-gpBJ-LLAC-W1wv-5xmu-bcl1-O28Rl6
"/dev/hdd1" is a new physical volume of "94.10 MB"
--- NEW Physical volume ---
PV Name /dev/hdd1
VG Name
PV Size 94.10 MB
Allocatable NO
PE Size (KByte) 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID 8mSdlc-m7XO-aPq0-OBur-cxpH-g89N-4rV6ve
[root@test01 ~]#
pvdisplay [device_name] 로 device 만 검색 할수 있다.
[root@test01 ~]# pvdisplay /dev/hdb1
"/dev/hdb1" is a new physical volume of "94.10 MB"
--- NEW Physical volume ---
PV Name /dev/hdb1
VG Name
PV Size 94.10 MB
Allocatable NO
PE Size (KByte) 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID wNdRe9-gpBJ-LLAC-W1wv-5xmu-bcl1-O28Rl6
--------------------------------
VG(Volume Group : 볼륨 그룹) 생성
--------------------------------
vgcreate 명령어를 이용해 vg를 생성해 주어야 한다.
vgcreate [VG 구룹명] [device_name] pv1 pv2 ..
vgcreate vg0 /dev/hdb1 /dev/hdd1 /dev/vda1
[root@test01 ~]# vgcreate vg0 /dev/hdb1 /dev/hdd1 /dev/vda1
Volume group "vg0" successfully created
hdb1 hdd1 vda1 을 vg0 으로 만든다.
VG (Volume Group : 볼륨 구룹 ) 활성화
불륨 그룹 VG를 사용하기 위하여 활성화 시켜 주어야 합니다. VG 의 활성화는 vgchange 명령어를 이용합니다.
vgchange -a [y|n] [VG 구룹명]
y는 활성화 n 은 비활성화를 의미
vgchange -a y vg0
0 logical volume(s) in colume group "vg0" now active
---------------
VG 정보 확인
---------------
[root@test01 ~]# vgdisplay -v vg0
Using volume group(s) on command line
Finding volume group "vg0"
--- Volume group ---
VG Name vg0
System ID
Format lvm2
Metadata Areas 3
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 3
Act PV 3
VG Size 280.00 MB
PE Size 4.00 MB
Total PE 70
Alloc PE / Size 0 / 0
Free PE / Size 70 / 280.00 MB
VG UUID dhbL2A-1Bwr-ij1X-Eo6i-99H2-KTKQ-t38YNp
--- Physical volumes ---
PV Name /dev/hdb1
PV UUID wNdRe9-gpBJ-LLAC-W1wv-5xmu-bcl1-O28Rl6
PV Status allocatable
Total PE / Free PE 23 / 23
PV Name /dev/hdd1
PV UUID 8mSdlc-m7XO-aPq0-OBur-cxpH-g89N-4rV6ve
PV Status allocatable
Total PE / Free PE 23 / 23
PV Name /dev/vda1
PV UUID X0Wfni-xewX-Itan-uIcX-iH8P-4whO-Eh8yFd
PV Status allocatable
Total PE / Free PE 24 / 24
[root@test01 ~]#
--------------------------------------
LV (logical volume : 논리적 볼륨) : 셍성
--------------------------------------
lvcreate 명령어를 이용하여 lv 를 생성해 주어야 한다.
사용방법
lvcreate -L [size] -n [논리볼륨명] VG
lvcreate -l [PE개수] -n [논리적볼륨명]
lvcreate -L 200M -n data1 vg0
[root@test01 ~]# lvcreate -L 200M -n data1 vg0
Logical volume "data1" created
vgdisplay 명령어로 vg0 의 남은 용량을 체크 할수 있다
[root@test01 ~]# vgdisplay -v vg0
Using volume group(s) on command line
Finding volume group "vg0"
--- Volume group ---
VG Name vg0
System ID
Format lvm2
Metadata Areas 3
Metadata Sequence No 2
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 1
Open LV 0
Max PV 0
Cur PV 3
Act PV 3
VG Size 280.00 MB
PE Size 4.00 MB
Total PE 70
Alloc PE / Size 50 / 200.00 MB
Free PE / Size 20 / 80.00 MB
VG UUID dhbL2A-1Bwr-ij1X-Eo6i-99H2-KTKQ-t38YNp
--- Logical volume ---
LV Name /dev/vg0/data1
VG Name vg0
LV UUID WRdZRk-xpGC-JIfn-AUdy-5lSx-aeCG-5VdAdH
LV Write Access read/write
LV Status available
# open 0
LV Size 200.00 MB
Current LE 50
Segments 3
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:0
--- Physical volumes ---
PV Name /dev/hdb1
PV UUID wNdRe9-gpBJ-LLAC-W1wv-5xmu-bcl1-O28Rl6
PV Status allocatable
Total PE / Free PE 23 / 0
PV Name /dev/hdd1
PV UUID 8mSdlc-m7XO-aPq0-OBur-cxpH-g89N-4rV6ve
PV Status allocatable
Total PE / Free PE 23 / 20
PV Name /dev/vda1
PV UUID X0Wfni-xewX-Itan-uIcX-iH8P-4whO-Eh8yFd
PV Status allocatable
Total PE / Free PE 24 / 0
[root@test01 ~]#
-----------------------------------------
Using volume group(s) on command line
Finding volume group "vg0"
--- Volume group ---
Alloc PE / Size 50 / 200.00 MB
Free PE / Size 20 / 80.00 MB
-----------------------------------------
80MB 가 Free 사이즈 인것을 확인 할수 있다.
--- Logical volume ---
LV Name /dev/vg0/data1
VG Name vg0
LV UUID WRdZRk-xpGC-JIfn-AUdy-5lSx-aeCG-5VdAdH
LV Write Access read/write
LV Status available
# open 0
LV Size 200.00 MB
data1 에 200MB 가 추가 되어 있다.
나머지 용량 80M 전체를 data2 로 만든다.
[root@test01 ~]# lvcreate -l 100%FREE -n data2 vg0
Logical volume "data2" created
[root@test01 ~]# lvs
LV VG Attr LSize Origin Snap% Move Log Copy% Convert
data1 vg0 -wi-a- 200.00M
data2 vg0 -wi-a- 80.00M
파일 시스템 생성
mkfs -t ext3 /dev/vg0/data1
mkfs -t ext3 /dev/vg0/data2
mount 시킬 디렉토리 생성및
[root@test01 ~]# mkdir /data1
[root@test01 ~]# mkdir /data2
[root@test01 ~]# mount /dev/vg0/data1 /data1
[root@test01 ~]# mount /dev/vg0/data2 /data2
[root@test01 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/hda3 7.5G 4.1G 3.0G 59% /
/dev/hda1 99M 12M 82M 13% /boot
tmpfs 502M 0 502M 0% /dev/shm
/dev/mapper/vg0-data1
194M 5.6M 179M 4% /data1
------------------------------------------------------------
작성중
참고 사이트
http://docs.redhat.com/docs/ko-KR/Red_Hat_Enterprise_Linux/6/html/Logical_Volume_Manager_Administration/index.html
작성중
참고 사이트
http://docs.redhat.com/docs/ko-KR/Red_Hat_Enterprise_Linux/6/html/Logical_Volume_Manager_Administration/index.html