LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-06-2012, 08:03 PM   #1
willkruss
LQ Newbie
 
Registered: Nov 2012
Posts: 6

Rep: Reputation: Disabled
Question Extending LVM Volume with more than 4 partitions?


Hi,
I have an LVM partition on a CentOS 6 VPS and currently have extended it a few times and need to extend it further.

fdisk -l:

Disk /dev/sda: 85.9 GB, 85899345920 bytes
255 heads, 63 sectors/track, 10443 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: 0x0004a08c

Device Boot Start End Blocks Id System
/dev/sda1 * 1 14 103424 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 14 1306 10380288 8e Linux LVM
/dev/sda3 1306 2610 10480089 8e Linux LVM
/dev/sda4 2611 5221 20972857+ 8e Linux LVM

Disk /dev/mapper/VolGroup00-LogVol00: 42.8 GB, 42832232448 bytes
255 heads, 63 sectors/track, 5207 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: 0x00000000

If I try to create a new partition I'm told that I have to delete one to do that. Unfortunately this isn't possible as the data is live. I'm really at a loss here :-(

Cheers,
- Will
 
Old 11-06-2012, 08:25 PM   #2
Ser Olmy
Senior Member
 
Registered: Jan 2012
Distribution: Slackware
Posts: 2,403

Rep: Reputation: Disabled
This is not related to LVM. You've hit the 4 partition limit of the MBR partition table.

The MBR only has room for four entries, limiting you to a maximum of four primary partitions. A workaround exists; one of the four primary partitions can be a so-called extended partision, which in turn can contain a number of sub-partitions ("logical" partitions).

Unfortunately, you've already created four primary partitions. You will need to convert the last of these to an extended partition containing a logical partition. This typically involves backing up data and deleting and recreating the partition in question, although various utilities exist which claim to be able to do a non-destructive conversion.

In either case, your existing /dev/sda4 partition will become /dev/sda5, so you'll need to reconfigure LVM.
 
Old 11-06-2012, 08:43 PM   #3
willkruss
LQ Newbie
 
Registered: Nov 2012
Posts: 6

Original Poster
Rep: Reputation: Disabled
Hi,

Okay, but as I'm using an LVM and the whole thing is actually one big partition, I can't just 'backup' sda4 and recreate it as an extended partition.

Any suggestions on how to go about this with minimal disruption (it's a live cPanel server)?

Thanks.
 
Old 11-06-2012, 08:45 PM   #4
willkruss
LQ Newbie
 
Registered: Nov 2012
Posts: 6

Original Poster
Rep: Reputation: Disabled
Is it possible to merge sda3 and sda4? The blocks are sequential.

Thanks.
 
Old 11-06-2012, 09:00 PM   #5
Ser Olmy
Senior Member
 
Registered: Jan 2012
Distribution: Slackware
Posts: 2,403

Rep: Reputation: Disabled
These partitions are PVs in an LVM Volume Group, right? No, there's no way to simply merge the partitions. Each partition contains LVM metadata that identifies it as an LVM Physical Volume.

However, it is possible to add a temporary drive (say, an external USB drive) to the VG, use pvmove to migrate all data from /dev/sda4, and then remove /dev/sda4 from the VG with vgreduce.

You could then create an extended partition (/dev/sda4, which should take up all available disk space) and any number of logical partitions (/dev/sda5++), which you could then add back to the VG before using pvmove/vgreduce again to get rid of the temporary drive.
 
Old 11-06-2012, 09:04 PM   #6
willkruss
LQ Newbie
 
Registered: Nov 2012
Posts: 6

Original Poster
Rep: Reputation: Disabled
Actually, if that's not possible, if I add another physical HDD to the OS. Can I then create it as a new partition (I assume /dev/sdb1) and add that to the LVM without losing anything? If so, can someone please tell me the commands to do this?

Thanks,
- Will
 
Old 11-06-2012, 09:22 PM   #7
Ser Olmy
Senior Member
 
Registered: Jan 2012
Distribution: Slackware
Posts: 2,403

Rep: Reputation: Disabled
Quote:
Originally Posted by willkruss View Post
Actually, if that's not possible, if I add another physical HDD to the OS. Can I then create it as a new partition (I assume /dev/sdb1) and add that to the LVM without losing anything?
Sure you can. Create a partition with fdisk (or whatever), run pvcreate on the partition, add it to the volume group with vgextend and extend any logical volume in the volume group with lvextend.

(Or use the new partition as temporary storage to migrate data from /dev/sda4, as I suggested in my previous post, which would allow you to repartition /dev/sda without losing data.)
 
Old 11-06-2012, 09:30 PM   #8
willkruss
LQ Newbie
 
Registered: Nov 2012
Posts: 6

Original Poster
Rep: Reputation: Disabled
Thanks Ser, I'll give it a go this evening!
 
Old 11-07-2012, 03:31 AM   #9
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 14,832

Rep: Reputation: 1820Reputation: 1820Reputation: 1820Reputation: 1820Reputation: 1820Reputation: 1820Reputation: 1820Reputation: 1820Reputation: 1820Reputation: 1820Reputation: 1820
So you'll wind up wasting half that (original) disk - no big deal I suppose these days. Allocating multiple pv's like that is limiting in a LVM setup.
In future you would be better off to have one large pv (maybe even the entire disk in the case of the new disk), and use vg's to carve it up if you wish; that way you can expand at will, and not waste disk real estate.
 
Old 11-07-2012, 03:55 AM   #10
willkruss
LQ Newbie
 
Registered: Nov 2012
Posts: 6

Original Poster
Rep: Reputation: Disabled
Ahh it's a thin provisioned VPS so no actual disk space is lost anyhow :-)
 
  


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 Off
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 08:02 AM
Need help with extending volume. Suse10. Spuddy Linux - Server 3 03-23-2011 03:01 PM
LVM - Extending logical volume - Insufficient free space deim Linux - Newbie 0 04-07-2007 10:47 PM
how do I add partitions to drives that have Logical Volume (LVM) partitions? The MJ Linux - Software 5 08-17-2006 07:15 PM
Partitions under LVM Volume Group won't mount after install jimisola Mandriva 4 11-16-2005 05:17 PM


All times are GMT -5. The time now is 01:59 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration