LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
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-24-2015, 09:14 AM   #1
osama.mansoor
Member
 
Registered: Oct 2015
Posts: 55

Rep: Reputation: Disabled
Extend Linux Partition (Extend LVM)


I am running Oracle Linux Unbreakable 6.5 on Hyper-V , VHD size on Hyper-V is increased how I can extend from its one partition extend dev/sda2 which is mount on /

is there any safe way to extend this

Screen Shot Attached
Attached Thumbnails
Click image for larger version

Name:	Extend LVM.jpg
Views:	70
Size:	92.2 KB
ID:	20117  
 
Old 11-24-2015, 10:53 AM   #2
morrolan
Member
 
Registered: Sep 2003
Location: Manchester UK
Posts: 264

Rep: Reputation: 30
You can extend LVM by adding a new disk, then expanding the LV group across it.

Here are my notes from the last time I had to do it:

Extending LVM:
In VMWare create a new virtual hard disk device to add to the volume group.

In LVM, there are several layers, each builds on top of the other:
PV[s] (Physical Volumes) -> VG[s] (Volume Groups) -> LV[s] (Logical Volumes) -> Filesystems.

Code:
lvdisplay
Gives you required information regarding the Logical Volume Group.

Code:
pvdisplay
Gives you information regarding the Physical Volume Group.

1. example #1: you've added to VMWare a new virtual hard disk called /dev/sdb
Code:
pvcreate /dev/sdb
vgextend turnkey /dev/sdb
After you've extended the Volume Group, you are free to extend the underlying Logical Volume:
Code:
lvextend -L+100G /dev/turnkey/root


Finally, you'll have to resize the filesystem within /dev/turnkey/root so it can see that the underlying block device just got 10G bigger:
Code:
resize2fs /dev/turnkey/root
resize2fs 1.41.11 (14-Mar-2010) Filesystem at /dev/turnkey/root is mounted on /; on-line resizing required old desc_blocks = 2, new_desc_blocks = 2 Performing an on-line resize of /dev/turnkey/root to 7077888 (4k) blocks. The filesystem on /dev/turnkey/root is now 7077888 blocks long.


The following section won't apply to you, I renamed the host (and LVM's) whilst I was at it. if you are also changing the Hostname of an LVM enabled machine, the following will apply:

PERFORM THE FOLLOWING BEFORE REBOOTING!
Code:
sudo vgrename /dev/zabsgccsc001 /dev/zabbixserver01
sudo nano /etc/hostname
sudo nano /etc/hosts
sudo nano /etc/fstab
sudo update-grub
Please remember to check and amend any hostnames or names - lvdisplay and pvdisplay are your friends, make sure what you are entering matches you current setup - if in doubt, post here in response.
 
Old 11-24-2015, 05:46 PM   #3
berndbausch
LQ Addict
 
Registered: Nov 2013
Location: Tokyo
Distribution: Mostly Ubuntu and Centos
Posts: 6,316

Rep: Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002
Quote:
Originally Posted by osama.mansoor View Post
I am running Oracle Linux Unbreakable 6.5 on Hyper-V , VHD size on Hyper-V is increased how I can extend from its one partition extend dev/sda2 which is mount on /

is there any safe way to extend this
First, your system doesn't use LVM. The only way to replace your current setup with an LVM-based one is to reinstall it.

You need a partition manager to change the size of /dev/sda2. parted or its GUI version, gparted, should be able to accomplish this. It's dangerous - a small mistake and your data is hard or impossible to recover. If the data is important, first back it up.

If /dev/sda has room after partition 2, it's simply a question of changing its size. If not, the partition must be moved to a different place. gparted/parted can do that.

After that, the filesystem has to be extended as well, though parted may have an option to do both tasks together.

Since this is the root disk, the best bet is to boot from a Live DVD and do the work there.

Quote:
Originally Posted by osama.mansoor View Post
Screen Shot Attached
It's a bit small and hard to read.
 
Old 11-24-2015, 07:25 PM   #4
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,126

Rep: Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120
If this is a guest and the "disk" has been increased by the host, a simple reboot will pick up the change - as might partprobe.
"df" shows filesystem size, not partition size.

Reboot if possible and post the output of (as root) "parted -l". Should be simply a matter of using the appropriate filesystem tool to enlarge - can usually be done online these days.
 
Old 11-26-2015, 10:54 PM   #5
osama.mansoor
Member
 
Registered: Oct 2015
Posts: 55

Original Poster
Rep: Reputation: Disabled
I am agree with "berndbausch"

We donot have LVM its simple partition.

is it single partition can be extend by using diskpart utility.
 
Old 11-27-2015, 01:09 AM   #6
berndbausch
LQ Addict
 
Registered: Nov 2013
Location: Tokyo
Distribution: Mostly Ubuntu and Centos
Posts: 6,316

Rep: Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002
Quote:
Originally Posted by osama.mansoor View Post
I am agree with "berndbausch"

We donot have LVM its simple partition.

is it single partition can be extend by using diskpart utility.
I don't know about diskpart, but parted and its derivatives can do one of the following:
  • If there is unused space right after the partition, it can extend it.
  • If not, and there is unused space somewhere else, it can move the partition to the unused space, then extend it.
Moving the partition takes a while. You might be better off doing this:
  1. clone your partition with dd
  2. repartition your disk
  3. copy the clone back
In all cases, after resizing/moving/cloning the partition, you need to extend the filesystem, e.g. with resize2fs or xfs_growfs. Perhaps parted can do that as well, not sure.
 
  


Reply

Tags
extend, lvm



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] How to extend /home or / partition through LVM smilemukul Linux - Newbie 9 01-29-2012 11:07 PM
Extend Partition and Linux LVM on a virtual Server Steve_Aug Linux - General 2 12-19-2011 07:38 AM
Extend Partition and Linux LVM on a virtual Server Steve_Aug Linux - Virtualization and Cloud 1 12-16-2011 09:30 AM
Extend LVM partition rconan Linux - Software 5 08-31-2010 02:32 AM
How to extend an existing partition without LVM james.reid Linux - Software 14 06-02-2006 12:48 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

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