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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
|
07-13-2012, 11:46 AM
|
#1
|
Member
Registered: Apr 2012
Distribution: CentOS 6.2
Posts: 45
Rep:
|
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?
|
|
|
07-13-2012, 12:01 PM
|
#2
|
Senior Member
Registered: Mar 2012
Distribution: Red Hat
Posts: 1,604
|
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.
|
07-13-2012, 12:08 PM
|
#3
|
Member
Registered: Apr 2012
Distribution: CentOS 6.2
Posts: 45
Original Poster
Rep:
|
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.
|
|
|
07-13-2012, 12:14 PM
|
#4
|
Senior Member
Registered: Mar 2012
Distribution: Red Hat
Posts: 1,604
|
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.
|
07-13-2012, 12:31 PM
|
#5
|
Member
Registered: Apr 2012
Distribution: CentOS 6.2
Posts: 45
Original Poster
Rep:
|
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.
|
|
|
07-13-2012, 12:48 PM
|
#6
|
Senior Member
Registered: Mar 2012
Distribution: Red Hat
Posts: 1,604
|
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:
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.
|
07-13-2012, 12:51 PM
|
#7
|
Member
Registered: Apr 2012
Distribution: CentOS 6.2
Posts: 45
Original Poster
Rep:
|
Quote:
Originally Posted by Kustom42
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.
|
|
|
07-13-2012, 01:14 PM
|
#8
|
Senior Member
Registered: Mar 2012
Distribution: Red Hat
Posts: 1,604
|
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.
|
07-13-2012, 01:31 PM
|
#9
|
Member
Registered: Apr 2012
Distribution: CentOS 6.2
Posts: 45
Original Poster
Rep:
|
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.
|
|
|
07-13-2012, 03:42 PM
|
#10
|
Senior Member
Registered: Mar 2012
Distribution: Red Hat
Posts: 1,604
|
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.
|
07-13-2012, 04:32 PM
|
#11
|
Senior Member
Registered: Mar 2012
Distribution: Red Hat
Posts: 1,604
|
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.
|
07-16-2012, 08:17 AM
|
#12
|
Member
Registered: Apr 2012
Distribution: CentOS 6.2
Posts: 45
Original Poster
Rep:
|
Quote:
Originally Posted by Kustom42
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.
|
|
|
07-16-2012, 10:53 AM
|
#13
|
Senior Member
Registered: Mar 2012
Distribution: Red Hat
Posts: 1,604
|
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.
|
07-16-2012, 11:00 AM
|
#14
|
Member
Registered: Apr 2012
Distribution: CentOS 6.2
Posts: 45
Original Poster
Rep:
|
Quote:
Originally Posted by Kustom42
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?
|
|
|
07-16-2012, 11:34 AM
|
#15
|
Senior Member
Registered: Mar 2012
Distribution: Red Hat
Posts: 1,604
|
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.
|
|
|
All times are GMT -5. The time now is 10:11 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|