Tag Archives: lvm

How to Add Physical Disk to Increase Size of /dev/mapper/centos-root

Dear Friends,

I ran into a problem where my openstack machine ran out of space. My Logical FS /dev/mapper/centos-root was only 50GB and most of the space was lost.

Solution:
LVM

I Added a new 500GB HDD (sdb), created partition with parted (sdb1) and gave the below commands:

[root@stack opt]# pvcreate /dev/sdb1
Physical volume "/dev/sdb1" successfully created

Next Check your Volumes with “vgdisplay” command

[root@stack opt]# vgdisplay 
 --- Volume group ---
 VG Name centos
 System ID 
 Format lvm2
 Metadata Areas 1
 Metadata Sequence No 4
 VG Access read/write
 VG Status resizable
 MAX LV 0
 Cur LV 3
 Open LV 3
 Max PV 0
 Cur PV 1
 Act PV 1
 VG Size 465.27 GiB
 PE Size 4.00 MiB
 Total PE 119109
 Alloc PE / Size 119109 / 465.27 GiB
 Free PE / Size 0 / 0 
 VG UUID TrvUI3-Xt7U-6vzF-5RtW-OfK0-OCOy-Tejrb6
 
 --- Volume group ---
 VG Name cinder-volumes
 System ID 
 Format lvm2
 Metadata Areas 1
 Metadata Sequence No 5
 VG Access read/write
 VG Status resizable
 MAX LV 0
 Cur LV 0
 Open LV 0
 Max PV 0
 Cur PV 1
 Act PV 1
 VG Size 20.60 GiB
 PE Size 4.00 MiB
 Total PE 5273
 Alloc PE / Size 0 / 0 
 Free PE / Size 5273 / 20.60 GiB
 VG UUID 9LDtLm-52Un-1QJA-yc3q-13vE-LqEc-hX0kiU

Continue reading

Recovery of the File System from Disaster

Hey Guys, long time no see…Well i am back and this time the issue is File System.

What Happened ?

Well My Backup Server’s root partition ran out of space due to some issue, and since it was on LVM (Logical Volume Manager) i took some space from my /home partition (it was 400 GB ) and added to my root partition. Following commands were used to resize the partition.

umount /dev/mapper/centos-home

lvreduce -L 200G /dev/mapper/centos-home

Note first i unmounted the partition and then reduced the space from my /home partition which was mounted as /centos-home
I took 200 GB out of it and added to my root partition.

The Mistake: I forgot to remount /home to /dev/mapper/centos-home

But i extended the partition with the following command:

lvextend -r -l+100%FREE /dev/mapper/centos-root

As per above command the partition will be re-sized to the 100% free space available from the reduced volume. Of course it was 200 GB. All was good when i saw the partition sized changed from no space to +200 GB. But then i realized that i was not able to mount /home to /centos-home and that was the time when all problem started. I “Rebooted The Machine” and when it came back it refused to enter the normal boot prompt but went into “Emergency mode”

Things i Tried:

I tried to fix the partition with xfs_repair tool , but in vain , and i received the error that “Cannot Find Super Block “

I tried to run the fixes couple of time but failed every time.

The Fix:

I fixed the issue by the following commands:

lvremove /dev/mapper/centos-home
lvcreate -L 200GB -n home centos

mkfs.xfs /dev/centos/home

mount /dev/mapper/centos-home

Luckily there was no important data on my /home partition and i was able to save my server.

Good Practice:

If you every fall prey to such situation, remember to “Backup” to an external drive and then proceed with the above mentioned technique to rescue yourself from such difficult situation.

I hope it will help some one some where, Let me know with your feedback.

Thanks & Best Regards,

Salman A. Francis