How to find which EBS volume is storing the data

456 Views Asked by At

I have created a ec2 instance and attached 3 ebs volumes to it, I have created a lvm on the 3 ebs volumes and mounted it to /var/lib/pgsql and then installed postgresql source 8.4 and configure it to /var/lib/pgsql/data/data1 and i have created a sample table on it and the data is been store in lvm volumes( /dev/mapper/vg_ebs-lv_ebs) . I want check on which ebs volumes the data is been stored, so that I can remove the rest unused volumes in such that way that it does not affect the postgresql database.

I have attached the photos of the work. enter image description here

  1. enter image description here

  2. enter image description here

  3. enter image description here

  4. Picture

Tried to check the details by pvdisplay, lvdisplay vgdisplay, and tried to make the volume full to 100% still not able to identify which ebs volumes the data is been stored.

Want to know if 1) the data is been stored in all the volumes, 2) in root volumes 2) or any specific volumes the data is stored.

1

There are 1 best solutions below

3
jurez On

Postgres data is in /var/lib/pgsql which falls under lv_ebs logical volume in vg_ebs volume group.

To provide space for this volume group, you have three physical volumes: /dev/sdf, dev/sdg and /dev/sdh.

In general, LVM decides which data from logical volume to put on which physical volume. Allocation is done by means of extents which are non-overlapping, continuous ranges of bytes, each having a starting offset and a length (similar to partitions). You can get the information about extent allocation of LVs with

lvs -o +seg_pe_ranges

In your case all the space in PVs has been allocated to your LV, so you cannot just remove PV from VG. What you need to do is:

  1. Unmount /var/lib/pgsql
  2. Use resize2fs to shrink your filesystem by at least the size of the PV that you want to remove
  3. Use lvreduce to shrink the size of LV to the reduced size of filesystem
  4. Use pvmove to move any active physical segments off of the PV being removed
  5. Use vgreduce to remove now empty PV from VG

Don't forget to back up your data first.