It’s not difficult, but requires to read a documentation.
I would emulate this on loop devices
- Create images for the disks
$ truncate -s 1G disk1.raw
$ truncate -s 1G disk2.raw
- Create loop devices to emulate disks
$ sudo losetup -f disk1.raw
$ sudo losetup -f disk2.raw
- find which one loop devices has been created
$ losetup | grep disk
/dev/loop6 0 0 0 0 /home/ubuntu/disk1.raw 0 512
/dev/loop7 0 0 0 0 /home/ubuntu/disk2.raw 0 512
- enter to an lvm shell
$ sudo lvm
- Add a new disk
lvm> pvcreate /dev/loop6
Physical volume "/dev/loop6" successfully created.
- Create VG
lvm> vgcreate vg0 /dev/loop6
Volume group "vg0" successfully created
- Create LV
lvm> lvcreate -l 100%FREE vg0
Logical volume "lvol0" created.
- exit the lvm shell
lvm> exit
- find our new lvm device
$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
fd0 2:0 1 4K 0 disk
loop0 7:0 0 63.9M 1 loop /snap/core20/2105
loop1 7:1 0 63.9M 1 loop /snap/core20/2182
loop2 7:2 0 67.8M 1 loop /snap/lxd/22753
loop4 7:4 0 40.4M 1 loop /snap/snapd/20671
loop5 7:5 0 91.9M 1 loop /snap/lxd/24061
loop6 7:6 0 1G 0 loop
└─vg0-lvol0 253:0 0 1020M 0 lvm
loop7 7:7 0 1G 0 loop
loop8 7:8 0 38.8M 1 loop /snap/snapd/21465
sda 8:0 0 20G 0 disk
├─sda1 8:1 0 19.9G 0 part /
├─sda14 8:14 0 4M 0 part
└─sda15 8:15 0 106M 0 part /boot/efi
sr0 11:0 1 52K 0 rom
sr1 11:1 1 1024M 0 rom
- Format our new LVM volume
$ sudo mkfs -t ext4 /dev/mapper/vg0-lvol0
mke2fs 1.45.5 (07-Jan-2020)
Discarding device blocks: done
Creating filesystem with 261120 4k blocks and 65280 inodes
Filesystem UUID: f13cb690-c69c-43ae-90bc-36886da4b0b5
Superblock backups stored on blocks:
32768, 98304, 163840, 229376
Allocating group tables: done
Writing inode tables: done
Creating journal (4096 blocks): done
Writing superblocks and filesystem accounting information: done
- Mount a new lvm volume
$ sudo mkdir /mnt/storj
$ sudo mount /dev/mapper/vg0-lvol0 /mnt/storj
$ sudo chown $(id -u) /mnt/storj/
- copy some file to there (to emulate data)
$ cp disk2.raw /mnt/storj/
- make an md5sum file to check that file is not corrupted (this is not necessary, but allows to check that everything went well)
$ md5sum /mnt/storj/disk2.raw > /mnt/storj/disk2.raw.md5
- checking:
$ md5sum -c /mnt/storj/disk2.raw.md5
/mnt/storj/disk2.raw: OK
- Now we are going to add a new disk to move data.
$ sudo pvcreate /dev/loop7
Physical volume "/dev/loop7" successfully created.
- add it to vg0
$ sudo vgextend vg0 /dev/loop7
Volume group "vg0" successfully extended
- Mark the first disk to be not used anymore (any new data will go to the second disk)
$ sudo pvchange -xn /dev/loop6
Physical volume "/dev/loop6" changed
1 physical volume changed / 0 physical volumes not changed
- now order to move data from the original disk to a new one
$ sudo pvmove /dev/loop6
/dev/loop6: Moved: 32.55%
- wait until it finish (if something happen on this stage, except disk damaging, it is safe, you always can resume the move even after reboot)
/dev/loop6: Moved: 100.00%
- remove the first disk from vg0
$ sudo vgreduce vg0 /dev/loop6
Removed "/dev/loop6" from volume group "vg0"
- remove pv for the first disk
$ sudo pvremove /dev/loop6
Labels on physical volume "/dev/loop6" successfully wiped.
- now check, that data didn’t damage
$ md5sum -c /mnt/storj/disk2.raw.md5
/mnt/storj/disk2.raw: OK