2

Used spaceI have LVM built like this

NAME                         MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sr0                           11:0    1 1024M  0 rom
vda                          252:0    0   10G  0 disk
└─vda1                       252:1    0   10G  0 part /
vdb                          252:16   0   10G  0 disk
└─pro103-home--files (dm-2)  253:2    0   10G  0 lvm  /home/pro103by
vdc                          252:32   0   50G  0 disk
└─pro103by--sql-mysql (dm-1) 253:1    0   90G  0 lvm  /data
vdd                          252:48   0   30G  0 disk
└─dbbackup-data (dm-0)       253:0    0   30G  0 lvm  /dbbackup
vde                          252:64   0   30G  0 disk
└─pro103by--sql-mysql (dm-1) 253:1    0   90G  0 lvm  /data
vdf                          252:80   0   10G  0 disk
└─pro103by--sql-mysql (dm-1) 253:1    0   90G  0 lvm  /data
vdg                          252:96   0  150G  0 disk
└─vdg1                       252:97   0  150G  0 part

Drives included in pro103by-sql volume group

lvs -o +devices /dev/pro103by-sql/mysql
  LV    VG           Attr       LSize  Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert Devices
  mysql pro103by-sql -wi-ao---- 89.99g                                                     /dev/vdc(0)
  mysql pro103by-sql -wi-ao---- 89.99g                                                     /dev/vde(0)
  mysql pro103by-sql -wi-ao---- 89.99g                                                     /dev/vdf(0)

Used space

pvs -o+pv_used
  PV         VG           Fmt  Attr PSize   PFree   Used
  /dev/vdb   pro103       lvm2 a--u  10.00g   4.00m  9.99g
  /dev/vdc   pro103by-sql lvm2 a--u  50.00g      0  50.00g
  /dev/vdd   dbbackup     lvm2 a--u  30.00g      0  30.00g
  /dev/vde   pro103by-sql lvm2 a--u  30.00g      0  30.00g
  /dev/vdf   pro103by-sql lvm2 a--u  10.00g      0  10.00g
  /dev/vdg1  pro103by-sql lvm2 a--u 150.00g 150.00g     0

I need to move data from all threee drives - /dev/vdc /dev/vde /dev/vdf to one much bigger I know how to move data from one drive to another wit pvmove but not sure if this would work in this case.

4
  • 1
    You cannot merge the contents of multiple drives this way. Each volume is logically a separate file system on a separate partition--and you cannot simply merge partition this way, either. The only thing you can do is copy each file and directory from each of the separate drives to the same full/path/to/file on the new and larger volume. The command cp has several options to assist in doing that--take a look at it's man page with man cp. (Or use mv instead of cp.) Commented Apr 26, 2021 at 9:18
  • 2
    @C.M. Considering they are all part of the same VG: already merged, it should be possible to relocate blocks to the empty disk at the LVM level without dealing with the filesystem level by using pvmove. It looks like OP just wants confirmation. The answer is always the same: do backups. Commented Apr 26, 2021 at 9:56
  • @A.B: That is true. As long as the OP just wants to move each logical partition/volume to a different VG, and not merge them in to one, then a pvmove should be fine. Though, my personal preference is to copy them rather than move them--and then delete the old ones after I am certain there were no errors. (In addition to making backups! -- Too many times I have lost data due to unexpected issues and power outages...) Commented Apr 26, 2021 at 12:29
  • 1
    @C.M. but there is one LV in one VG (over 4 PV). There's no change of VG here. Commented Apr 26, 2021 at 12:31

1 Answer 1

2

Disclaimer: do backups.

As the sum of the space used on the 3 first PVs (50+30+10=80g) amounts to less space than available on the 4th PV (150g), this is possible.

This isn't a complex task, the (1st and) 2nd example in pvmove's man page is for your case:

Move all physical extents that are used by simple LVs on the specified PV to free physical extents elsewhere in the VG.

pvmove /dev/sdb1

Use a specific destination PV when moving physical extents.

pvmove /dev/sdb1 /dev/sdc1

So adapted to your case, this can be done in three commands, one at a time:

pvmove /dev/vdc /dev/vdg1
pvmove /dev/vde /dev/vdg1
pvmove /dev/vdf /dev/vdg1

The man page also tells that this should not be done in parallel for a single LV. No harm would be done, but all moves wouldn't be complete and would have to be run again:

More than one pvmove can run concurrently if they are moving data from different source PVs, but additional pvmoves will ignore any LVs already in the process of being changed, so some data might not get moved.

This can be done online with the database running (behind the scene, the pvmove operation ensures a smooth migration by using temporary mirroring mappings etc. Details in the man page's notes.). But if that's not mandatory to keep the service running, better do backups and take the database offline before doing it: this allows to rollback from backups in case of unforeseen problems.

You can then verify that all the data is indeed in the PV /dev/vdg1 by running one of these commands:

pvdisplay --maps

or specifically:

pvdisplay --maps /dev/vdc
pvdisplay --maps /dev/vde
pvdisplay --maps /dev/vdf
pvdisplay --maps /dev/vdg1

which will then show used physical extents only in /dev/vdg1 (all for /dev/pro103by-sql/mysql).

The orthogonal command would be:

lvdisplay --maps /dev/pro103by-sql/mysql

which will then show that all its logical extents are in /dev/vdg1.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.