LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 02-09-2016, 03:04 PM   #1
mjl3434
Member
 
Registered: Sep 2003
Location: USA
Distribution: Ubuntu 20.04
Posts: 111

Rep: Reputation: 15
How to increase logical volume to match physical volume, after increasing size of virtualbox virtual drive


I need to know how to fix my LVM stuff, so that I can use the 20 GB of space I added to my VirtualBox VM. I ran out of space in my VirtualBox VM. When I initially created the VM I selected "dynamic allocated storage". I mistakenly assumed the virtual hard drive would grow automatically as it ran out of space. Instead I learned that it does not automatically grow, but can be manually increased in size by use of a command line utility in the host OS provided by VirtualBox / Oracle. I backed everything up before making any changes.

So far I have run this command and successfully increased the size of the VM drive:

Code:
C:\Program Files\Oracle\VirtualBox>VBoxManage modifyhd "C:\Users\...path to vm\MyVm.vdi" --resize 40,960
0...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%.
Next I booted to an Ubuntu boot CD and started GParted. From there I disabled the lvm2 pv, and resized /dev/sda2 and /dev/sda5 to take up all of the additional space I just added. Because I do know what what I am doing, and for fear of trashing the existing data, I did not format anything. After these changes I can successfully boot into Ubuntu, but when check out the size of the drive, it looks as if it has not been increased.

Code:
user@zugzwang:~$ df -h
Filesystem                   Size  Used Avail Use% Mounted on
/dev/mapper/ubuntu--vg-root   19G   16G  1.7G  91% /
I found a few commands online to get information about the Logical Volumes, Physical Volumes, and Volume Groups. This is what they show:

Code:
user@zugzwang:~$ sudo lvs
[sudo] password for user: 
  LV     VG        Attr      LSize    Pool Origin Data%  Move Log Copy%  Convert
  root   ubuntu-vg -wi-ao---   18.74g                                           
  swap_1 ubuntu-vg -wi-ao--- 1020.00m            

user@zugzwang:~$ sudo pvs
[sudo] password for user: 
  PV         VG        Fmt  Attr PSize  PFree 
  /dev/sda5  ubuntu-vg lvm2 a--  39.76g 20.02g

user@zugzwang:~$ sudo vgs
[sudo] password for user: 
  VG        #PV #LV #SN Attr   VSize  VFree 
  ubuntu-vg   1   2   0 wz--n- 39.76g 20.02g
As you can see it looks like the problem is that my Physical Volume and Volume Group both show that there is 20 GB free, while the Logical Volume where the actual filesystem resides only has the original 18.74 GB. My question is how do I fix everything so that my filesystem can take advantage of the additional 20 GB of space I added?

Last edited by mjl3434; 02-09-2016 at 03:06 PM.
 
Old 02-09-2016, 03:15 PM   #2
AlucardZero
Senior Member
 
Registered: May 2006
Location: USA
Distribution: Debian
Posts: 4,824

Rep: Reputation: 615Reputation: 615Reputation: 615Reputation: 615Reputation: 615Reputation: 615
Code:
lvextend -l +100%FREE /dev/mapper/ubuntu--vg-root
resize2fs /dev/mapper/ubuntu--vg-root
(assuming / is ext3 or ext4)

Last edited by AlucardZero; 02-09-2016 at 03:17 PM.
 
Old 02-09-2016, 03:21 PM   #3
mjl3434
Member
 
Registered: Sep 2003
Location: USA
Distribution: Ubuntu 20.04
Posts: 111

Original Poster
Rep: Reputation: 15
Thank you AlucardZero the commands worked without even having to do it form a Live CD. Can you please explain what this argument is, and how one would find it? "/dev/mapper/ubuntu--vg-root"


Code:
user@zugzwang:~$ sudo lvextend -l +100FREE /dev/mapper/ubuntu--vg-root
[sudo] password for user: 
  Extending logical volume root to 38.76 GiB
  Logical volume root successfully resized

user@zugzwang:~$ sudo resize2fs /dev/mapper/ubuntu--vg-root
[sudo] password for user: 
resize2fs 1.42.9 (4-Feb-2014)
Filesystem at /dev/mapper/ubuntu--vg-root is mounted on /; on-line resizing required
old_desc_blocks = 2, new_desc_blocks = 3
The filesystem on /dev/mapper/ubuntu--vg-root is now 10161152 blocks long.

user@zugzwang:~$ df -h
Filesystem                   Size  Used Avail Use% Mounted on
/dev/mapper/ubuntu--vg-root   39G   17G   20G  46% /

Last edited by mjl3434; 02-09-2016 at 03:48 PM.
 
Old 02-09-2016, 08:16 PM   #4
AlucardZero
Senior Member
 
Registered: May 2006
Location: USA
Distribution: Debian
Posts: 4,824

Rep: Reputation: 615Reputation: 615Reputation: 615Reputation: 615Reputation: 615Reputation: 615
It's the device of your root filesystem.
 
Old 02-10-2016, 08:29 AM   #5
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,699
Blog Entries: 4

Rep: Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947
You can either resize the physical file ... note that you might have to tell the LVM that you have done so ... or you can allocate a new physical storage unit – partition, what have you – and add it to the pool. I prefer to do the latter. The thought of "re-sizing" a file system gives me the creeps.
 
  


Reply



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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LVM Mount Physical Volume/Logical Volume without a working Volume Group mpivintis Linux - Newbie 10 01-11-2014 07:02 AM
I have spce in volume group but it can not increase the size of logical volume anis123 Linux - Newbie 14 04-16-2012 06:23 AM
Can I increase the size of a physical volume in an lvm group? If so, how? MikeB23930 Fedora 2 07-21-2009 05:38 PM
Increasing a Logical Volume over a new hard-drive - Possible? rizhun Linux - Hardware 2 04-01-2006 12:56 PM
Increasing a Logical Volume over a new hard-drive - Possible? rizhun Linux - Hardware 2 04-01-2006 10:10 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 07:23 AM.

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