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ƽ̴. ũ⸦ ٲ
ִ.

Filesystem : ext2, reiserfs ϴ Ͻý
ִ.

---------------------------------------------------------------------------------

lvm ġ Ȯ.
⺻ Redhat Linux ü ġ ϸ ġ ˴ϴ.

[root@linux root]# rpm -qa | grep lvm
lvm-1.0.3-15
[root@linux root]#
 rpm ġ Ȯ -qa ɼ ϸ ˴ϴ.

Ȥ ޽ lvm ġ Ȯ Ҽ ֽϴ.
[root@linux linux-2.4]# dmesg | grep LVM
LVM version 1.0.5+(22/07/2002) module loaded
[root@linux linux-2.4]#

lvm ٿε
ftp://ftp.gwdg.de/pub/linux/misc/lvm/1.0/ ֽϴ.

---------------------------------------------------------------------------------

[lvm ]

׽Ʈ 40GB ϵũ Ƽ ϰ +200M

1. ũ Ƽ Դϴ.࿡ ũ Ѵٸ n ɼ Ͽ ũ Ƽ ϰ t ɼ Ƽ Ÿ ϸ ˴ϴ.

[root@linux root]# fdisk /dev/hdc

The number of cylinders for this disk is set to 79408.
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): n
Command action
  e  extended
  p  primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-79408, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-79408, default 79408): +200M

Command (m for help): n
Command action
  e  extended
  p  primary partition (1-4)
p
Partition number (1-4): 2
First cylinder (390-79408, default 390):
Using default value 390
Last cylinder or +size or +sizeM or +sizeK (390-79408, default 79408): +200M

Command (m for help): t
Partition number (1-4): 1
Hex code (type L to list codes): 8e
Changed system type of partition 1 to 8e (Linux LVM)

Command (m for help): t
Partition number (1-4): 2
Hex code (type L to list codes): 8e
Changed system type of partition 2 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@linux linux-2.4]# fdisk -l  ---- ϵũ Ƽ Ȯ.

Disk /dev/hdc: 40.9 GB, 40982151168 bytes
16 heads, 63 sectors/track, 79408 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes

  Device Boot    Start      End    Blocks  Id  System
/dev/hdc1            1      389    196024+  8e  Linux LVM  ---- ũ
/dev/hdc2          390      778    196056  8e  Linux LVM
/dev/hdc3          779      1167    196056  8e  Linux LVM
/dev/hdc4          1168      1556    196056  8e  Linux LVM

Disk /dev/hda: 40.9 GB, 40982151168 bytes
255 heads, 63 sectors/track, 4982 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      1925  15358140  83  Linux
/dev/hda3          1926      1990    522112+  82  Linux swap
/dev/hda4          1991      4982  24033240    f  Win95 Ext'd (LBA)
/dev/hda5          1991      4982  24033208+  83  Linux
[root@linux linux-2.4]#

2. Ƽ PV Ѵ. pvcreate ̸ ش. lvm ϰ ϴ Ƽ θ ָ ֽϴ.
[root@linux root]# pvcreate /dev/hdc1
pvcreate -- ERROR: "/etc/lvmtab" doesn't exist; please run vgscan

࿡ PV ܿ

[root@linux root]# touch /etc/lvmtab[root@linux 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

̿ /etc/ 丮 lvmtab ϰ vgscan ָ ˴ϴ.

[root@linux root]# pvcreate /dev/hdc1
pvcreate -- physical volume "/dev/hdc1" successfully created

[root@linux root]# pvcreate /dev/hdc2
pvcreate -- physical volume "/dev/hdc2" successfully created

3. ׷ ش. vgcreate /dev/hdd1 /dev/hdd2
vg01 ׷ ϴ.׷ մϴ.⼭ vg01 ϰڽϴ.

[root@linux root]# vgcreate vg01 /dev/hdc1 /dev/hdc2
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 "vg01"
vgcreate -- volume group "vg01" successfully created and activated
[root@linux root]#

׷ ϰ ׷ Ȯvgdisply Ȯ մϴ.

[root@linux root]# vgdisplay
--- Volume group ---
VG Name              vg01
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              368 MB
PE Size              4 MB
Total PE              92
Alloc PE / Size      0 / 0
Free  PE / Size      92 / 368 MB
VG UUID              Ywc9nQ-8tzD-vPdN-1LR2-iVcz-1b65-OJ6ssO


[root@linux root]#
׷ vg01 ̰ а,,ũ⺯ȯ ϰ 368 MB ˼ֽϴ.

4. δ Ƽ մϴ. ̰ Ʈ ͸ ,Ʈ ͸ ֽϴ.

lvcreate <ũ> < ̸> < ׷>

-L ɼ ũ⸦ MB Է, -l PE Է ǹϸ, -n ̸ Ÿϴ.

[root@linux root]# lvcreate -L 300M -n lvol1 vg01
lvcreate -- doing automatic backup of "vg01"
lvcreate -- logical volume "/dev/vg01/lvol1" successfully created

[root@linux root]#

ɿ ũ 300MB ϰ lvol1 ϰ ׷ vg01 Դϴ.

Ƽ 됬 Ȯ δ  lvscan Ȯ մϴ.

[root@linux root]# lvscan
lvscan -- ACTIVE            "/dev/vg01/lvol1" [300 MB]
lvscan -- 1 logical volumes with 300 MB total in 1 volume group
lvscan -- 1 active logical volumes

[root@linux root]#

5. ֵ Ͻý   մϴ.

[root@linux root]# mkfs.ext2 /dev/vg01/lvol1

vg01 : ׷ , lvol1 :

6. Ʈ Ұ....

[root@linux root]#mkdir test
[root@linux /]# mount /dev/vg01/lvol1 /test
[root@linux /]# df
Filesystem          1K-blocks      Used Available Use% Mounted on
/dev/hda2            15116868  2114932  12234032  15% /
/dev/hda1              101089      5005    90865  6% /boot
none                    94548        0    94548  0% /dev/shm
/dev/vg01/lvol1        297485        13    282112  1% /test
[root@linux /]#

test Ʈ Ȱ Ȯ Ҽ ֽϴ.

7. /var 丮 뷮 ã Ƽ ȱ Դϴ.

[root@linux var]# cd ..
[root@linux /]# mv /var /var.old
[root@linux /]# umount /data
[root@linux /]# mkdir /var
[root@linux /]# mount /dev/vg01/lvol1 /var
[root@linux /]# df
Filesystem          1K-blocks      Used Available Use% Mounted on
/dev/hda2            15116868  2114932  12234032  15% /
/dev/hda1              101089      5005    90865  6% /boot
none                    94548        0    94548  0% /dev/shm
/dev/vg01/lvol1        297485        13    282112  1% /var
[root@linux /]# cp -dpR /var.old/* /var
[root@linux /]#vi /etc/fstab
LABEL=/                /                      ext2    defaults        1 1
LABEL=/boot            /boot                  ext2    defaults        1 2
LABEL=/data            /data                  ext2    defaults        1 2
none                    /dev/pts                devpts  gid=5,mode=620  0 0
none                    /proc                  proc    defaults        0 0
none                    /dev/shm                tmpfs  defaults        0 0
/dev/hda3              swap                    swap    defaults        0 0
/dev/cdrom              /mnt/cdrom              udf,iso9660 noauto,owner,kudzu,ro 0 0
/dev/fd0                /mnt/floppy            auto    noauto,owner,kudzu 0 0
/dev/vg01/lvol3    /var        ext2    defaults    1    2 ---->

wq!
[root@linux /]#sync;sync;sync;reboot -- -r

̷ ϸ ũ ִ ͸ ũ  Ҽ ִ Ƽ Ȱ Ҽ ֽϴ.

---------------------------------------------------------------------------------

[ ׷ ]
׷ ϱ ؼ Ȱȭ(ACTIVE) ׷Ȱȭ(inactive) Ѵ. Ȱȭ, Ȱȭ vgchange ٲָȴ. vgchange -a n vg01̸ Ȱȭ Ѵٴ ǹ̰, vgchange -a y ȰȭѴٴ ǹ̴. ׷ ϴ ɾ vgrename̴.

vgrename < ׷ ̸> <ٲ ׷ ̸>

[root@linux /]# vgscan  ----
vgscan -- reading all physical volumes (this may take a while...)
vgscan -- found active volume group "vg01"
vgscan -- "/etc/lvmtab" and "/etc/lvmtab.d" successfully created
vgscan -- WARNING: This program does not do a VGDA backup of your volume group

[root@linux /]# vgrename vg01 vg02 ----
vgrename -- doing automatic backup of volume group "vg02"
vgrename -- volume group "vg01" successfully renamed to "vg02"

[root@linux /]# vgscan ---
vgscan -- reading all physical volumes (this may take a while...)
vgscan -- found active volume group "vg02"
vgscan -- "/etc/lvmtab" and "/etc/lvmtab.d" successfully created
vgscan -- WARNING: This program does not do a VGDA backup of your volume group

[root@linux /]# mount /dev/vg02/lvol1 /var
[root@linux /]# df -k
Filesystem          1K-blocks      Used Available Use% Mounted on
/dev/hda2            15116868  2115084  12233880  15% /
/dev/hda1              101089      5005    90865  6% /boot
none                    94548        0    94548  0% /dev/shm
/dev/vg02/lvol1        297485    41057    241068  15% /var
[root@linux /]#

ó vg01 vg02 ٽ Ʈ Ǹ ˴ϴ.

---------------------------------------------------------------------------------

[ ο Ƽ ߰]

ִ ׷ ٸ ϵ ũ ִ Ƽ ߰ vgextend, ϵ ũ Ƽ ߰ ֽϴ. /dev/hdc1 ִvg02 Ƽǿ /dev/hdc3 ִ lvm Ƽ ĥ 쿡 Ѵ. vg02 Ȱȭ Ǿ ʱ Ȱȭ մϴ. Ȱȭݴϴ.

[root@linux PVs]# pvscan
pvscan -- reading all physical volumes (this may take a while...)
pvscan -- ACTIVE  PV "/dev/hdc1" of VG "vg02" [184 MB / 0 free]
pvscan -- ACTIVE  PV "/dev/hdc2" of VG "vg02" [184 MB / 68 MB free]
pvscan -- total: 2 [382.89 MB] / in use: 2 [382.89 MB] / in no VG: 0 [0]

[root@linux PVs]# vgchange -a y vg02
vgchange -- volume group "vg02" already active

[root@linux PVs]#
[root@linux PVs]# pvcreate /dev/hdc3
pvcreate -- physical volume "/dev/hdc3" successfully created

[root@linux PVs]# vgextend vg02 /dev/hdc3
vgextend -- INFO: maximum logical volume size is 255.99 Gigabyte
vgextend -- doing automatic backup of volume group "vg02"
vgextend -- volume group "vg02" successfully extended

[root@linux PVs]# vgdisplay
--- Volume group ---
VG Name              vg02
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                3
Act PV                3
VG Size              552 MB ---- 200M 뷮 ߰ Ȯ.....
PE Size              4 MB
Total PE              138
Alloc PE / Size      75 / 300 MB
Free  PE / Size      63 / 252 MB
VG UUID              Ywc9nQ-8tzD-vPdN-1LR2-iVcz-1b65-OJ6ssO


[root@linux PVs]#

---------------------------------------------------------------------------------

[ ̱]

ũ⸦ ø δ -L+100 ִ   ֽϴ.

[root@linux PVs]# lvextend -L+200 /dev/vg02/lvol1
lvextend -- extending logical volume "/dev/vg02/lvol1" to 500 MB
lvextend -- doing automatic backup of volume group "vg02"
lvextend -- logical volume "/dev/vg02/lvol1" successfully extended

ũ 뷮 200M ߰ ߰ ؼ ο Ͻý ְ(ext2) Ʈ(/var) Ų Դϴ.

[root@linux PVs]# lvextend -L+200 /dev/vg02/lvol1
lvextend -- extending logical volume "/dev/vg02/lvol1" to 500 MB
lvextend -- doing automatic backup of volume group "vg02"
lvextend -- logical volume "/dev/vg02/lvol1" successfully extended
[root@linux /]# mkfs.ext2 /dev/vg02/lvol1
[root@linux /]# mount /dev/vg02/lvol1 /var

뷮 ߰ 쿡 ٽ ý ؾ ŭ 뷮 Ҽ ֽϴ.̷ ϱ ؼ ش Ƽǿ ִ ʹ ٸ Űų ٽ ؾ մϴ.


[root@linux PVs]# df -k ---- 200M ߰ ϱ (var)
Filesystem          1K-blocks      Used Available Use% Mounted on
/dev/hda2            15116868  2115388  12233576  15% /
/dev/hda1              101089      5005    90865  6% /boot
none                    94548        0    94548  0% /dev/shm
/dev/vg02/lvol1        297485    41057    241068  15% /var
[root@linux PVs]#

[root@linux /]# df -k ---- 200M ߰ (var)
Filesystem          1K-blocks      Used Available Use% Mounted on
/dev/hda2            15116868  2115388  12233576  15% /
/dev/hda1              101089      5005    90865  6% /boot
none                    94548        0    94548  0% /dev/shm
/dev/vg02/lvol1        495844        13    470231  1% /var
[root@linux /]#

---------------------------------------------------------------------------------

[ ̱]

ũ⸦ lvreduce ϸŭ ڸ ϸ ׸ŭ پ ˴ϴ. ũ⸦ Ͱ 츦 , ũ⸦ Ȯϰ ̰ Ǿ մϴ. Ͱ ִ ̻ŭ پ Ǹ, ʹ 翬 ˴ϴ.

[root@linux /]# lvreduce -L-300 /dev/vg02/lvol1
lvreduce -- WARNING: reducing active and open logical volume to 200 MB
lvreduce -- THIS MAY DESTROY YOUR DATA (filesystem etc.)
lvreduce -- do you really want to reduce "/dev/vg02/lvol1"? [y/n]: y
lvreduce -- doing automatic backup of volume group "vg02"
lvreduce -- logical volume "/dev/vg02/lvol1" successfully reduced

[root@linux /]#

  vg02 500M 300M ̶ Դϴ. ϰ ٽ Ͻý ؾ մϴ.

[root@linux /]# mkfs.ext2 /dev/vg02/lvol1
[root@linux /]# mount /dev/vg02/lvol1 /var
[root@linux /]# df -k
Filesystem          1K-blocks      Used Available Use% Mounted on
/dev/hda2            15116868  2115540  12233424  15% /
/dev/hda1              101089      5005    90865  6% /boot
none                    94548        0    94548  0% /dev/shm
/dev/vg02/lvol1        198337        13    188084  1% /var
[root@linux /]#

---------------------------------------------------------------------------------

[ ]

vgreduce ϳ ִ ׷ Ƽ մϴ.
vg02 /dev/hdc1 /dev/hdc3 Բ ִ /dev/hdc3 
, vgreduce մϴ.

[root@linux /]# vgreduce vg02 /dev/hdc3
vgreduce -- doing automatic backup of volume group "vg02"
vgreduce -- volume group "vg02" successfully reduced by physical volume:
vgreduce -- /dev/hdc3

[root@linux /]# pvscan ---- pvƼ Ȯ.
pvscan -- reading all physical volumes (this may take a while...)
pvscan -- ACTIVE  PV "/dev/hdc1" of VG "vg02" [184 MB / 0 free]
pvscan -- ACTIVE  PV "/dev/hdc2" of VG "vg02" [184 MB / 168 MB free]
pvscan -- inactive PV "/dev/hdc3" is in no VG  [191.46 MB]
pvscan -- total: 3 [574.35 MB] / in use: 2 [382.89 MB] / in no VG: 1 [191.46 MB]

[root@linux /]#

ٽ Ͻý ؾ ˴ϴ.

---------------------------------------------------------------------------------

[ ]

lvrename < > <ο ̸>

[root@linux /]# lvrename /dev/vg02/lvol1 /dev/vg02/test01
lvrename -- doing automatic backup of volume group "vg02"
lvrename -- logical volume "/dev/vg02/lvol1" successfully renamed to "/dev/vg02/test01"

[root@linux /]# lvchange -ay /dev/vg02/test01 
lvchange -- logical volume "/dev/vg02/test01" is already active
lvchange -- availability of logical volume "/dev/vg02/test01" doesn't have to be changed
lvchange -- logical volume "/dev/vg02/test01" didn't have to be changed

Ȱȭ Ȱȭ......

[root@linux /]# lvscan ----
lvscan -- ACTIVE            "/dev/vg02/test01" [200 MB]
lvscan -- 1 logical volumes with 200 MB total in 1 volume group
lvscan -- 1 active logical volumes

Ȯ......

[root@linux /]#

 
 

Total 106
ȣ     ۾ ¥ ȸ
16 ssh 񽺰 ʵɶ....
2005/12/26 12098
15 ھ ϱ
2005/12/26 12121
14 HP DL380 (smart array 5300) ̵ ũ
2005/12/23 10035
13 ̵尡 Ƽ .... HP DL380 sm
2005/12/23 19705
12 solaris (1) linux (2) .
2005/12/07 4389
11 bind 9.2.3 ġ.
2005/12/07 8216
10 chkconfig
2005/12/07 4024
9 linux Ʈũ .
2005/12/07 6398
8 LVM . (Logical Volume Manager) (2)
2005/12/07 5816
7 Linux root password нǽ
2005/12/06 7547
6 [L I N U X] disk spacing management - view partion table
2005/12/06 4137
5 LVM . (Logical Volume Manager) (1)
2005/12/06 18742
4 rsync .....
2005/12/01 5757
3 linux - solaris nfs .(2)
2005/11/30 23957
2 linux nfs (1)
2005/11/30 17624
 1  2  3  4  5  6  7  8  
 
 
 
Administrator Login