참조: http://kit2013.tistory.com/199


# dd sparse image

]# dd if=/dev/zero of=test1.img bs=10M count=0 seek=1K 

]# dd if=/dev/zero of=test2.img bs=10M count=0 seek=1K


]# ls -alh

-rw-r--r--   1 root  root   10G Jan 12 14:28 test1.img

-rw-r--r--   1 root  root   10G Jan 12 14:28 test2.img


]# du -sh *

0       test1.img

0       test2.img


# losetup 

]# losetup -a

/dev/loop0: [2051]:1316303 (/opt/stack/data/stack-volumes-default-backing-file)

/dev/loop1: [2051]:1316304 (/opt/stack/data/stack-volumes-lvmdriver-1-backing-file)


]# losetup /dev/loop2 test1.img 

[root@localhost home]# losetup -a

/dev/loop0: [2051]:1316303 (/opt/stack/data/stack-volumes-default-backing-file)

/dev/loop1: [2051]:1316304 (/opt/stack/data/stack-volumes-lvmdriver-1-backing-file)

/dev/loop2: [2050]:12 (/home/test1.img)


]# pvscan 

  PV /dev/loop1   VG stack-volumes-lvmdriver-1   lvm2 [10.01 GiB / 8.01 GiB free]

  PV /dev/loop0   VG stack-volumes-default       lvm2 [10.01 GiB / 10.01 GiB free]

  Total: 2 [20.02 GiB] / in use: 2 [20.02 GiB] / in no VG: 0 [0   ]


]# pvcreate /dev/loop2

  Physical volume "/dev/loop2" successfully created.

[root@localhost home]# pvscan 

  PV /dev/loop1   VG stack-volumes-lvmdriver-1   lvm2 [10.01 GiB / 8.01 GiB free]

  PV /dev/loop0   VG stack-volumes-default       lvm2 [10.01 GiB / 10.01 GiB free]

  PV /dev/loop2                                  lvm2 [10.00 GiB]

  Total: 3 [30.02 GiB] / in use: 2 [20.02 GiB] / in no VG: 1 [10.00 GiB]


]# vgscan 

  Reading volume groups from cache.

  Found volume group "stack-volumes-lvmdriver-1" using metadata type lvm2

  Found volume group "stack-volumes-default" using metadata type lvm2

[root@localhost home]# vgdisplay

  --- Volume group ---

  VG Name               stack-volumes-lvmdriver-1

  System ID             

  Format                lvm2

  Metadata Areas        1

  Metadata Sequence No  7

  VG Access             read/write

  VG Status             resizable

  MAX LV                0

  Cur LV                2

  Open LV               1

  Max PV                0

  Cur PV                1

  Act PV                1

  VG Size               10.01 GiB

  PE Size               4.00 MiB

  Total PE              2562

  Alloc PE / Size       512 / 2.00 GiB

  Free  PE / Size       2050 / 8.01 GiB

  VG UUID               Evn3J0-O09c-9dei-2eKI-Y8Yl-lwhF-FqvTlb

   

  --- Volume group ---

  VG Name               stack-volumes-default

  System ID             

  Format                lvm2

  Metadata Areas        1

  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                1

  Act PV                1

  VG Size               10.01 GiB

  PE Size               4.00 MiB

  Total PE              2562

  Alloc PE / Size       0 / 0   

  Free  PE / Size       2562 / 10.01 GiB

  VG UUID               jsQjQe-wiwI-1ZA2-lvBY-flvp-Bn5G-CGJrb1


]# vgcreate vg1 /dev/loop2

  Volume group "vg1" successfully created

[root@localhost home]# vgscan                 

  Reading volume groups from cache.

  Found volume group "stack-volumes-lvmdriver-1" using metadata type lvm2

  Found volume group "vg1" using metadata type lvm2

  Found volume group "stack-volumes-default" using metadata type lvm2

[root@localhost home]# vgdisplay              

  --- Volume group ---

  VG Name               stack-volumes-lvmdriver-1

  System ID             

  Format                lvm2

  Metadata Areas        1

  Metadata Sequence No  7

  VG Access             read/write

  VG Status             resizable

  MAX LV                0

  Cur LV                2

  Open LV               1

  Max PV                0

  Cur PV                1

  Act PV                1

  VG Size               10.01 GiB

  PE Size               4.00 MiB

  Total PE              2562

  Alloc PE / Size       512 / 2.00 GiB

  Free  PE / Size       2050 / 8.01 GiB

  VG UUID               Evn3J0-O09c-9dei-2eKI-Y8Yl-lwhF-FqvTlb

   

  --- Volume group ---

  VG Name               vg1

  System ID             

  Format                lvm2

  Metadata Areas        1

  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                1

  Act PV                1

  VG Size               10.00 GiB

  PE Size               4.00 MiB

  Total PE              2559

  Alloc PE / Size       0 / 0   

  Free  PE / Size       2559 / 10.00 GiB

  VG UUID               qCfSGd-ymgV-DWJz-p35j-ZHNr-gCIK-Pgcaw3

   

  --- Volume group ---

  VG Name               stack-volumes-default

  System ID             

  Format                lvm2

  Metadata Areas        1

  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                1

  Act PV                1

  VG Size               10.01 GiB

  PE Size               4.00 MiB

  Total PE              2562

  Alloc PE / Size       0 / 0   

  Free  PE / Size       2562 / 10.01 GiB

  VG UUID               jsQjQe-wiwI-1ZA2-lvBY-flvp-Bn5G-CGJrb1


]# lvcreate -n vg1_lo1 -L 1G vg1  

  Logical volume "vg1_lo1" created.

[root@localhost home]# vgdisplay vg1

  --- Volume group ---

  VG Name               vg1

  System ID             

  Format                lvm2

  Metadata Areas        1

  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                1

  Act PV                1

  VG Size               10.00 GiB

  PE Size               4.00 MiB

  Total PE              2559

  Alloc PE / Size       256 / 1.00 GiB

  Free  PE / Size       2303 / 9.00 GiB

  VG UUID               qCfSGd-ymgV-DWJz-p35j-ZHNr-gCIK-Pgcaw3


]# fdisk  -l


Disk /dev/mapper/vg1-vg1_lo1: 1073 MB, 1073741824 bytes, 2097152 sectors

Units = sectors of 1 * 512 = 512 bytes

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

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



## add 

]# losetup /dev/loop3 test2.img 

[root@localhost home]# losetup -a

/dev/loop0: [2051]:1316303 (/opt/stack/data/stack-volumes-default-backing-file)

/dev/loop1: [2051]:1316304 (/opt/stack/data/stack-volumes-lvmdriver-1-backing-file)

/dev/loop2: [2050]:12 (/home/test1.img)

/dev/loop3: [2050]:13 (/home/test2.img)


]# pvcreate /dev/loop3

  WARNING: Not using lvmetad because duplicate PVs were found.

  WARNING: Use multipath or vgimportclone to resolve duplicate PVs?

  WARNING: After duplicates are resolved, run "pvscan --cache" to enable lvmetad.

  Physical volume "/dev/loop3" successfully created.


]# pvdisplay 

  WARNING: Not using lvmetad because duplicate PVs were found.

  WARNING: Use multipath or vgimportclone to resolve duplicate PVs?

  WARNING: After duplicates are resolved, run "pvscan --cache" to enable lvmetad.

  --- Physical volume ---

  PV Name               /dev/loop2

  VG Name               vg1

  PV Size               10.00 GiB / not usable 4.00 MiB

  Allocatable           yes 

  PE Size               4.00 MiB

  Total PE              2559

  Free PE               2303

  Allocated PE          256

  PV UUID               9l5ff5-zqk7-qH8n-IEx9-tgjG-2Cjg-CT2L41

   

  --- Physical volume ---

  PV Name               /dev/loop1

  VG Name               stack-volumes-lvmdriver-1

  PV Size               10.01 GiB / not usable 2.00 MiB

  Allocatable           yes 

  PE Size               4.00 MiB

  Total PE              2562

  Free PE               2050

  Allocated PE          512

  PV UUID               DVNkcA-Syfm-5du0-0XFe-QnIE-D5zi-9h23wK

   

  --- Physical volume ---

  PV Name               /dev/loop0

  VG Name               stack-volumes-default

  PV Size               10.01 GiB / not usable 2.00 MiB

  Allocatable           yes 

  PE Size               4.00 MiB

  Total PE              2562

  Free PE               2562

  Allocated PE          0

  PV UUID               TOdLHi-diqH-I9eb-eJ6A-jv3P-YXUx-geAIwx

   

  "/dev/loop3" is a new physical volume of "10.00 GiB"

  --- NEW Physical volume ---

  PV Name               /dev/loop3

  VG Name               

  PV Size               10.00 GiB

  Allocatable           NO

  PE Size               0   

  Total PE              0

  Free PE               0

  Allocated PE          0

  PV UUID               PL6niV-hc1Y-JLTz-zx7k-8rlL-WHIf-8ekmvg


]# vgextend vg1 /dev/loop3 

  WARNING: Not using lvmetad because duplicate PVs were found.

  WARNING: Use multipath or vgimportclone to resolve duplicate PVs?

  WARNING: After duplicates are resolved, run "pvscan --cache" to enable lvmetad.

  Volume group "vg1" successfully extended


]# vgdisplay  vg1

  WARNING: Not using lvmetad because duplicate PVs were found.

  WARNING: Use multipath or vgimportclone to resolve duplicate PVs?

  WARNING: After duplicates are resolved, run "pvscan --cache" to enable lvmetad.

  --- Volume group ---

  VG Name               vg1

  System ID             

  Format                lvm2

  Metadata Areas        2

  Metadata Sequence No  3

  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               19.99 GiB

  PE Size               4.00 MiB

  Total PE              5118

  Alloc PE / Size       256 / 1.00 GiB

  Free  PE / Size       4862 / 18.99 GiB

  VG UUID               qCfSGd-ymgV-DWJz-p35j-ZHNr-gCIK-Pgcaw3


]# lvextend -L+10G /dev/vg1/vg1_lo1     

  WARNING: Not using lvmetad because duplicate PVs were found.

  WARNING: Use multipath or vgimportclone to resolve duplicate PVs?

  WARNING: After duplicates are resolved, run "pvscan --cache" to enable lvmetad.

  Size of logical volume vg1/vg1_lo1 changed from 1.00 GiB (256 extents) to 11.00 GiB (2816 extents).

  Logical volume vg1/vg1_lo1 successfully resized.


fdisk -l /dev/mapper/vg1-vg1_lo1 


Disk /dev/mapper/vg1-vg1_lo1: 11.8 GB, 11811160064 bytes, 23068672 sectors

Units = sectors of 1 * 512 = 512 bytes

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

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


## remove


]# lvremove /dev/vg1/vg1_lo1

  WARNING: Not using lvmetad because duplicate PVs were found.

  WARNING: Use multipath or vgimportclone to resolve duplicate PVs?

  WARNING: After duplicates are resolved, run "pvscan --cache" to enable lvmetad.

Do you really want to remove active logical volume vg1/vg1_lo1? [y/n]: y

  Logical volume "vg1_lo1" successfully removed


]# vgremove vg1

  WARNING: Not using lvmetad because duplicate PVs were found.

  WARNING: Use multipath or vgimportclone to resolve duplicate PVs?

  WARNING: After duplicates are resolved, run "pvscan --cache" to enable lvmetad.

  Volume group "vg1" successfully removed


]# pvremove /dev/loop2 /dev/loop3

  WARNING: Not using lvmetad because duplicate PVs were found.

  WARNING: Use multipath or vgimportclone to resolve duplicate PVs?

  WARNING: After duplicates are resolved, run "pvscan --cache" to enable lvmetad.

  Labels on physical volume "/dev/loop2" successfully wiped.

  Labels on physical volume "/dev/loop3" successfully wiped.


]# losetup -d /dev/loop2

[root@localhost home]# losetup -d /dev/loop3

[root@localhost home]# losetup -a

/dev/loop0: [2051]:1316303 (/opt/stack/data/stack-volumes-default-backing-file)

/dev/loop1: [2051]:1316304 (/opt/stack/data/stack-volumes-lvmdriver-1-backing-file)


'Virtualization' 카테고리의 다른 글

ceph  (0) 2017.01.19
kvm install  (0) 2017.01.03

+ Recent posts