1

I have a disk. I want to convert it to LVM, so I can add another disk to it -- to increase storage.

It is not a system disk or anything, it is formatted using xfs and just stores data.

Here is the info

/dev/sdc                           932G   32G  900G   4% /gluster/bricks/1
Disk /dev/sdc: 931.5 GiB, 1000204886016 bytes, 1953525168 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

So what I wanted to do is add another physical disk and the system sees it as one.

Can anyone help with some simple steps without losing the data on there.

I did try pvcreate but I got the disk was mounted.

I kind of don't know what I am doing - so I thought I would reach out.

I mean it is not a system disks, it is just a extra disk that I want to convert to LVM, so I can extend it using another physical disk.

If I can provide more details then please let me know, I only provided the above 2 command outputs.

1
  • 2
    pvcreate on /dev/sdc would lose your data... set up LVM on a new drive, and then migrate data. Mar 14, 2020 at 17:32

1 Answer 1

1

What you can do is set up an LVM logical volume on the new disk, copy the xfs filesystem to the new logical volume, replace the old xfs with an LVM physical volume, and then add the new physical volume to the LVM volume group. Finally, you can resize the new logical volume to give it more storage space. This would effectively allow the new xfs filesystem to span across both disks.

WARNING: Before proceeding I recommend making a backup of your data.

  1. Install the new disk. As an example, let's say it's called /dev/sdd.
  2. Create a partition table (ex. GPT) and a partition. You can use tools like cfdisk, parted, or gparted
  3. Create a physical volume on the new disk and a volume group. For example, let's call the volume group vg0: vgcreate vg0 /dev/sdd1
  4. Create a logical volume: lvcreate -ay -L 931.5G -n gluster vg0
  5. Stop the gluster service and unmount the gluster xfs filesystem.
  6. Copy the xfs filesystem to the logical volume: xfs_copy /dev/sdc /dev/vg0/gluster
  7. Do a quick wipe of the old xfs filesystem: wipefs /dev/sdc
  8. Add the old drive to the volume group: vgextend vg0 /dev/sdc
  9. Edit /etc/fstab so that the xfs filesystem gets mounted from /dev/mapper/vg0-gluster
  10. Cross your fingers and reboot.

If all goes well everything will be as before, except you'll have an LVM volume group which consists of the storage capacity of both disks. You can then use lvextend to increase the size of the xfs filesystem.

2
  • Thank you. I will give it a go. If I remove the drive from gluster, and then do everything and add it back to the gluster volume - maybe i wont lose data :-) But I think I will go with the more secure way and use another disk. Thanks for all your help.
    – Martin
    Mar 16, 2020 at 16:58
  • Actually you would use data because a partition is not the same thing as a physical volume; The data is not stored in the same place on-disk. Mar 18, 2020 at 4:16

You must log in to answer this question.

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