* 관련용어 PV(physical Volume) : 실제로 나눈 파티션을 말함 (/dev/hda3) PE(physical Extents) : 일종의 블럭같은 것으로 실제 데이터가 저장되는 공간을 말함 1PE = 약 4MB VG(volume Group) : 물리적 볼륨이 모여서 하나의 VG를 이룸 LV(logical Volume) : 이 논리적 볼륨이 우리가 흔히 쓰는 정규파티션과 같음 -> 즉 피지컬볼륨을 하나로 묵어서 볼륨구룹을 그성하고 그것을 논리적으로 나눈것.
1. RAID강좌에서 테스트한 레이드 확인하자
[root@linux233 /]# fdisk /dev/hda
The number of cylinders for this disk is set to 3654. There is nothing wrong with that, but this is larger than 1024, and could in certain setups cause problems with: 1) software that runs at boot time (e.g., old versions of LILO) 2) booting and partitioning software from other OSs (e.g., DOS FDISK, OS/2 FDISK)
Command (m for help): p
Disk /dev/hda: 30.0 GB, 30060527616 bytes 255 heads, 63 sectors/track, 3654 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System /dev/hda1 * 1 127 1020096 83 Linux /dev/hda2 128 1402 10241437+ 83 Linux /dev/hda3 1403 2039 5116702+ 83 Linux /dev/hda4 2040 3654 12972487+ f Win95 Ext'd (LBA) /dev/hda5 2677 3058 3068383+ 83 Linux /dev/hda6 3059 3123 522081 82 Linux swap /dev/hda7 3124 3654 4265226 83 Linux /dev/hda8 2040 2283 1959898+ 83 Linux /dev/hda9 2284 2480 1582371 fd Linux raid autodetect/dev/hda10 2481 2676 1574338+ fd Linux raid autodetect Partition table entries are not in disk order
Command (m for help): q
You have new mail in /var/spool/mail/root [root@linux233 /]# mount /dev/hda1 on / type ext2 (rw) none on /proc type proc (rw) usbdevfs on /proc/bus/usb type usbdevfs (rw) /dev/hda3 on /backup type ext3 (rw) none on /dev/pts type devpts (rw,gid=5,mode=620) /dev/hda7 on /home type ext3 (rw,usrquota) none on /dev/shm type tmpfs (rw) /dev/hda2 on /usr type ext3 (rw) /dev/hda5 on /var type ext3 (rw) /dev/hda8 on /data1 type ext3 (rw) /dev/md0 on /raiddata type ext3 (rw) [root@linux233 /]# umount /raiddata [root@linux233 /]# raidstop /dev/md0
2. 기존 레이드 파티션을 LVM로 변경
[root@linux233 /]# fdisk /dev/hda
The number of cylinders for this disk is set to 3654. There is nothing wrong with that, but this is larger than 1024, and could in certain setups cause problems with: 1) software that runs at boot time (e.g., old versions of LILO) 2) booting and partitioning software from other OSs (e.g., DOS FDISK, OS/2 FDISK)
Command (m for help): p
Disk /dev/hda: 30.0 GB, 30060527616 bytes 255 heads, 63 sectors/track, 3654 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System /dev/hda1 * 1 127 1020096 83 Linux /dev/hda2 128 1402 10241437+ 83 Linux /dev/hda3 1403 2039 5116702+ 83 Linux /dev/hda4 2040 3654 12972487+ f Win95 Ext'd (LBA) /dev/hda5 2677 3058 3068383+ 83 Linux /dev/hda6 3059 3123 522081 82 Linux swap /dev/hda7 3124 3654 4265226 83 Linux /dev/hda8 2040 2283 1959898+ 83 Linux /dev/hda9 2284 2480 1582371 fd Linux raid autodetect /dev/hda10 2481 2676 1574338+ fd Linux raid autodetect
Partition table entries are not in disk order
Command (m for help): t Partition number (1-10): 9 Hex code (type L to list codes): L
0 Empty 1c Hidden Win95 FA 70 DiskSecure Mult bb Boot Wi zard hid 1 FAT12 1e Hidden Win95 FA 75 PC/IX be Solaris boot 2 XENIX root 24 NEC DOS 80 Old Minix c1 DRDOS/s ec (FAT- 3 XENIX usr 39 Plan 9 81 Minix / old Lin c4 DRDOS/s ec (FAT- 4 FAT16 <32M 3c PartitionMagic 82 Linux swap c6 DRDOS/s ec (FAT- 5 Extended 40 Venix 80286 83 Linux c7 Syrinx
6 FAT16 41 PPC PReP Boot 84 OS/2 hidden C: da Non-FS data 7 HPFS/NTFS 42 SFS 85 Linux extended db CP/M / CTOS / . 8 AIX 4d QNX4.x 86 NTFS volume set de Dell Ut ility 9 AIX bootable 4e QNX4.x 2nd part 87 NTFS volume set df BootIt
a OS/2 Boot Manag 4f QNX4.x 3rd part 8e Linux LVM e1 DOS acc ess b Win95 FAT32 50 OnTrack DM 93 Amoeba e3 DOS R/O
c Win95 FAT32 (LB 51 OnTrack DM6 Aux 94 Amoeba BBT e4 SpeedSt or e Win95 FAT16 (LB 52 CP/M 9f BSD/OS eb BeOS fs
f Win95 Ext'd (LB 53 OnTrack DM6 Aux a0 IBM Thinkpad hi ee EFI GPT
10 OPUS 54 OnTrackDM6 a5 FreeBSD ef EFI (FA T-12/16/ 11 Hidden FAT12 55 EZ-Drive a6 OpenBSD f0 Linux/P A-RISC b 12 Compaq diagnost 56 Golden Bow a7 NeXTSTEP f1 SpeedSt or 14 Hidden FAT16 <3 5c Priam Edisk a8 Darwin UFS f4 SpeedSt or 16 Hidden FAT16 61 SpeedStor a9 NetBSD f2 DOS sec ondary 17 Hidden HPFS/NTF 63 GNU HURD or Sys ab Darwin boot fd Linux r aid auto 18 AST SmartSleep 64 Novell Netware b7 BSDI fs fe LANstep
Hex code (type L to list codes): 8e Changed system type of partition 9 to 8e (Linux LVM)
Command (m for help): p
Disk /dev/hda: 30.0 GB, 30060527616 bytes 255 heads, 63 sectors/track, 3654 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System /dev/hda1 * 1 127 1020096 83 Linux /dev/hda2 128 1402 10241437+ 83 Linux /dev/hda3 1403 2039 5116702+ 83 Linux /dev/hda4 2040 3654 12972487+ f Win95 Ext'd (LBA) /dev/hda5 2677 3058 3068383+ 83 Linux /dev/hda6 3059 3123 522081 82 Linux swap /dev/hda7 3124 3654 4265226 83 Linux /dev/hda8 2040 2283 1959898+ 83 Linux /dev/hda9 2284 2480 1582371 8e Linux LVM /dev/hda10 2481 2676 1574338+ fd Linux raid autodetect
Partition table entries are not in disk order
Command (m for help): t Partition number (1-10): 10 Hex code (type L to list codes): 8e Changed system type of partition 10 to 8e (Linux LVM)
Command (m for help): p
Disk /dev/hda: 30.0 GB, 30060527616 bytes 255 heads, 63 sectors/track, 3654 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System /dev/hda1 * 1 127 1020096 83 Linux /dev/hda2 128 1402 10241437+ 83 Linux /dev/hda3 1403 2039 5116702+ 83 Linux /dev/hda4 2040 3654 12972487+ f Win95 Ext'd (LBA) /dev/hda5 2677 3058 3068383+ 83 Linux /dev/hda6 3059 3123 522081 82 Linux swap /dev/hda7 3124 3654 4265226 83 Linux /dev/hda8 2040 2283 1959898+ 83 Linux /dev/hda9 2284 2480 1582371 8e Linux LVM /dev/hda10 2481 2676 1574338+ 8e Linux LVM
Partition table entries are not in disk order
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.
3.리부팅을 하자
4. 디스크에 있는 볼륨그룹을 검색하고 /etc/lvmtab파일을 생성
[root@linux233 root]# vgscan vgscan -- reading all physical volumes (this may take a while...) vgscan -- "/etc/lvmtab" and "/etc/lvmtab.d" successfully created vgscan -- WARNING: This program does not do a VGDA backup of your volume group
5. 물리적 볼륨 생성 [root@linux233 root]# pvcreate /dev/hda9 pvcreate -- physical volume "/dev/hda9" successfully created
You have new mail in /var/spool/mail/root [root@linux233 root]# pvcreate /dev/hda10 pvcreate -- physical volume "/dev/hda10" successfully created
6. 생성된 PV를 특정한 볼륨그룹(lvm)에 추가시킨다
[root@linux233 root]# vgcreate lvm2 /dev/hda9 /dev/hda10 vgcreate -- INFO: using default physical extent size 4 MB vgcreate -- INFO: maximum logical volume size is 255.99 Gigabyte vgcreate -- doing automatic backup of volume group "lvm2" vgcreate -- volume group "lvm2" successfully created and activated
7. 생성된 볼륨그룹 검사한다 (vgdisplay -v)
[root@linux233 root]# vgdisplay -v lvm2 --- Volume group --- VG Name lvm2 VG Access read/write VG Status available/resizable VG # 0 MAX LV 256 Cur LV 0 Open LV 0 MAX LV Size 255.99 GB Max PV 256 Cur PV 2 Act PV 2 VG Size 3 GB PE Size 4 MB Total PE 768 Alloc PE / Size 0 / 0 Free PE / Size 768 / 3 GB VG UUID 16Qc7E-mWzm-gIJ2-koaa-ETQQ-LguF-ZJQLXB
--- No logical volumes defined in "lvm2" ---
--- Physical volumes --- PV Name (#) /dev/hda9 (1) PV Status available / allocatable Total PE / Free PE 385 / 385
PV Name (#) /dev/hda10 (2) PV Status available / allocatable Total PE / Free PE 383 / 383
[root@linux233 root]# lvscan lvscan -- ACTIVE "/dev/lvm2/home2" [1000 MB] lvscan -- 1 logical volumes with 1000 MB total in 1 volume group lvscan -- 1 active logical volumes
9.파일시스템 생성
[root@linux233 root]# mkfs -t ext3 /dev/lvm2/home2 mke2fs 1.32 (09-Nov-2002) Filesystem label= OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) 128000 inodes, 256000 blocks 12800 blocks (5.00%) reserved for the super user First data block=0 8 block groups 32768 blocks per group, 32768 fragments per group 16000 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840, 229376
11. 확인해보자 [root@linux233 /]# vgdisplay -v lvm2 --- Volume group --- VG Name lvm2 VG Access read/write VG Status available/resizable VG # 0 MAX LV 256 Cur LV 1 Open LV 1 MAX LV Size 255.99 GB Max PV 256 Cur PV 2 Act PV 2 VG Size 3 GB PE Size 4 MB Total PE 768 Alloc PE / Size 250 / 1000 MB Free PE / Size 518 / 2.02 GB VG UUID 16Qc7E-mWzm-gIJ2-koaa-ETQQ-LguF-ZJQLXB
--- Logical volume --- LV Name /dev/lvm2/home2 VG Name lvm2 LV Write Access read/write LV Status available LV # 1 # open 1 LV Size 1000 MB Current LE 250 Allocated LE 250 Allocation next free Read ahead sectors 1024 Block device 58:0
--- Physical volumes --- PV Name (#) /dev/hda9 (1) PV Status available / allocatable Total PE / Free PE 385 / 135
PV Name (#) /dev/hda10 (2) PV Status available / allocatable Total PE / Free PE 383 / 383
2. 확장된 공간확인 [root@linux233 /]# lvscan lvscan -- ACTIVE "/dev/lvm2/home2" [1.95 GB] lvscan -- 1 logical volumes with 1.95 GB total in 1 volume group lvscan -- 1 active logical volumes
자.. 그럼 정리해보죠. /dev/hda7 /dev/hdb1 /dev/hdc2 등 의 장치가 있다고 합시다 이것을 pv로 등록해서 VG(volumn group)으로 구성을 합니다. vgdisplay로 상태를 확인한다음 자신이 원하는 공간으로 쪼갠다음 마운트시켜서 사용하면 됩니다^^