LVM(Linux Volume Manager) 구축하기

I. 시스템 사양

  - PC 의 vmware 상에서 하드를 2개 추가하여 할 예정

  - OS : redhat 9 2.4.20-31.9(yum으로 커널 컴파일 한 버전)

  - vmware에서 구축

  - HDD 3개 : 이중 sad1(2G) 과 sdc1(2G) 에 구축예정

  - CPU : Pentium 4 2.8Ghz

  - memory : 1G(physical) + 1G(swap)


II . 구축하기

1. 먼저 디스크에 리눅스 LVM 파일 시스템을 만들어준다.

[root@angka root]# fdisk /dev/sdb


Command (m for help): n

Command action

  e   extended

  p   primary partition (1-4)

p

Partition number (1-4): 1

First cylinder (1-261, default 1):

Using default value 1

Last cylinder or +size or +sizeM or +sizeK (1-261, default 261):

Using default value 261


Command (m for help): t

Selected partition 1

Hex code (type L to list codes): 8e      <-- 반드시 LVM으로 포맷해준다.

Changed system type of partition 1 to 8e (Linux LVM)


Command (m for help): p


Disk /dev/sdb: 2147 MB, 2147483648 bytes

255 heads, 63 sectors/track, 261 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes


  Device Boot    Start       End    Blocks   Id  System

/dev/sdb1             1       261   2096451   8e  Linux LVM


Command (m for help): w

The partition table has been altered!


Calling ioctl() to re-read partition table.

Syncing disks.


/dev/sdc 도 똑같은 방법으로 LVM 으로 만들어준다.


fdisk -l 명령으로 sdb 와 sdc가 LVM으로 만들어 졌는지 확인한다.


[root@angka root]# fdisk -l


Disk /dev/sda: 11.8 GB, 11811160064 bytes

255 heads, 63 sectors/track, 1435 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes


  Device Boot    Start       End    Blocks   Id  System

/dev/sda1   *         1       510   4096543+  83  Linux

/dev/sda2           511       637   1020127+  82  Linux swap

/dev/sda3           638      1435   6409935   83  Linux


Disk /dev/sdb: 2147 MB, 2147483648 bytes

255 heads, 63 sectors/track, 261 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes


  Device Boot    Start       End    Blocks   Id  System

/dev/sdb1             1       261   2096451   8e Linux LVM <-- 파일 시스템 파입이 LVM이어야한다.


Disk /dev/sdc: 2147 MB, 2147483648 bytes

255 heads, 63 sectors/track, 261 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes


  Device Boot    Start       End    Blocks   Id  System

/dev/sdc1             1       261   2096451   8e  Linux LVM



2. pvcreate 명령으로 물리적인 볼륨을 생성한다.


[root@angka root]# pvcreate /dev/sdb1

pvcreate -- physical volume "/dev/sdb1" successfully created


[root@angka root]# pvcreate /dev/sdc1

pvcreate -- physical volume "/dev/sdc1" successfully created


[root@angka root]#


3. sdb1 과 sdc1을 하나의 물리적 볼륨으로 묶어준다. 볼륨 그룹 이름은 angkaVG 로 한다.

[root@angka root]# vgcreate angkaVG /dev/sdb1 /dev/sdc1

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 "angkaVG"

vgcreate -- volume group "angkaVG" successfully created and activated


[root@angka root]#


4. vgdisplay 명령으로 볼륨그룹이 잘 생성되었는지 확인한다.

[root@angka root]# vgdisplay

--- Volume group ---

VG Name               angkaVG

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.98 GB <-- 2G 2개를 묶었으므로 4G가 나온다.

PE Size               4 MB

Total PE              1020

Alloc PE / Size       0 / 0

Free  PE / Size       1020 / 3.98 GB

VG UUID               HJNDS6-X7U4-BVlx-pPiG-uAkD-2Fup-cMqeqP



[root@angka root]#

여기서 주의할 것은 angkaVG는 단지 볼륨 그룹이지 논리적인 슬라이스가 아니다. angkaVG 자체를 마운트 하려고 하면 오류가 떨어진다. 이것은 마치 하드디스크를 추가하면 /dev/sde 와 같이 물리적인 디스크로 시스템에서 인식할 뿐이다. 그러므로 angkaVG를 다시 lvcreate 이용하여(하드 디스크일 경우는 fdisk이지만) 논리적으로 시스템이 인식하도록 만들어 주어야 한다.



5. angkaVG를 lvcreate를 이용 angkaVG1 4G로 만든다.

[root@angka root]# lvcreate -L 3.98G -n angkaVG1 angkaVG

lvcreate -- rounding size up to physical extent boundary

lvcreate -- doing automatic backup of "angkaVG"

lvcreate -- logical volume "/dev/angkaVG/angkaVG1" successfully created


[root@angka root]#


자 이제 우리가 쓸 수 있는 논리적인 디스크의 이름은 /dev/angkaVG/angkaVG1 이다. 이것의 크기는 4G 이며 이것은 sdb1(2G) + sdc1(2G)를 합쳐놓은 크기이다.


6. angkaVG1을 파일 시스템을 만들고 fsck 까지 한다음에 마운트한다.

[root@angka /]# mkfs.ext3 /dev/angkaVG/angkaVG1

mke2fs 1.32 (09-Nov-2002)

Filesystem label=

OS type: Linux

Block size=4096 (log=2)

Fragment size=4096 (log=2)

522240 inodes, 1043456 blocks

52172 blocks (5.00%) reserved for the super user

First data block=0

32 block groups

32768 blocks per group, 32768 fragments per group

16320 inodes per group

Superblock backups stored on blocks:

       32768, 98304, 163840, 229376, 294912, 819200, 884736


Writing inode tables: done                           

Creating journal (8192 blocks): done

Writing superblocks and filesystem accounting information: done


This filesystem will be automatically checked every 37 mounts or

180 days, whichever comes first.  Use tune2fs -c or -i to override.

[root@angka /]# fsck -y /dev/angkaVG/angkaVG1

fsck 1.32 (09-Nov-2002)

e2fsck 1.32 (09-Nov-2002)

/dev/angkaVG/angkaVG1: clean, 11/522240 files, 24607/1043456 blocks

[root@angka /]# mount /dev/angkaVG/angkaVG1 /test

[root@angka /]# df -k

Filesystem           1K-blocks      Used Available Use% Mounted on

/dev/sda1              4032092   3364488    462780  88% /

/dev/sda3              6309320   3779156   2209668  64% /oracle

none                     79144         0     79144   0% /dev/shm

/dev/angkaVG/angkaVG1

                      4108224     32828   3866708   1% /test

[root@angka /]#

 

7. 부팅시에도 올라오도록 /etc/fstab 에 넣어준다.

LABEL=/                 /                       ext3    defaults        1 1

none                    /dev/pts                devpts  gid=5,mode=620  0 0

LABEL=/oracle           /oracle                 ext3    defaults        1 2

none                    /proc                   proc    defaults        0 0

none                    /dev/shm                tmpfs   defaults        0 0

/dev/sda2               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/angkaVG/angkaVG1   /test                   ext3    defaults        1 3



출처 - http://myoung76.tistory.com/18 








LVM 구현  Linux / OS for Oracle 

2011/08/07 02:54

복사 http://blog.naver.com/calmim/90119895561

※ LVM (Logical Volume Manager) : 여러개의 하드디스크를 관리하면 불편하기 때문에 여러개의 장치를 하나로 묶어 관리하는 것이 LVM이다. 윈도우에서는 SPAN이라고 하며, RAID 처럼 분할이 아닌 차곡차곡 데이터가 쌓이는 것이다. 즉, n개의 하드에 1개의 파티션이라고 생각하면 된다.

 

- LVM 구현 -

 

먼저 하드디스크를 추가해 주기로 한다.

하드디스크를 3개(200MB, 100MB, 200MB)를  추가할 것이다.


 

 

add를 눌러준다.

 

 

 

hard disk 선택 후 다음

 

 

새로운 디스크를 생성하기위해 첫번째를 선택후 다음

 

 

SCSI를 선택 후 다음

 

 

하드 용량을 설정한 후 다음

 

 

장치 이름을 입력후 완료

 

 

디스크를 확인한다.

 

 

이렇게 하드디스크를 추가해준 다음 ok를 선택

 

 

머신을 실행 시킨다.

 

로그인 후

하드디스크가 추가된 것을 확인

[root@centos ~]# cd /dev

[root@centos dev]# ls sd*
sda  sda1  sda2  sda3  sda4  sda5  sda6  sdb  sdc  sdd

 

파티션과 포맷

[root@centos dev]# fdisk /dev/sdb

Command (m for help): n  <== 입력

Command action
   e   extended
   p   primary partition (1-4)
p   <== 입력
Partition number (1-4): 1  <== 1번 파티션 선택

First cylinder (1-204, default 1):   <== 시작 실린더 엔터(기본값 1)
Using default value 1

Last cylinder or +size or +sizeM or +sizeK (1-204, default 204):   <== 마지막 실린더 엔터
Using default value 204 (기본값 마지막 실린더 번호)

 

Command (m for help): t   <== 파일 시스템 유형 선택

 

Selected partition 1
Hex code (type L to list codes): 8e   <== LVM의 코드 번호 L을 입력하면 목록을 볼 수 있다
Changed system type of partition 1 to 8e (Linux LVM)

 

Command (m for help): p  <== 설정 내용 확인

Disk /dev/sdb: 213 MB, 213909504 bytes
64 heads, 32 sectors/track, 204 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1         204      208880   8e  Linux LVM

 

Command (m for help): w  <== 저장
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

 

같은방식으로 sdc와 sdd를 파티션을 할당한다.

 

파티션을 할당 후 하드디스크를 확인한다.

[root@centos /]# fdisk -l

Disk /dev/sda: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 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         650     5116702+  83  Linux
/dev/sda3             651         911     2096482+  82  Linux swap / Solaris
/dev/sda4             912        2610    13647217+   5  Extended
/dev/sda5             912        1038     1020096   83  Linux
/dev/sda6            1039        2610    12627058+  83  Linux

Disk /dev/sdb: 213 MB, 213909504 bytes
64 heads, 32 sectors/track, 204 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1         204      208880   8e  Linux LVM

Disk /dev/sdc: 106 MB, 106954752 bytes
64 heads, 32 sectors/track, 102 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1               1         102      104432   8e  Linux LVM

Disk /dev/sdd: 213 MB, 213909504 bytes
64 heads, 32 sectors/track, 204 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdd1               1         204      208880   8e  Linux LVM

 

 

 

물리적 볼륨 생성

[root@centos dev]# pvcreate /dev/sdb1 /dev/sdc1 /dev/sdd1
  Physical volume "/dev/sdb1" successfully created
  Physical volume "/dev/sdc1" successfully created
  Physical volume "/dev/sdd1" successfully created

 


 

볼륨 그룹 생성

[root@centos dev]# vgcreate VG /dev/sdb1 /dev/sdc1 /dev/sdd1
  Volume group "VG" successfully created

 


 

볼륨 그룹 생성 확인

[root@centos dev]# vgdisplay
  --- Volume group ---
  VG Name               VG
  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               500.00 MB  <== 물리적장치의 용량을 합한 size 이다.(200+100+200MB)
  PE Size               4.00 MB
  Total PE              125
  Alloc PE / Size       0 / 0
  Free  PE / Size       125 / 500.00 MB
  VG UUID               MigSur-JEOD-O6gn-1nNB-dX5A-ADb7-7guD3V

논리적 그룹 생성

[root@centos dev]# lvcreate -L 500MB -n LG VG <== VG size 전체를 잡아준다.
   Logical volume "LG" created

[root@centos dev]# ls -l /dev/VG
total 0
lrwxrwxrwx 1 root root 17 Aug  6 23:55 LG -> /dev/mapper/VG-LG  <== 링크 되어 있다.

포맷

[root@centos dev]# mkfs.ext3 /dev/VG/LG
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
128016 inodes, 512000 blocks
25600 blocks (5.00%) reserved for the super user
First data block=1
Maximum filesystem blocks=67633152
63 block groups
8192 blocks per group, 8192 fragments per group
2032 inodes per group
Superblock backups stored on blocks:
        8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409

Writing inode tables: done
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 33 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.


 

 

마운트

[root@centos /]# mkdir lvmdata  <== 마운트할 디렉토리 생성
[root@centos /]# mount /dev/VG/LG /lvmdata   <== 마운트
[root@centos /]# df -h  <== 마운트 확인
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda2             4.8G  2.7G  1.9G  59% /
/dev/sda6              12G  159M   11G   2% /home
/dev/sda5             965M   71M  845M   8% /var
/dev/sda1              99M   11M   83M  12% /boot
tmpfs                 506M     0  506M   0% /dev/shm
/dev/hdc              3.8G  3.8G     0 100% /media/CentOS_5.2_Final
/dev/mapper/VG-LG     485M   11M  449M   3% /lvmdata  <== 마운트 성공

 

 

 

부팅시 자동 마운트 설정

[root@centos /]# vi /etc/fstab
  장치명                  마운트할 폴더        시스템유형      defaults        읽기   쓰기

/dev/VG/LG              /lvmdata                ext3            defaults          1        1   <== 내용 추가

 

재부팅 후 확인해 본다.

 

 

- LVM 삭제 -

 

[root@centos /]# umount /dev/mapper/VG-LG
[root@centos /]# lvremove /dev/mapper/VG-LG
  Do you really want to remove active logical volume "LG"? [y/n]: y
  Logical volume "LG" successfully removed

[root@centos /]# vgremove /dev/VG
  Volume group "VG" successfully removed
[root@centos /]# vgdisplay

[root@centos /]# vi /etc/fstab
추가한 내용을 삭제 한다.

[root@centos /]# pvremove /dev/[경로]

OS 종료 후 하드디스크 장치를 제거한다.








Linux - How to add a new disk to a volume group

 

The disk to add to the VG can be a single disk or a hardware raid of disks that can be seen by the fdisk command

fdisk -l

The truncated output from this command is shown below

Disk /dev/sda: 146.6 GB, 146694733824 bytes
255 heads, 63 sectors/track, 17834 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          17      136521   83  Linux
/dev/sda2              18       17834   143115052+  8e  Linux LVM

Disk /dev/sdb: 293.3 GB, 293389467648 bytes
255 heads, 63 sectors/track, 35669 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sdb doesn't contain a valid partition table

We can see that the disk /dev/sdb is not in use

We now need to create a partition on this disk using the fdisk command as follows

fdisk /dev/sdb

Command (m for help): p

Disk /dev/sdb: 293.3 GB, 293389467648 bytes
255 heads, 63 sectors/track, 35669 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-35669, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-35669, default 35669):
Using default value 35669

Command (m for help): p

Disk /dev/sdb: 293.3 GB, 293389467648 bytes
255 heads, 63 sectors/track, 35669 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1       35669   286511211   83  Linux

The above process creates a linux partition the same size as the disk, however we need to change the type from linux to Linux LVM as this partition will be part of Logical Volume Management (LVM)

Whilst still in the fdisk /dev/sdb utility do the following

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): p

Disk /dev/sdb: 293.3 GB, 293389467648 bytes
255 heads, 63 sectors/track, 35669 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1       35669   286511211   8e  Linux LVM

Command (m for help):

After the partition type has been changed use the w command to write the partition table to the disk.

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

We now need to prepare the disk for use in LVM by using the pvcreate command

pvcreate /dev/sdb1

Physical volume "/dev/sdb1" successfully created

Now in this example we are going to extend an existing volume group to incorporate this new partition. You could however create a new VG and add it to that.

Use the vgdisplay command to see the existing volume groups

vgdisplay

 --- Volume group ---
  VG Name               system
  System ID
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  7
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                6
  Open LV               6
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               136.48 GB
  PE Size               4.00 MB
  Total PE              34940
  Alloc PE / Size       16896 / 66.00 GB
  Free  PE / Size       18044 / 70.48 GB
  VG UUID               Xcgf7x-W6FJ-OMPa-0j21-XIdt-NLFz-PshfWe

We are going to add /dev/sdb1 into the existing VG called system by using the vgextend command

vgextend system /dev/sdb1

Volume group "system" successfully extended

Use the vgdisplay command again to view the statistics for the VG. Check the Free row to ensure the free disk space in the VG has increased as shown below.

vgdisplay

 --- Volume group ---
  VG Name               system
  System ID
  Format                lvm2
  Metadata Areas        2
  Metadata Sequence No  8
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                6
  Open LV               6
  Max PV                0
  Cur PV                2
  Act PV                2
  VG Size               409.72 GB
  PE Size               4.00 MB
  Total PE              104888
  Alloc PE / Size       16896 / 66.00 GB
  Free  PE / Size       87992 / 343.72 GB
  VG UUID               Xcgf7x-W6FJ-OMPa-0j21-XIdt-NLFz-PshfWe

In this case we want to use the capacity of the new partition to create a new logical volume. This can be achieved by using the lvcreate command

lvcreate -L 293G -n logs system

Logical volume "logs" created

This command creates a 293GB logical volume called logs in the system VG

We now need to create a filesystem on the LV as follows

mkfs.ext3 /dev/system/logs

mke2fs 1.38 (30-Jun-2005)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
38404096 inodes, 76808192 blocks
3840409 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=79691776
2344 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
        4096000, 7962624, 11239424, 20480000, 23887872, 71663616

Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 35 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.

This creates an ext3 filesystem on the logs LV

Now all we have left to is mount the new filesystem, in this case on an existing directory called logs

mount /dev/system/logs /logs

Lastly don't forget to edit /etc/fstab so that this filesystem is mounted on boot



source - http://www.computers-it.com/linux/linux_add_new_disk_to_VG.php








 LVM 사용하여 추가한 디스크로 볼륨 늘리기


1. 디스크 먼저 추가

 

2. fdisk 로 해당 디스크 파티셔닝 및 파일시스템을 Linux LVM (8e) 타입으로 변경

 

3. 추가된 디스크 파티션  (예:/dev/sdb1) 을  LVM pv로 등록

 

# pvcreate /dev/sdb1

 

 

-- pv 확인

# pvdisplay

 

 

4. 볼륨그룹에 해당 pv 를 추가

 

 

-- 볼륨그룹 확인방법

# vgdisplay
  --- Volume group ---
  VG Name               VolGroup00
  System ID             
  Format                lvm2
  Metadata Areas        2
  Metadata Sequence No  6
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                2
  Open LV               2
  Max PV                0
  Cur PV                2
  Act PV                2
  VG Size               69.84 GB
  PE Size               32.00 MB
  Total PE              2235
  Alloc PE / Size       2235 / 69.84 GB
  Free  PE / Size       0 / 0   
  VG UUID               c0VfnV-tkri-vcAz-Z9Nz-bhBc-hfsX-Xdbupi

 

 

-- 볼륨그룹에 pv를 추가

# vgextend VolGroup00 /dev/sdb1

 

 

-- 볼륨그룹 증가된 부분 확인

  --- Volume group ---
  VG Name               VolGroup00
  System ID             
  Format                lvm2
  Metadata Areas        2
  Metadata Sequence No  6
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                2
  Open LV               2
  Max PV                0
  Cur PV                2
  Act PV                2
  VG Size               69.84 GB
  PE Size               32.00 MB
  Total PE              2235                    --->  증가된 부분 확인
  Alloc PE / Size       2235 / 69.84 GB
  Free  PE / Size       0 / 0                --->  남은 공간  (추가된 디스크 만큼의 용량)
  VG UUID               c0VfnV-tkri-vcAz-Z9Nz-bhBc-hfsX-Xdbupi

 

 

 

5. 볼륨그룹내 LV 의 크기를 증가.

vgdisplay 의 결과중 TotalPE의 크기만큼 증가시킨다.

즉, 추가할 PE만큼 늘리는게 아니라 목표하는 전체 PE의 크기만큼 지정해준다.

 

# lvextend -l 2235 /dev/mapper/VolGroup00-LogVol01

 

 

--  vg와 lv 를 모두 확인

# vgdisplay

# lvdisplay

  --- Logical volume ---
  LV Name                /dev/VolGroup00/LogVol01
  VG Name                VolGroup00
  LV UUID                Mlt1AT-b5aP-k1L8-355J-i9dT-3Fak-BNcmQz
  LV Write Access        read/write
  LV Status              available
  # open                 1
  LV Size                68.84 GB           --> 최종 증가된 분량 확인
  Current LE             2203
  Segments               2
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:0

 

 

 

 

6. 파일시스템에 적용

--> LV까지 증가시켰는데도 파일시스템이 증가하지 않는다.

수동으로 증가시켜야 한다.

 

# resize2fs /dev/mapper/VolGroup00-LogVol01
resize2fs 1.39 (29-May-2006)
Filesystem at /dev/mapper/VolGroup00-LogVol01 is mounted on /; on-line resizing required
Performing an on-line resize of /dev/mapper/VolGroup00-LogVol01 to 18046976 (4k) blocks.
The filesystem on /dev/mapper/VolGroup00-LogVol01 is now 18046976 blocks long.

 

 

7. 확인

# df -k   로 확인했을때 늘어난 용량을 확인할 수 있다.



출처 - http://www.ischo.net/?mid=board_linux&page=1&document_srl=1390








Thursday, July 19, 2012

How To Add to an LVM Drive

One of the great things about LVM is that you never run out of space. If it seems as if you are about to do so, you just add a new "physical volume" to your "volume group", add that to your "logical volume", and resize the file system. In effect, it's as if you have a partition that spans multiple drives.

It would of course be a good idea to back things up before you do this. But sometimes we don't have that option, do we?

I'll suppose our existing volume group is "vgroup", and our existing logical volume is "vvolume".

All of this of course needs to be done as root.

A little hint first: You can (and probably should) give the "-t" (test) option to each LVM command first, to make sure it's going to do what you want. Then I hit up arow (history) and delete the "-t" option, so I make sure I'm running that same command.
  1. Add the new disk to the machine, and format whatever space we want on it (all of it, if we wish) as type 8e (Linux LVM). I'll assume this is now /dev/sde1.
  2. Create a physical volume: 
    # pvcreate /dev/sde1
  3. Add the physical volume to the volume group:
    # vgextend vgroup /dev/sde1
  4. Check your work:
    # vgdisplay vgroup
    You should now see something like:
    VG Name               vgroup
    System ID             
    Format                lvm2
    Metadata Areas        2
    Metadata Sequence No  5
    VG Access             read/write
    VG Status             resizable
    MAX LV                0
    Cur LV                1
    Open LV               0
    Max PV                0
    Cur PV                2
    Act PV                2
    VG Size               3.68 TiB
    PE Size               4.00 MiB
    Total PE              1192327
    Alloc PE / Size       476931 / 1.82 TiB
    Free  PE / Size       476931 / 1.82 TiB
    VG UUID               JitzBk-zFH0-vhzm-XhYk-V5Xi-Nt7d-87K9En
    
    Note the free space we now have.
  5. Extend the logical volume:
    # lvresize -l 100%VG /dev/vgroup/vvolume
    The "-l 100%VG" says to resize to use all of the space in the volume group assigned to this logical volume. The argument can be given many ways. See "man lvcreate".
  6. Check our work:
    # lvdisplay
  7. Now we are ready to resize the filesystem:
    # e2fsck -f /dev/vgroup/vvolume
    It made me do that first.
    # resize2fs /dev/vgroup/vvolume
The LVM HowTo covers all of this.


I find this works better btw: lvextend -l +100%FREE /dev/vg/lv



source - http://rgheck.blogspot.kr/2012/07/how-to-add-to-lvm-drive.html








[root@db1 ~]# fdisk -l


Disk /dev/xvda: 21.5 GB, 21474836480 bytes

255 heads, 63 sectors/track, 2610 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x000a00b4


    Device Boot      Start         End      Blocks   Id  System

/dev/xvda1   *           1          64      512000   83  Linux

Partition 1 does not end on cylinder boundary.

/dev/xvda2              64        2611    20458496   8e  Linux LVM


Disk /dev/xvdb: 85.9 GB, 85899345920 bytes

255 heads, 63 sectors/track, 10443 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x00000000



Disk /dev/mapper/VolGroup-lv_root: 16.8 GB, 16752050176 bytes

255 heads, 63 sectors/track, 2036 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x00000000



Disk /dev/mapper/VolGroup-lv_swap: 4194 MB, 4194304000 bytes

255 heads, 63 sectors/track, 509 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x00000000


[root@db1 ~]# 

[root@db1 ~]# fdisk /dev/xvdb

Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel

Building a new DOS disklabel with disk identifier 0xbe92d432.

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)


WARNING: DOS-compatible mode is deprecated. It's strongly recommended to

         switch off the mode (command 'c') and change display units to

         sectors (command 'u').


Command (m for help): n

Command action

   e   extended

   p   primary partition (1-4)

p

Partition number (1-4): 1

First cylinder (1-10443, default 1): 

Using default value 1

Last cylinder, +cylinders or +size{K,M,G} (1-10443, default 10443): 

Using default value 10443


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): p


Disk /dev/xvdb: 85.9 GB, 85899345920 bytes

255 heads, 63 sectors/track, 10443 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0xbe92d432


    Device Boot      Start         End      Blocks   Id  System

/dev/xvdb1               1       10443    83883366   8e  Linux LVM


Command (m for help): w

The partition table has been altered!


Calling ioctl() to re-read partition table.

Syncing disks.

[root@db1 ~]# 

[root@db1 ~]# fdisk -l


Disk /dev/xvda: 21.5 GB, 21474836480 bytes

255 heads, 63 sectors/track, 2610 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x000a00b4


    Device Boot      Start         End      Blocks   Id  System

/dev/xvda1   *           1          64      512000   83  Linux

Partition 1 does not end on cylinder boundary.

/dev/xvda2              64        2611    20458496   8e  Linux LVM


Disk /dev/xvdb: 85.9 GB, 85899345920 bytes

255 heads, 63 sectors/track, 10443 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0xbe92d432


    Device Boot      Start         End      Blocks   Id  System

/dev/xvdb1               1       10443    83883366   8e  Linux LVM


Disk /dev/mapper/VolGroup-lv_root: 16.8 GB, 16752050176 bytes

255 heads, 63 sectors/track, 2036 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x00000000



Disk /dev/mapper/VolGroup-lv_swap: 4194 MB, 4194304000 bytes

255 heads, 63 sectors/track, 509 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x00000000


[root@db1 ~]# 

[root@db1 ~]# pvcreate /dev/xvdb1

  Physical volume "/dev/xvdb1" successfully created

[root@db1 ~]# 

[root@db1 ~]# vgextend VolGroup /dev/xvdb1

  Volume group "VolGroup" successfully extended

[root@db1 ~]# 

[root@db1 ~]# vgdisplay

  --- Volume group ---

  VG Name               VolGroup

  System ID             

  Format                lvm2

  Metadata Areas        2

  Metadata Sequence No  4

  VG Access             read/write

  VG Status             resizable

  MAX LV                0

  Cur LV                2

  Open LV               2

  Max PV                0

  Cur PV                2

  Act PV                2

  VG Size               99.50 GiB

  PE Size               4.00 MiB

  Total PE              25473

  Alloc PE / Size       4994 / 19.51 GiB

  Free  PE / Size       20479 / 80.00 GiB

  VG UUID               WgNnG3-6emx-ULfq-UCWD-Ca27-KAEx-dL7r3l

   

[root@db1 ~]# 

[root@db1 ~]# lvextend -l +100%FREE /dev/VolGroup/lv_root

  Extending logical volume lv_root to 95.60 GiB

  Logical volume lv_root successfully resized

[root@db1 ~]# 

[root@db1 ~]# lvdisplay

  --- Logical volume ---

  LV Path                /dev/VolGroup/lv_root

  LV Name                lv_root

  VG Name                VolGroup

  LV UUID                ZMnMQe-jWY7-09sS-jXX0-fL1V-pprq-0WpPXU

  LV Write Access        read/write

  LV Creation host, time localhost.localdomain, 2014-03-11 13:45:54 +0900

  LV Status              available

  # open                 1

  LV Size                95.60 GiB

  Current LE             24473

  Segments               2

  Allocation             inherit

  Read ahead sectors     auto

  - currently set to     256

  Block device           253:0

   

  --- Logical volume ---

  LV Path                /dev/VolGroup/lv_swap

  LV Name                lv_swap

  VG Name                VolGroup

  LV UUID                ZZSPps-ioYZ-ISdq-yjco-7Um6-dAkm-Sq0BHe

  LV Write Access        read/write

  LV Creation host, time localhost.localdomain, 2014-03-11 13:46:00 +0900

  LV Status              available

  # open                 1

  LV Size                3.91 GiB

  Current LE             1000

  Segments               1

  Allocation             inherit

  Read ahead sectors     auto

  - currently set to     256

  Block device           253:1

   

[root@db1 ~]# 

[root@db1 ~]# df -h

Filesystem            Size  Used Avail Use% Mounted on

/dev/mapper/VolGroup-lv_root

                       16G  2.3G   13G  16% /

tmpfs                 1.9G     0  1.9G   0% /dev/shm

/dev/xvda1            485M   54M  406M  12% /boot

[root@db1 ~]# 

[root@db1 ~]# resize2fs /dev/mapper/VolGroup-lv_root

resize2fs 1.41.12 (17-May-2010)

Filesystem at /dev/mapper/VolGroup-lv_root is mounted on /; on-line resizing required

old desc_blocks = 1, new_desc_blocks = 6

Performing an on-line resize of /dev/mapper/VolGroup-lv_root to 25060352 (4k) blocks.

The filesystem on /dev/mapper/VolGroup-lv_root is now 25060352 blocks long.


[root@db1 ~]# 

[root@db1 ~]# df -h

Filesystem            Size  Used Avail Use% Mounted on

/dev/mapper/VolGroup-lv_root

                       95G  2.3G   88G   3% /

tmpfs                 1.9G     0  1.9G   0% /dev/shm

/dev/xvda1            485M   54M  406M  12% /boot

[root@db1 ~]# 








'System > Linux' 카테고리의 다른 글

Live CD  (0) 2012.03.07
리눅스 명령어  (2) 2012.03.02
A typical north/southbridge layout  (0) 2011.11.02
일반 유저의 .rhosts 파일 생성 금지법  (0) 2011.11.01
TCP-Wrapper  (0) 2011.10.31
Posted by linuxism
,