LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Virtualization and Cloud
User Name
Password
Linux - Virtualization and Cloud This forum is for the discussion of all topics relating to Linux Virtualization and Linux Cloud platforms. Xen, KVM, OpenVZ, VirtualBox, VMware, Linux-VServer and all other Linux Virtualization platforms are welcome. OpenStack, CloudStack, ownCloud, Cloud Foundry, Eucalyptus, Nimbus, OpenNebula and all other Linux Cloud platforms are welcome. Note that questions relating solely to non-Linux OS's should be asked in the General forum.

Notices


Reply
  Search this Thread
Old 01-21-2011, 07:38 PM   #1
hansaplazt
LQ Newbie
 
Registered: Oct 2010
Posts: 22

Rep: Reputation: 0
Lightbulb Grow LVM in extended partition.


I couldn't find a HOWTO that always works (even with LVM in extended partition).

Here's one...

Code:
First, shut down your VM and increase the disk size.
Then start your VM and go to the console.

# fdisk -u /dev/xvda
(-u shows sectors instead of cylinders. This is important)

(Make a note of the start sector of the LVM partition)
Command (m for help): p

    Device Boot      Start         End      Blocks   Id  System
/dev/xvda1   *        2048      499711      248832   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/xvda2          501758    16775167     8136705    5  Extended
/dev/xvda5          501760    16775167     8136704   8e  Linux LVM

(delete the LVM and/or Extended partition)
Command (m for help): d
Partition number (1-5): 2

(Create a new partition)
Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p (I choose primary but you may choose extended)
Partition number (1-4): 2 (choose one that's available)

(Fill in the start sector of the LVM partition we deleted above)
First sector (63-16777215, default 63): 501760
Last sector, +sectors or +size{K,M,G} (501760-16777215, default 16777215): (Enter)

(change created partition to Linux LVM)
Command (m for help): t 
Partition number (1-4): 2
Hex code (type L to list codes): 8e
Changed system type of partition 2 to 8e (Linux LVM)

Command (m for help): p

    Device Boot      Start         End      Blocks   Id  System
/dev/xvda1   *        2048      499711      248832   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/xvda2          501760    16777215     8137728   8e  Linux LVM

Command (m for help): w (write)

# reboot

(Resize physical volume)
# pvresize /dev/xvda2

(make a note of the VG "Free PE")
# vgdisplay

(make a note of the "LV Name" of the LV you want to resize)
# lvdisplay 

(Resize LV. Fill in the found "Free PE" and "LV Name" (without the brackets))
# lvresize -l +[Free PE] [LV Name]

(resize the file system)
# resize2fs [LV Name] 
# reboot
Thats all..

Hope this is useful to somebody.

Last edited by hansaplazt; 01-21-2011 at 07:47 PM.
 
Old 07-20-2011, 10:03 AM   #2
sefai
LQ Newbie
 
Registered: Jul 2011
Posts: 1

Rep: Reputation: Disabled
It was very useful for me.

Thank you very much.

Last edited by sefai; 07-21-2011 at 12:17 AM.
 
Old 07-21-2011, 05:16 AM   #3
hansaplazt
LQ Newbie
 
Registered: Oct 2010
Posts: 22

Original Poster
Rep: Reputation: 0
Glad you liked it.
 
Old 12-05-2011, 07:29 AM   #4
SwedishViking
LQ Newbie
 
Registered: Dec 2011
Posts: 3

Rep: Reputation: Disabled
Unfortunately this doesn't work for me

After performing the steps above I get the following message when booting.

Gave up waiting for root device. Common problems:
- Boot args (cat /proc/cmdline)
- Check rootdelay= (did the system wait long enough?)
- Check root= (did the system wait for the right device?)
- Missing modules (cat /proc/modules; ls /dev)
ALERT! /dev/mapper/AhsayOBS-root does not exist. Dropping to a shell!


BusyBox v1.13.3 (Ubuntu 1:1.13.3-1ubuntu11) built-in shell (ash)
Enter 'help' for a list of built-in commands.

(initramfs)


I'm running this Ubuntu 10.04.03 LTS on a XenServer v6.0

Any one else seen this?
 
Old 12-05-2011, 08:05 AM   #5
hansaplazt
LQ Newbie
 
Registered: Oct 2010
Posts: 22

Original Poster
Rep: Reputation: 0
I presume you have created snapshot or backup of your VM?
Go back to it and start your VM (it should come up now). Can you post the output of "fdisk -u /dev/xvda" here? Assuming of course that /dev/xvda is the device you want to resize.

Last edited by hansaplazt; 12-05-2011 at 08:06 AM.
 
Old 12-06-2011, 01:33 AM   #6
SwedishViking
LQ Newbie
 
Registered: Dec 2011
Posts: 3

Rep: Reputation: Disabled
Yes, that's correct. But I had to fix the space problem on that server immediately so had to solve it temporarily with mounting another partition into the filesystem to gain space where needed.

Although I've set up a similar Xen VM Guest server to continue tests on and it looked like this.

Disk /dev/xvda: 75.2 GB, 75161927680 bytes
255 heads, 63 sectors/track, 9137 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00075641

Device Boot Start End Blocks Id System
/dev/xvda1 1 32 248832 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/xvda2 32 9138 73148417 5 Extended
/dev/xvda5 32 9138 73148416 8e Linux LVM
 
Old 12-06-2011, 04:13 AM   #7
hansaplazt
LQ Newbie
 
Registered: Oct 2010
Posts: 22

Original Poster
Rep: Reputation: 0
You are showing me cylinders instead of sectors. This is important. What unix/linux flavour do you have? Check the fdisk man page for listing sectors (usually this is '-u')
 
Old 12-06-2011, 05:55 AM   #8
SwedishViking
LQ Newbie
 
Registered: Dec 2011
Posts: 3

Rep: Reputation: Disabled
I'm running Ubuntu Lucid Lynx (10.04 LTS)

Okay, changed to sectors inside fdisk instead of on the command line which seems to work better.

Changing display/entry units to sectors

Command (m for help): p

Disk /dev/xvda: 17.2 GB, 17179869184 bytes
255 heads, 63 sectors/track, 2088 cylinders, total 33554432 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00050338

Device Boot Start End Blocks Id System
/dev/xvda1 2048 499711 248832 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/xvda2 501758 33552383 16525313 5 Extended
/dev/xvda5 501760 33552383 16525312 8e Linux LVM
 
Old 12-06-2011, 05:59 AM   #9
hansaplazt
LQ Newbie
 
Registered: Oct 2010
Posts: 22

Original Poster
Rep: Reputation: 0
That was probably the problem.
If you now follow my first post (exactly of course ) all should be fine.
 
Old 02-10-2016, 10:31 AM   #10
johnavp1989
LQ Newbie
 
Registered: Feb 2016
Posts: 1

Rep: Reputation: Disabled
Thank You!

I know this is a really old post but I've been looking for the answer to this for a couple of days now and couldn't find it until I stumbled upon this! Thank's so much!
 
Old 02-20-2016, 03:42 PM   #11
pjs67123
LQ Newbie
 
Registered: Feb 2016
Posts: 1

Rep: Reputation: Disabled
Thanks hansaplazt for the post! You are awesome!
 
Old 11-27-2016, 02:33 PM   #12
paranoico
LQ Newbie
 
Registered: Nov 2016
Posts: 1

Rep: Reputation: Disabled
Smile Thanks a lot

Hello,

Your thread was very useful for me even 6 years before

Just wanted to note that on Debian 8 now some commands has changed that needs complete paths for LV (name is not enough anymore):
  • sudo lvresize -l +[Free PE] [LV Path]
    sudo resize2fs [LV Path]

Thanks for your great post.
 
1 members found this post helpful.
Old 12-15-2016, 11:44 AM   #13
Coffee!!!
LQ Newbie
 
Registered: Dec 2016
Distribution: RHEL
Posts: 18

Rep: Reputation: Disabled
For RHEL 7*

Try running a rescan on the iscsi bus after adding or extending a drive to a VM:

echo "- - -" > /sys/class/scsi_host/host0/scan

Most of the time it will work and prevent you from having to do a reboot.

Since file systems have changed a bit, adding the following command for XFS since it doesn't use resize2fs:

xfs_growfs /dev/mapper/rhel-root00
 
Old 04-11-2017, 11:41 AM   #14
gingerpower121
LQ Newbie
 
Registered: Oct 2013
Posts: 1

Rep: Reputation: Disabled
Still relevant in 2017.

Using Ubuntu 16.04.2 LTS (Server build). Thank you OP!
 
Old 09-03-2019, 06:45 AM   #15
azidhaka
LQ Newbie
 
Registered: Sep 2019
Posts: 1

Rep: Reputation: Disabled
Talking

Helped me in 2019, thank you very much!
 
  


Reply


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
Can't grow partition halfpower Linux - General 7 12-03-2010 03:47 PM
Extended partitions and LVM gargamel Linux - Server 5 07-19-2010 11:48 AM
LXer: How To Resize LVM Software RAID1 Partitions (Shrink & Grow) LXer Syndicated Linux News 0 01-09-2009 02:11 PM
LXer: Linux desktops grow and grow and grow LXer Syndicated Linux News 0 11-23-2007 01:00 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Virtualization and Cloud

All times are GMT -5. The time now is 12:33 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