I'm on CentOS 7. I have data in vdb2. In vdb3, vdd and vde I don't have data. Is it possible to merge all 4 partitions and assign one mount point (/data1) without losing data?

[user@hbase2 ~]$ lsblk
sr0     11:0    1  1024M  0 rom  
vda    253:0    0    50G  0 disk 
└─vda1 253:1    0    50G  0 part /
vdb    253:16   0   450G  0 disk 
├─vdb1 253:17   0  46.6G  0 part /mnt/
├─vdb2 253:18   0 372.5G  0 part /data1
└─vdb3 253:19   0  30.9G  0 part 
vdc    253:32   0    20G  0 disk 
├─vdc1 253:33   0     4G  0 part /home
├─vdc2 253:34   0     4G  0 part /var/tmp
├─vdc3 253:35   0     4G  0 part /var/log
├─vdc4 253:36   0     4G  0 part /var/log/audit
└─vdc5 253:37   0     4G  0 part /var
vdd    253:48   0    20G  0 disk 
vde    253:64   0   250G  0 disk
[user@hbase2 ~]$ df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/vda1        50G   36G   15G  71% /
devtmpfs        3.9G     0  3.9G   0% /dev
tmpfs           3.9G     0  3.9G   0% /dev/shm
tmpfs           3.9G  385M  3.5G  10% /run
tmpfs           3.9G     0  3.9G   0% /sys/fs/cgroup
/dev/vdc5       3.9G  333M  3.4G   9% /var
/dev/vdc2       3.9G   16M  3.6G   1% /tmp
/dev/vdc3       3.9G  113M  3.5G   4% /var/log
/dev/vdb1        46G   53M   44G   1% /mnt/
/dev/vdc1       3.9G  222M  3.5G   6% /home
/dev/vdc4       3.9G   82M  3.6G   3% /var/log/audit
/dev/vdb2       367G  242G  106G  70% /data1
tmpfs           783M     0  783M   0% /run/user/1002

1 Answer 1


Yes, you can use LVM to put the four block devices into a pool, from which you can create a logical volume for your /data filesystem.

  1. Create partitions on vdd and vde. Technically not required, but recommended.
  2. Create an LVM volume group using the three unused partitions: vgcreate vg0 /dev/vdb3 /dev/vdd1 /dev/vde1
  3. Create a logical volume: lvcreate -l 100%FREE -n data1 vg0
  4. Create a filesystem on the logical volume. For example, using ext4: mkfs.ext4 -L DATA1 /dev/mapper/vg0-data1`
  5. Remote the /data1 filesystem in read-only mode, to make copying files safer: umount /data && mount -o ro /data1`
  6. Mount the new filesystem at a temporary location: mkdir /mnt/foo && mount -L DATA1 /mnt/foo
  7. Copy the files from /data1 to the temporary mountpoint: cp -av /data1/ /mnt/foo/
  8. Modify /etc/fstab so that it mounts /data1 from the new filesystem (the logical volume from step 3.
  9. Reboot and cross your fingers.
  10. Verify that the new filesystem is being mounted at /data1.
  11. Once you're satisfied, it's time to reclaim the old partition: wipefs /dev/vdb2 && vgextend vg0 /dev/vdb2 && lvextend vg0/data1 -r -l +100%FREE

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .