LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
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 07-13-2012, 11:46 AM   #1
jbennett
Member
 
Registered: Apr 2012
Distribution: CentOS 6.2
Posts: 45

Rep: Reputation: Disabled
Expand disk size on centos VM?


I have a VM with only 10GB of disk size avaliable.

I have expanded the disk size to 120GB from the VM tools, however, I only see 10GB of space from within Linux.

I have everything already installed on this VM as I need it and would like ot expand the logical volume to the entire 120GB that's now avaliable to it without losing everything on the disk.

Do I need to use the 'lvextend' tool as described on this page?
 
Old 07-13-2012, 12:01 PM   #2
Kustom42
Senior Member
 
Registered: Mar 2012
Distribution: Red Hat
Posts: 1,604

Rep: Reputation: 415Reputation: 415Reputation: 415Reputation: 415Reputation: 415
Maybe yes, maybe no. We need to figure out your config first.


Run the following commands as root or via sudo and give us the output:

Code:
fdisk -l
pvs
vgs
lvs
df -h
 
1 members found this post helpful.
Old 07-13-2012, 12:08 PM   #3
jbennett
Member
 
Registered: Apr 2012
Distribution: CentOS 6.2
Posts: 45

Original Poster
Rep: Reputation: Disabled
Code:
[root@system ~]# fdisk -l

Disk /dev/sda: 128.8 GB, 128849018880 bytes
255 heads, 63 sectors/track, 15665 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: 0x00024a62

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          13      102400   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2              13        1306    10382336   8e  Linux LVM

Disk /dev/mapper/VolGroup00-LogVol01: 268 MB, 268435456 bytes
255 heads, 63 sectors/track, 32 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

Disk /dev/mapper/VolGroup00-LogVol01 doesn't contain a valid partition table

Disk /dev/mapper/VolGroup00-LogVol00: 10.4 GB, 10359930880 bytes
255 heads, 63 sectors/track, 1259 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

Disk /dev/mapper/VolGroup00-LogVol00 doesn't contain a valid partition table
[root@system ~]# pvs
  PV         VG         Fmt  Attr PSize PFree
  /dev/sda2  VolGroup00 lvm2 a--  9.90g    0
[root@system ~]# vgs
  VG         #PV #LV #SN Attr   VSize VFree
  VolGroup00   1   2   0 wz--n- 9.90g    0
[root@system ~]# lvs
  LV       VG         Attr   LSize   Origin Snap%  Move Log Copy%  Convert
  LogVol00 VolGroup00 -wi-ao   9.65g
  LogVol01 VolGroup00 -wi-ao 256.00m
[root@system ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
                      9.5G  9.5G     0 100% /
tmpfs                 376M     0  376M   0% /dev/shm
/dev/sda1              97M   82M   11M  89% /boot
I hope this gives the necessary information!

Last edited by jbennett; 07-13-2012 at 12:12 PM.
 
Old 07-13-2012, 12:14 PM   #4
Kustom42
Senior Member
 
Registered: Mar 2012
Distribution: Red Hat
Posts: 1,604

Rep: Reputation: 415Reputation: 415Reputation: 415Reputation: 415Reputation: 415
Your good to go, you will need to create a new partition, /dev/sda3, use pvcreate to make it a physical volume, use vgextend to extend your volume group, then use lvextend to extend your logical volume.

http://www.howtoforge.com/logical-vo...a-volume-group

http://linuxconfig.org/Linux_lvm_-_L...ate-partitions


MAKE SURE YOU SET THE PARTITION TYPE TO "8e" WHEN CREATING IT!


If you have specific questions about any of the commands or the syntax just let me know and I'll give you some examples

Last edited by Kustom42; 07-13-2012 at 12:15 PM.
 
1 members found this post helpful.
Old 07-13-2012, 12:31 PM   #5
jbennett
Member
 
Registered: Apr 2012
Distribution: CentOS 6.2
Posts: 45

Original Poster
Rep: Reputation: Disabled
Before I dive off into this, I'm getting the following notification:

Code:
[root@system~]# fdisk /dev/sda

WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
         switch off the mode (command 'c') and change display units to
         sectors (command 'u').

Command (m for help):
Am I to assume I need to do as suggested?

Thanks agian.
 
Old 07-13-2012, 12:48 PM   #6
Kustom42
Senior Member
 
Registered: Mar 2012
Distribution: Red Hat
Posts: 1,604

Rep: Reputation: 415Reputation: 415Reputation: 415Reputation: 415Reputation: 415
Not a big deal on that warning, just follow the steps.

Code:
fdisk /dev/sda
p 
t
3
8e
w
Those will create the necessary partition for you. Then do a:

Code:
pvcreate /dev/sda3
Now yo have another physical volume, lets add it to your volume group

Code:
vgextend /dev/VolGroup00 /dev/sda3
Now you should have that extra space as free in your volume group, you can verify it with vgdisplay.


Finally, extend your current logical volume.

Code:
lvextend -L +100G /dev/VolGroup00/LogVol01
And to make the space available to the OS, resize the filesystem:

Code:
resize2fs /dev/VolGroup00/LogVol01
 
1 members found this post helpful.
Old 07-13-2012, 12:51 PM   #7
jbennett
Member
 
Registered: Apr 2012
Distribution: CentOS 6.2
Posts: 45

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by Kustom42 View Post
Not a big deal on that warning, just follow the steps.

Code:
fdisk /dev/sda
p 
t
3
8e
w
As seems to be the case just about any time I touch Linux, it's never straight forward.

Code:
Command (m for help): p

Disk /dev/sda: 128.8 GB, 128849018880 bytes
255 heads, 63 sectors/track, 15665 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: 0x00024a62

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          13      102400   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2              13        1306    10382336   8e  Linux LVM

Command (m for help): t
Partition number (1-4): 3
Partition 3 does not exist yet!
1) Do I need to be worried about the note: Partition 1 does not end on cylinder boundary.
2) No Partition 3...I don't think I missed a step, did I?

Or, should the order be?

Code:
fdisk /dev/sda
n
p
3
t
8e
w

Last edited by jbennett; 07-13-2012 at 01:05 PM.
 
Old 07-13-2012, 01:14 PM   #8
Kustom42
Senior Member
 
Registered: Mar 2012
Distribution: Red Hat
Posts: 1,604

Rep: Reputation: 415Reputation: 415Reputation: 415Reputation: 415Reputation: 415
Yes, I usually use cfdisk so the commands were a bit out of order. The cylinder boundary error you can ignore as well. Plenty of info on google about it that explains why that happens.


So fdisk /dev/sda

n -- Create new partition
p -- make it a primary partition(you would want to make it an extended one if this was your 4th partition so you don't limit yourself)
3 - Set the partition number
Enter through to get the default sizes which should take up all the free space.
t - modify type
3 - select partition three
8e - make it a linux lvm type partition
w - write the partition
 
1 members found this post helpful.
Old 07-13-2012, 01:31 PM   #9
jbennett
Member
 
Registered: Apr 2012
Distribution: CentOS 6.2
Posts: 45

Original Poster
Rep: Reputation: Disabled
OK, done, and I get the following:

Code:
Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.
I rebooted the machine and was able to do everything else without error, until I reached resizing the filesystem:

Code:
[root@system ~]# resize2fs /dev/VolGroup00/LogVol01
resize2fs 1.41.12 (17-May-2010)
resize2fs: Bad magic number in super-block while trying to open /dev/VolGroup00/LogVol01
Couldn't find valid filesystem superblock.
I'm not sure where to go at this point. A quick search tells me it might be a different file system type?

Code:
[root@system ~]# pvdisplay
  --- Physical volume ---
  PV Name               /dev/sda2
  VG Name               VolGroup00
  PV Size               9.90 GiB / not usable 3.00 MiB
  Allocatable           yes (but full)
  PE Size               4.00 MiB
  Total PE              2534
  Free PE               0
  Allocated PE          2534
  PV UUID               RVurOl-tESz-BgZd-M3g1-6ny4-UQaL-L7Hc0s

  --- Physical volume ---
  PV Name               /dev/sda3
  VG Name               VolGroup00
  PV Size               110.00 GiB / not usable 3.99 MiB
  Allocatable           yes
  PE Size               4.00 MiB
  Total PE              28159
  Free PE               2559
  Allocated PE          25600
  PV UUID               mhwHl3-8Ni2-RCYT-TefS-1GU3-GYA1-5ctfjK

[root@system ~]# vgdisplay
  --- Volume group ---
  VG Name               VolGroup00
  System ID
  Format                lvm2
  Metadata Areas        2
  Metadata Sequence No  5
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                2
  Open LV               2
  Max PV                0
  Cur PV                2
  Act PV                2
  VG Size               119.89 GiB
  PE Size               4.00 MiB
  Total PE              30693
  Alloc PE / Size       28134 / 109.90 GiB
  Free  PE / Size       2559 / 10.00 GiB
  VG UUID               ehy4a2-1hOw-VBqL-0TNL-i9JN-BJEh-ErOhwH

[root@system ~]# lvdisplay
  --- Logical volume ---
  LV Name                /dev/VolGroup00/LogVol01
  VG Name                VolGroup00
  LV UUID                x3ddq2-pUcu-u3JS-vUPQ-bNIj-XlzG-EhbT0Y
  LV Write Access        read/write
  LV Status              available
  # open                 1
  LV Size                100.25 GiB
  Current LE             25664
  Segments               2
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:0

  --- Logical volume ---
  LV Name                /dev/VolGroup00/LogVol00
  VG Name                VolGroup00
  LV UUID                gD7mVs-PygF-XxPy-MM6m-zncd-g2nw-MxtQiM
  LV Write Access        read/write
  LV Status              available
  # open                 1
  LV Size                9.65 GiB
  Current LE             2470
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:1

[root@system ~]# df -T
Filesystem    Type   1K-blocks      Used Available Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
              ext4     9958240   9947624         0 100% /
tmpfs        tmpfs      384396         0    384396   0% /dev/shm
/dev/sda1     ext2       99150     83574     10456  89% /boot
Thanks so much for your continued help. If you were local, I would buy you a beer...or two.
 
Old 07-13-2012, 03:42 PM   #10
Kustom42
Senior Member
 
Registered: Mar 2012
Distribution: Red Hat
Posts: 1,604

Rep: Reputation: 415Reputation: 415Reputation: 415Reputation: 415Reputation: 415
Wait a second! We extended the wrong lv here...

Do the following:

Code:
lvremove /dev/VolGroup00/LogVol01
lvextend -L +100G /dev/VolGroup00/LogVol00
resize2fs /dev/VolGroup00/LogVol00
If that gives you an error then you will need to resize the filesystem off of a rescue CD, as you may get an error that you can't resize a file system that is mounted.

Last edited by Kustom42; 07-13-2012 at 04:33 PM.
 
1 members found this post helpful.
Old 07-13-2012, 04:32 PM   #11
Kustom42
Senior Member
 
Registered: Mar 2012
Distribution: Red Hat
Posts: 1,604

Rep: Reputation: 415Reputation: 415Reputation: 415Reputation: 415Reputation: 415
I think this was my fault as I told you do the lvextend on your 01 lv and not the 00 lv which doesnt appear to be in use or have a filesystem on it, it's was only 256MB before you added the other 100GB.
 
1 members found this post helpful.
Old 07-16-2012, 08:17 AM   #12
jbennett
Member
 
Registered: Apr 2012
Distribution: CentOS 6.2
Posts: 45

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by Kustom42 View Post
Wait a second! We extended the wrong lv here...

Do the following:

Code:
lvremove /dev/VolGroup00/LogVol01
Code:
Can't remove open logical volume "LogVol01"


Quote:
If that gives you an error then you will need to resize the filesystem off of a rescue CD, as you may get an error that you can't resize a file system that is mounted.
Do I just need to follow the same methods as you listed above?

Last edited by jbennett; 07-16-2012 at 10:34 AM.
 
Old 07-16-2012, 10:53 AM   #13
Kustom42
Senior Member
 
Registered: Mar 2012
Distribution: Red Hat
Posts: 1,604

Rep: Reputation: 415Reputation: 415Reputation: 415Reputation: 415Reputation: 415
Try running lvremove with the -f option, you're not going to break anything here..

lvremove -f /dev/VolGroup00/LogVol01

If that doesn't work, add the -vvvv option and give us the output.
 
1 members found this post helpful.
Old 07-16-2012, 11:00 AM   #14
jbennett
Member
 
Registered: Apr 2012
Distribution: CentOS 6.2
Posts: 45

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by Kustom42 View Post
Try running lvremove with the -f option, you're not going to break anything here..

Code:
lvremove -f /dev/VolGroup00/LogVol01
I did this and it returned the following

Code:
Can't remove open logical volume "LogVol01"

Quote:
If that doesn't work, add the -vvvv option and give us the output.
I ran the following:

Code:
lvremove -f /dev/VolGroup00/LogVol01 -vvvv
and a whole bunch of text populated the screen. Unfortunately, this is on a VM and I can't copy the text over (since i'm not able to putty in while it's running from the rescue cd).

Is there a particular part that you are looking for?
 
Old 07-16-2012, 11:34 AM   #15
Kustom42
Senior Member
 
Registered: Mar 2012
Distribution: Red Hat
Posts: 1,604

Rep: Reputation: 415Reputation: 415Reputation: 415Reputation: 415Reputation: 415
Try doing:

Code:
lsof | grep -i LogVol01
See if there are any processes that have a lock on it. You don't have it mounted, so it shouldn't be giving you this error. Did you see anything in the verbose output in regards to the cause of the error? I know the -vvvv gives you alot of output but it should tell us at what point it errors.
 
  


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
[SOLVED] How to expand disk in Linux JALITE Linux - Newbie 6 04-15-2014 04:19 PM
[SOLVED] Expand WinXP Disk Size tronayne Linux - Virtualization and Cloud 4 12-15-2011 07:38 AM
I created my VM machine with to little disk space HOW DO YOU EXPAND bigcape Linux - Virtualization and Cloud 1 03-15-2011 11:30 PM
How to expand disk space cghcgh Linux - Newbie 7 07-08-2008 09:09 AM
expand root partition to occupy whole disk JohnGalt007 Linux - Software 4 01-09-2007 06:03 PM

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

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