D
D
DigitalViking2020-06-22 18:01:59
linux
DigitalViking, 2020-06-22 18:01:59

How to transfer data between different VGs in centos 7?

Hello colleagues, the question arose of how I can transfer the data. There is a server on centos 7, it has the following file structure

NAME                          MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda                             8:0    0    50G  0 disk 
+-sda1                          8:1    0     1G  0 part /boot
L-sda2                          8:2    0    49G  0 part 
  +-centos-root               253:0    0    44G  0 lvm  /
  L-centos-swap               253:1    0     5G  0 lvm  
sdb                             8:16   0   359G  0 disk 
L-sdb1                          8:17   0   359G  0 part 
  +-x-thin_tmeta           253:2    0    92M  0 lvm  
  ¦ L-x-thin-tpool         253:4    0 358.8G  0 lvm  
  ¦   +-x-thin             253:5    0 358.8G  0 lvm  
  ¦   L-x-var--lib         253:6    0   358G  0 lvm  /var/lib
  L-x-thin_tdata           253:3    0 358.8G  0 lvm  
    L-x-thin-tpool         253:4    0 358.8G  0 lvm  
      +-x-thin             253:5    0 358.8G  0 lvm  
      L-x-var--lib         253:6    0   358G  0 lvm  /var/lib
sdc                             8:32   0   359G  0 disk 
L-sdc1                          8:33   0   359G  0 part 
  L-bd-bd                   253:7    0   359G  0 lvm  /var/lib/ms/01/bd
sdd                             8:48   0 600.1G  0 disk 
L-sdd1                          8:49   0 600.1G  0 part 
  L-bd1-bd1 253:8    0 600.1G  0 lvm  /var/lib/ms/01/bd_1


I need to transfer everything that is (data) on sdb1 to sdd1, i.e. specifically, it turns out the data that lies here / var / lib, then the sdb1 disk will be deleted.

Here is what lvs shows
LV           VG           Attr       LSize    Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  bd bd-wi-ao---- <359.00g                                                    
  root         centos       -wi-ao----  <44.00g                                                    
  swap         centos       -wi-a-----    5.00g                                                    
  thin         x twi-aotz-- <358.82g             99.76  58.76                           
  var-lib      x         Vwi-aotz--  358.00g thin        99.98                                  
  bd1 bd1-wi-ao----  600.07g


lvscan output
ACTIVE            '/dev/x/thin' [<358.82 GiB] inherit
  ACTIVE            '/dev/x/var-lib' [358.00 GiB] inherit
  ACTIVE            '/dev/centos/swap' [5.00 GiB] inherit
  ACTIVE            '/dev/centos/root' [<44.00 GiB] inherit
  ACTIVE            '/dev/bd/bd' [<359.00 GiB] inherit
  ACTIVE            '/dev/bd1/bd' [600.07 GiB] inherit


what pvscan shows
PV /dev/sdb1   VG x lvm2 [<359.00 GiB / 0    free]
  PV /dev/sda2   VG centos          lvm2 [<49.00 GiB / 0    free]
  PV /dev/sdc1   VG bd lvm2 [<359.00 GiB / 0    free]
  PV /dev/sdd1   VG bd1 lvm2 [600.07 GiB / 0    free]
  Total: 4 [<1.34 TiB] / in use: 4 [<1.34 TiB] / in no VG: 0 [0   ]


So I'm stuck on how to properly migrate data to PV /dev/sdd1

Tried using snapshots
lvcreate --snapshot --name var-1 --size 1G  /dev/x/var-lib

But since the whole place is reserved, I get an error
Volume group "x" has insufficient free space (0 extents): 256 required

Resize didn't work either.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
shurshur, 2020-06-22
@shurshur

If the pv's were in the same vg, a pvmove could be done to release the desired pv.
As for resizing, many file systems do not know how to online resize downwards (and some, like xfs, and offline do not know how to reduce), so the file system will have to be unmounted, it will not be possible to resize it "live".
A possible option, if you need to urgently free the disk (for example, it dies): temporarily add another disk, which you add to the same vg, then pvmove it and then delete the first one. And then figure it out.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question