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? |
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 |
Code:
[root@system ~]# fdisk -l |
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 |
Before I dive off into this, I'm getting the following notification:
Code:
[root@system~]# fdisk /dev/sda Thanks agian. |
Not a big deal on that warning, just follow the steps.
Code:
fdisk /dev/sda Code:
pvcreate /dev/sda3 Code:
Finally, extend your current logical volume. Code:
lvextend -L +100G /dev/VolGroup00/LogVol01 Code:
resize2fs /dev/VolGroup00/LogVol01 |
Quote:
Code:
Command (m for help): p 2) No Partition 3...I don't think I missed a step, did I? Or, should the order be? Code:
fdisk /dev/sda |
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 |
OK, done, and I get the following:
Code:
Command (m for help): w Code:
[root@system ~]# resize2fs /dev/VolGroup00/LogVol01 Code:
[root@system ~]# pvdisplay |
Wait a second! We extended the wrong lv here...
Do the following: Code:
lvremove /dev/VolGroup00/LogVol01 |
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.
|
Quote:
Code:
Can't remove open logical volume "LogVol01" Quote:
|
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. |
Quote:
Code:
Can't remove open logical volume "LogVol01" Quote:
Code:
lvremove -f /dev/VolGroup00/LogVol01 -vvvv Is there a particular part that you are looking for? |
Try doing:
Code:
lsof | grep -i LogVol01 |
If you don't see any open file locks run the following:
Code:
Code:
|
Is LogVol01 mounted by any chance?
Code:
# lvcreate -L100M -n test /dev/vg0 |
It shouldnt be mounted, from the discussion we had this new lv got created. Unless it got mounted, which I can't see it from the steps the issue here is likely a file lock or the dmsetup.
|
Quote:
Code:
bash: lsof : command not found Quote:
Code:
Can't remove open logical volume "LogVol01" |
Quote:
Code:
#mm/memlock.c:389 Unlock : Memlock counters: locked:0 critical:0 daemon:0 suspended:0 |
Quote:
When I run df -h, I don't have LogVol01, I only have LogVol00, along with some other partitions. LogVol00 is still at 9.5G in size and is at 100% use. Also, /dev/loop0 is at 100% of 130M in use. I'm not sure if that matters? Thank you again for all of the help. |
Did you run the dmsetup commands I provided? What was the output of those? I think that is the issue here preventing the LV from being removed.
|
Quote:
I'll take a step back and allow the thread to continue with Kustom42. Regards |
Quote:
Code:
Name Maj Min Stat Open Targ Event UUID Quote:
Code:
device-mapper: remove ioctl failed: Device or resource busy |
Well, this is interesting...
That should allow you to remove it, add the -f option to the remove command. dmsetup remove -f VolGroup00-LogVol01 |
result as follows:
Code:
device-mapper: remove ioctl failed: Device or resource busy |
Ok, well since you don't have access to lsof try this:
Code:
ps auxww | grep -i LogVol01 |
Code:
root 1618 0.0 0.1 4328 784 tty1 S+ 21:02 0:00 grep -i LogVol01 if I do the following: Code:
ps ax | grep 1618 Code:
1624 tty1 S+ 0:00 grep 1618 When I do 'df -H', I don't see LogVol01 listed, only LogVol00?? |
The ps output you are getting is for the grep process you are running. This is very odd, there are no processes with a file open so you should have no issue removing the logical volume.
I have seen this is in wierd situation before where the device was suspended, not sure if thats the case but its something to try. Code:
|
result as follows:
Code:
device-mapper: remove ioctl failed: Device or resource busy |
Actually, I just had a thought that LogVol01 could be the swap volume for your CentOS system. It's possible that the LiveCD you are using has automatically started using it as swap and could explain why it wasn't able to be removed. This might be shown by:
Code:
blkid -t TYPE=swap # show volumes/partitions of type swap |
Quote:
Code:
/dev/mapper/VolGroup00-LogVol01: UUID="............" TYPE="swap" Quote:
Code:
Filename Type Size Used Priority Quote:
If all looks ok, at this point, I need to stay in recovery and do the following: Code:
lvextend -L +100G /dev/VolGroup00/LogVol00 |
Quote:
Code:
/sbin/swapoff /dev/VolGroup00/LogVol01 # stop using this volume as swap. You can check progress with vgs (or vgdisplay) to ensure that the volume group has enough free storage. Quote:
|
Code:
/sbin/swapoff /dev/VolGroup00/LogVol01 # stop using this volume as swap. |
Can you try just swapoff on it's own (in case the path is different in your evironment) ?
The warning is great (!) since the command is a sure way to kill a system if typos are ever made in the volume name :). In this case we will be ok since we know there isn't anything important on LogVol01 ( /proc/swaps show Used = 0 ) but I would prefer swapoff to work first. |
that seems to have worked (no errors).
I have successfully extended the LV to 109.65 GB and am now able to see that /VolGroup00-LogVol00 has a size of 108G with only 9.6G used! Now I get to see if I can restore a Nagios install to this VM. THANK YOU!!! This forum has been invaluable!! |
Glad to see you go there, thanks for your eyes whizzit I was hitting the wall on this one. didn't think about it being set up as swap by the rescue CD, I'll have to keep that in mind.
|
Thanks for all of your help as well Kustom!
|
All times are GMT -5. The time now is 07:14 AM. |