LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Enterprise Linux Forums > Linux - Enterprise
User Name
Password
Linux - Enterprise This forum is for all items relating to using Linux in the Enterprise.

Notices


Reply
  Search this Thread
Old 09-18-2015, 08:52 AM   #1
Mark_667
Member
 
Registered: Aug 2005
Location: Manchester, England
Distribution: Ubuntu 20.04
Posts: 377

Rep: Reputation: 30
Unable to resize PV in LVM in RHEL 6.3


I have a RHEL 6.3 Hyper-V VM which is complaining it's out of disk space. I expanded the VHD from 12GB to 15GB in Hyper-V which says the current file size is 8GB. Oddly lvdisplay gives an LV Size of 7.57 GiB. Unfortunately it's using LVM and I haven't been able to get any GUI tools to manage it and I know very little about it. Disk Utility recognises the 12GB LVM2 physical volume and the additional 3GB of free space at the end of the device but doesn't allow me to extend into it.

pvresize /dev/sda2 fails because there's no space left on the device. How can I get it to use the new disk space? Why was it complaining about not having enough disk space when it's only using 8GB of the 12GB available?
 
Old 09-18-2015, 10:03 AM   #2
custangro
Senior Member
 
Registered: Nov 2006
Location: California
Distribution: Fedora , CentOS , RHEL
Posts: 1,978
Blog Entries: 1

Rep: Reputation: 209Reputation: 209Reputation: 209
Quote:
Originally Posted by Mark_667 View Post
I have a RHEL 6.3 Hyper-V VM which is complaining it's out of disk space. I expanded the VHD from 12GB to 15GB in Hyper-V which says the current file size is 8GB. Oddly lvdisplay gives an LV Size of 7.57 GiB. Unfortunately it's using LVM and I haven't been able to get any GUI tools to manage it and I know very little about it. Disk Utility recognises the 12GB LVM2 physical volume and the additional 3GB of free space at the end of the device but doesn't allow me to extend into it.

pvresize /dev/sda2 fails because there's no space left on the device. How can I get it to use the new disk space? Why was it complaining about not having enough disk space when it's only using 8GB of the 12GB available?
You need to drop into fdisk/parted and extend the /dev/sda2 partition before you do the pvresize.

Another option is to create /dev/sda3 with the remaining space and do

Code:
vgextend vg0 /dev/sda3
Then run your lvextend command

Code:
lvexted vg00/lv_volume -l +100%FREE
 
Old 09-18-2015, 10:27 AM   #3
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,831
Blog Entries: 15

Rep: Reputation: 1668Reputation: 1668Reputation: 1668Reputation: 1668Reputation: 1668Reputation: 1668Reputation: 1668Reputation: 1668Reputation: 1668Reputation: 1668Reputation: 1668
We did this on a RHEL 6.5 last year based on information we'd found at:
http://earlruby.org/2010/10/increasi...out-rebooting/

It appeared from the link above that we could do a pvresize on a PV if it becomes larger. The example shown in the link relates to Multipath and SAN rather than virtual device but the principle should be the same. We just didnít need to do the multipath steps shown.


We shutdown our RHEL6 guest to allow the MS Hyper-V manager to do increase the disk size on the Hyper-V side.

He increased the device from 100 Gb to 320 Gb.

Once he did that we powered our RHEL6 guest back up.

'pvs' still displayed the disk as ~100 Gb (shown here):
[root@server]# pvs
PV VG Fmt Attr PSize PFree
/dev/sda2 vg00 lvm2 a-- 99.51g 35.66g
/dev/sdb vg01 lvm2 a-- 99.97g 0

Next we did a 'pvresize /dev/sdb' to resize the disk which output the following:
Physical volume "/dev/sdb" changed
1 physical volume(s) resized / 0 physical volume(s) not resized

After that pvs displayed the new size:
[root@server]# pvs
PV VG Fmt Attr PSize PFree
/dev/sda2 vg00 lvm2 a-- 99.51g 35.66g
/dev/sdb vg01 lvm2 a-- 319.97g 220.00g

Next we extended the logical volume lvdata to 320 Gb
'lvextend -l +100%FREE /dev/mapper/vg01-lvdata' which output:
Extending logical volume lv10g to 300.00 GiB
Logical volume lvdata successfully resized

Next resized the filesystem:
'resize2fs /dev/mapper/vg01-lvdata' which output:

resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/mapper/vg01-lvdata is mounted on /appl_top;
on-line resizing required
old desc_blocks = 5, new_desc_blocks = 19
Performing an on-line resize of /dev/mapper/vg01-lvdata to
78643200 (4k) blocks.
The filesystem on /dev/mapper/vg01-lvdata is now 78643200 blocks
long.
 
Old 09-21-2015, 09:38 AM   #4
Mark_667
Member
 
Registered: Aug 2005
Location: Manchester, England
Distribution: Ubuntu 20.04
Posts: 377

Original Poster
Rep: Reputation: 30
I tried pvresize but this failed the first time because there wasn't enough space to create a temporary file, then it failed a second time for some other reason so I just used gparted from an Ubuntu live CD to do the resize. I then ran lvexted -l +100%FREE vg00/lv_root which resized it to 10.5GB when the PV size was 15GB (pvs output confirms this). df output shows the lv_root as 100% used. What am I doing wrong here?
 
Old 09-21-2015, 02:07 PM   #5
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,831
Blog Entries: 15

Rep: Reputation: 1668Reputation: 1668Reputation: 1668Reputation: 1668Reputation: 1668Reputation: 1668Reputation: 1668Reputation: 1668Reputation: 1668Reputation: 1668Reputation: 1668
Maybe you put the actual commands you are running along with the outputs as there may be something you're doing incorrectly that isn't obvious from your posts.

What is the actual output of pvs? vgs? lvs? What is the actual output of "parted /dev/sd[alpha] print" for the disk listed as PV?

Did you boot from the Ubuntu live or did you mount it and run gparted?
 
Old 09-22-2015, 04:29 AM   #6
Mark_667
Member
 
Registered: Aug 2005
Location: Manchester, England
Distribution: Ubuntu 20.04
Posts: 377

Original Poster
Rep: Reputation: 30
Quote:
Maybe you put the actual commands you are running along with the outputs as there may be something you're doing incorrectly that isn't obvious from your posts.
Sorry, couldn't capture these but see below for the command output as they are now.
Code:
#pvs
PV	VG			Fmt	Attr	PSize	PFree
/dev/sda2	vg_server	lvm2	a--	14.51g	0

#vgs
VG		#PV	#LV	#SN	Attr	VSize	VFree
vg_server	1	2	0	wz--n-	14.51g	0

#lvs
LV	VG	  Attr	 LSize	Pool	origin	Data%	Move	Log	Copy%	Convert
lv_root	vg_server -wi-ao--10.57g
lv_swap	vg_authentic -wi-ao-- 3.94g

#parted /dev/sda2 print
Error: /dev/sda2: unrecognised disk label
Quote:
Did you boot from the Ubuntu live or did you mount it
I booted from it, is this significant? Why would I have an unrecognised disk label?
 
Old 09-22-2015, 08:07 AM   #7
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,831
Blog Entries: 15

Rep: Reputation: 1668Reputation: 1668Reputation: 1668Reputation: 1668Reputation: 1668Reputation: 1668Reputation: 1668Reputation: 1668Reputation: 1668Reputation: 1668Reputation: 1668
Quote:
Originally Posted by Mark_667 View Post
I booted from it, is this significant? Why would I have an unrecognised disk label?
I just wanted to verify you'd booted the guest AFTER updating the VHD size in Hyper-V.

Based on your vgs and pvs output it appears your ~15 GB is there.

The only time I've seen the "unrecognised disk label" was when I was setting up new disks that didn't yet have partition tables on them. The link that follows suggests your table got corrupted and suggests steps for recovery. You should of course backup what is on the filesystem before trying this: http://gparted-forum.surf4.info/viewtopic.php?id=17251
Quote:
Re-write the partition table using fdisk:
1) Write down the details of the 2 partitions: start, end sectors and partition type and boot flag.
2) Run "fdisk /dev/sda".
2a) Delete both partitions.
2b) Recreate two new partitions with the exact same start and end sectors, restore partition type, boot flag and write the partition table back to the disk.
 
Old 09-22-2015, 09:42 AM   #8
Mark_667
Member
 
Registered: Aug 2005
Location: Manchester, England
Distribution: Ubuntu 20.04
Posts: 377

Original Poster
Rep: Reputation: 30
Thanks, I'd actually found that link myself but was hoping I wouldn't need to do that but my latest findings might indicate that I do. According to parted -l output /dev/sda has a .5GB EXT4 boot partition with the remaning 15.6GB marked as a primary lvm partition and doesn't list a file system for it.
 
Old 09-22-2015, 12:47 PM   #9
sgrlscz
Member
 
Registered: Aug 2008
Posts: 123

Rep: Reputation: 84
The unrecognized disk label is because you tried to run parted on the partition not the disk. You need to run parted on /dev/sda, not /dev/sda2.
 
Old 09-23-2015, 03:37 AM   #10
Mark_667
Member
 
Registered: Aug 2005
Location: Manchester, England
Distribution: Ubuntu 20.04
Posts: 377

Original Poster
Rep: Reputation: 30
After doing some damage in fdisk I went back to backup and started over. To simplify things I converted the dynamic VHD to Fixed.

pvs gave PSize 11.51g
lvs LSize 7.57g
df lv_root 100 used

Code:
vgs
VG	   #PV #LV #SN attr	VSize	VFree
vg_authentic 1	 2 0  wz--n-	11.51g	  0
lvextend -l +100Free /dev/vg_server/lv_root
New size (1938 extents) matches existing size (1938 extents)

Why hasn't the lv extended into the free pv space?

Last edited by Mark_667; 09-23-2015 at 03:58 AM. Reason: added vgs output
 
Old 09-23-2015, 04:09 AM   #11
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 7.7 (?), Centos 8.1
Posts: 17,843

Rep: Reputation: 2572Reputation: 2572Reputation: 2572Reputation: 2572Reputation: 2572Reputation: 2572Reputation: 2572Reputation: 2572Reputation: 2572Reputation: 2572Reputation: 2572
I'm not entirely sure which cmds you ran in which order, but basically you have to start from the lowest level and re-size all 4(!) levels in order ie

1. extend pv
2. extend vg (vgextend...)
3. extend lv (lvextend...)
4. extend filesystem (resize2fs ...)

Is it possible you missed a step ?
 
Old 09-23-2015, 05:59 AM   #12
Mark_667
Member
 
Registered: Aug 2005
Location: Manchester, England
Distribution: Ubuntu 20.04
Posts: 377

Original Poster
Rep: Reputation: 30
I didn't do the first 2 as they didn't seem to be necessary. Both the PV and LG used the full disk size. I didn't do the resize2fs as it didn't look like the LV size had changed but I don't understand why?
 
Old 09-23-2015, 07:00 AM   #13
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 7.7 (?), Centos 8.1
Posts: 17,843

Rep: Reputation: 2572Reputation: 2572Reputation: 2572Reputation: 2572Reputation: 2572Reputation: 2572Reputation: 2572Reputation: 2572Reputation: 2572Reputation: 2572Reputation: 2572
You have to cover them all.
After adding some actual space (pv), you have to add it to a vg before you can allocate the resulting space to an LV.
(and then extend the fs to use it)
 
  


Reply

Tags
disk, lvm


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] RHEL 6 LVM resize pantdk Linux - Server 8 01-14-2012 08:08 PM
[SOLVED] Resize LVM? glock356 SUSE / openSUSE 1 08-10-2011 01:45 AM
[SOLVED] Unable to resize fedora 12 lvm parition with gparted jcstevens119 Linux - Newbie 2 01-16-2011 05:33 AM
[SOLVED] Unable to resize fedora 12 lvm parition with gparted jcstevens119 Linux - Newbie 2 01-15-2011 12:58 AM
LVM Resize - After logical resize, FS size does not match physical size. spectra Linux - Software 6 11-01-2006 11:28 AM

LinuxQuestions.org > Forums > Enterprise Linux Forums > Linux - Enterprise

All times are GMT -5. The time now is 06:20 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration