Friday, September 28, 2018

ubuntu - Can't migrate logical volume to newly added physical volumes



I had a partition of 91GB added in a logical volume filled to 61GB. Now I got an external hard drive and added a couple of partitions 43GB and 26GB each to the logical volume.



I now want to move the data to these new pvs and repartition the original 91GB partition. I started out with pvmove -v /dev/sdxx but it says Insufficient free space. Not enough extents. I am confused. My vgdisplay shows me as 91.23GB allocated. Why?



Here's the partition table of my hard disk:



/dev/sda5   91G
/dev/sda1 58G



I have my /home as a logical volume with /dev/sda5 as physical volume.



I now have an external hard drive partition table as follows:



/dev/sdb1    43G
/dev/sdb2 26G
/dev/sdb3 80G



df -h /home gives:



Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/home-home--lvm
91G 61G 343M 100% /home


I want to remove /dev/sda5 from /home and repartition it. I have /dev/sdb1 and /dev/sdb2 free, so I want to add them to the lv home. How do I get this done?


Answer




I was initially naive enough to just add /dev/sdb1 and /dev/sdb2. And try pvmove on /dev/sda5.



Here are the steps that solved the problem:




  • Boot into maintenance mode, umount the /home


  • resize2fs to within the size the new
    partitions can hold. (here 68G).*


  • lvresize the logical volume.


  • Use pvmove /dev/sda1*



  • Now pvremove /dev/sda1

  • Format it as you please




    • -- Both highly time consuming operations.
      You can skip the pvmove and resize the partition following the instructions here. http://www.howtoforge.com/linux_resizing_ext3_partitions
      But then it involves tampering with the partition table, while the data is not backed up. So you better be aware of the risk involved.



No comments:

Post a Comment

hard drive - Leaving bad sectors in unformatted partition?

Laptop was acting really weird, and copy and seek times were really slow, so I decided to scan the hard drive surface. I have a couple hundr...