0

This is my existing disk partition.

[root@xyz  development: /root] lvs
  LV       VG     Attr       LSize  Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  repolv   repovg -wi-ao----  1.95t
  LogVol00 rootvg -wi-ao----  6.00g
  LogVol01 rootvg -wi-ao---- 10.00g
  LogVol02 rootvg -wi-ao---- 10.00g
  LogVol03 rootvg -wi-ao---- 15.00g
  LogVol04 rootvg -wi-ao----  8.00g
 
    [root@xyz development: /root] lsblk -p
    NAME                            MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
    /dev/sda                          8:0    0  100G  0 disk
    ├─/dev/sda1                       8:1    0  500M  0 part /boot
    └─/dev/sda2                       8:2    0 92.7G  0 part
      ├─/dev/mapper/rootvg-LogVol00 253:0    0    6G  0 lvm  /
      ├─/dev/mapper/rootvg-LogVol04 253:1    0    8G  0 lvm  [SWAP]
      ├─/dev/mapper/rootvg-LogVol03 253:3    0   15G  0 lvm  /var
      ├─/dev/mapper/rootvg-LogVol02 253:4    0   10G  0 lvm  /tmp
      └─/dev/mapper/rootvg-LogVol01 253:5    0   10G  0 lvm  /opt
    /dev/sdb                          8:16   0   50G  0 disk
    /dev/sdc                          8:32   0  1.5T  0 disk
    /dev/sdd                          8:48   0  1.5T  0 disk
    └─/dev/mapper/repovg-repolv     253:2    0    2T  0 lvm  /var/www/html
    /dev/sde                          8:64   0  1.5T  0 disk
    └─/dev/mapper/repovg-repolv     253:2    0    2T  0 lvm  /var/www/html
    /dev/sdf                          8:80   0  1.5T  0 disk
    └─/dev/mapper/repovg-repolv     253:2    0    2T  0 lvm  /var/www/html
    /dev/sdg                          8:96   0  1.5T  0 disk
    /dev/sdh                          8:112  0  1.5T  0 disk
    /dev/sr0                         11:0    1 1024M  0 rom
    
    
    [root@ development: /root] pvs | grep repovg
      PV         VG     Fmt  Attr   PSize    PFree
      /dev/sdc   repovg lvm2 a--    1.46t    1.46t
      /dev/sdd   repovg lvm2 a--    1.46t  500.00g
      /dev/sde   repovg lvm2 a--    1.46t 1000.00g
      /dev/sdf   repovg lvm2 a--    1.46t 1000.00g
      /dev/sdg   repovg lvm2 a--    1.46t    1.46t
      /dev/sdh   repovg lvm2 a--    1.46t    1.46t
  1. First of all I can't figure out how 2.0T came in below. If we see lsblk output /var/www/html spread across /dev/sdd, /dev/sde and /dev/sdf. Then as per math it should be 6.0T.
[root@xyz development: /root] df -h /var/www/html/
  FileSystem                  Size  Usage Free   Usage% Mount Point
  /dev/mapper/repovg-repolv   2.0T  1.7T  263G   87%   /var/www/html
  1. Secondly, Since new disk has been added I wanted to move /var/www/html data to other disks and to restructure/move mount point as below. Could you please guide all the sequence of commands.
FileSystem
/dev/sdc : repovg-rhel6lv    -> Mount to /var/www/html/RHEL6
/dev/sdd : repovg-rhel7lv    -> Mount to /var/www/html/RHEL7
/dev/sde : repovg-rhel7awslv -> Mount to /var/www/html/RHEL7AWS
/dev/sdf : repovg-rhel8lv    -> Mount to /var/www/html/RHEL8
/dev/sdg : repovg-amzn24lv -> Mount to /var/www/html/AMZN24
/dev/sdh : repovg-amzn24lv -> Mount to /var/www/html/AMZN24
8
  • Have you read up on pvmove? Commented Apr 12, 2023 at 8:30
  • yeah I saw some video on it. I know how to move entire disk to another disk . Ex: pvmove /dev/sdb1 /dev/sdd1 will move data from sdb1 to sdd1. But in my case there are subdirectory under /varr/www/html .. so not sure what are the sequence of command to do.. since it is disk partitioning in prod i dont want to take chance
    – user984993
    Commented Apr 12, 2023 at 8:45
  • 2
    Do you understand the relationship between filesystem, logical volume (LV), volume group (VG), and physical volume (PV)? Commented Apr 12, 2023 at 8:53
  • Basics I know PV->VG -> LV & then mount the filesystem. first we create PV then VG and then LV and create Filesystem and mount .. Here I can see the till VG is already exists.. I think I need to work from LV ?
    – user984993
    Commented Apr 12, 2023 at 8:57
  • Q1: /var/www/html is spread accross /dev/sdd (1Tb) and /dev/sde /dev/sdf (both 500 Gb)
    – Archemar
    Commented Apr 12, 2023 at 9:38

1 Answer 1

1

Right now you have one LV, "repolv", containing a filesystem which you want to split into smaller parts such as "rhel6lv", "rhel7lv", etc. And then you want to migrate each of these new LVs to individual physical disks.

The general approach is as follows:

  1. Create a new LV for each new filesystem that now needs its own separate mount point
  2. Move the data across
  3. Migrate the LVs to their respective physical disks (although I would ask whether it really matters on which disk any given LV resides)

Test the following with throwaway data. Do not apply it to production data until you are totally sure that it achieves your requirement.

Create a bind mount for the original filesystem:

mkdir /mnt/vwh
mount --bind /var/www/html /mnt/vwh               # Bind mount

Now repeat a variation of this block for each of your new LVs/filesystems. Check the appropriate LV size, filesystem type and label, and final physical disk before commencing:

lvcreate --name rhel6lv --size 10G /dev/repovg    # Check size
mkfs -t ext4 --label rhel6 /dev/repovg/rhel6lv    # Check filesystem type and label name

mv /var/www/html/RHEL6 /var/www/html/RHEL6.old    # Save the original data
mkdir /var/www/html/RHEL6                         # Create mountpoint
mount /dev/repovg/rhel6lv /var/www/html/RHEL6     # Mount new filesystem
cp -a /mnt/vwh/RHEL6.old/. /var/www/html/RHEL6 &&
    rm -rf /mnt/vwh/RHEL6.old                     # Move data

pvmove --name rhel6lv /dev/sdc                    # Move extents for this LV to the required target disk

If you don't have any (hidden) dot files in /mnt/vwh/RHEL6.old you could replace the cp … && rm … with mv /mnt/vwh/RHEL6.old/* /var/www/html/RHEL6.

With this number of disks I would strongly recommend you consider RAID to protect against hardware failure. And backups. Lots of backups. Especially a backup before you start in case it all goes horribly wrong.

0

You must log in to answer this question.

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