LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Expand disk size on centos VM? (https://www.linuxquestions.org/questions/linux-newbie-8/expand-disk-size-on-centos-vm-4175416556/)

whizzit 07-17-2012 08:31 AM

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
cat /proc/swaps            # show swap volumes/partitions in use

For now, I'd say forget about LogVol01 and simply carry on with extending the main volume LogVol00 as Kustom42 previously described. Unless you have already extended LogVol01 (lvs will show LVM volume sizes).

jbennett 07-17-2012 09:28 AM

Quote:

Originally Posted by whizzit (Post 4730562)
Code:

blkid -t TYPE=swap        # show volumes/partitions of type swap

Code:

/dev/mapper/VolGroup00-LogVol01: UUID="............" TYPE="swap"
Quote:

Code:

cat /proc/swaps            # show swap volumes/partitions in use

Code:

Filename  Type      Size    Used Priority
/dev/dm-1 partition 262136  0    -1

Quote:

For now, I'd say forget about LogVol01 and simply carry on with extending the main volume LogVol00 as Kustom42 previously described. Unless you have already extended LogVol01 (lvs will show LVM volume sizes).
If I do a 'lvdisplay', I see where LogVol01 has a LV size of 100.24 GB while LogVol00 has a LV size of 9.65 GB. Is this showing that the LogVol01 has already been extended?


If all looks ok, at this point, I need to stay in recovery and do the following:

Code:

lvextend -L +100G /dev/VolGroup00/LogVol00
resize2fs /dev/VolGroup00/LogVol00

?

whizzit 07-17-2012 09:59 AM

Quote:

Originally Posted by jbennett (Post 4730609)
If I do a 'lvdisplay', I see where LogVol01 has a LV size of 100.24 GB while LogVol00 has a LV size of 9.65 GB. Is this showing that the LogVol01 has already been extended?

So this will need to be undone first with lvreduce to reclaim the space. To be thorough I propose the following commands, checking progress as you go ( at a pinch just the lvreduce would suffice for now ):

Code:

/sbin/swapoff    /dev/VolGroup00/LogVol01      # stop using this volume as swap.
lvreduce -L 256M /dev/VolGroup00/LogVol01      # reduce LogVol01 to 256M
/sbin/mkswap    /dev/VolGroup00/LogVol01      # initialise the swap space, to be on the safe side
/sbin/swapon    /dev/VolGroup00/LogVol01      # start using LogVol01 as swap again (not strictly necessary in this environment but good practice)

( Note: that it is not '-L -100G' because the original lvextend must have been executed as '-L 100G'. Subtle, but important if using other commands like lvresize, for example )

You can check progress with vgs (or vgdisplay) to ensure that the volume group has enough free storage.

Quote:

Originally Posted by jbennett (Post 4730609)
If all looks ok, at this point, I need to stay in recovery and do the following:

Code:

lvextend -L +100G /dev/VolGroup00/LogVol00
resize2fs /dev/VolGroup00/LogVol00

?

That looks correct.

jbennett 07-17-2012 10:12 AM

Code:

/sbin/swapoff    /dev/VolGroup00/LogVol01      # stop using this volume as swap.
bash: /sbin/swapoff: No such file or directory
lvreduce -L 256M /dev/VolGroup00/LogVol01      # reduce LogVol01 to 256M
WARNING: Reducing active and open logical volume to 256.00 MiB
THIS MAY DESTROY YOUR DATA (filesystem etc.)

I'm assuming I want to hit yes, but the fact that it couldn't find swapoff makes me want to verify before I go through with this.

whizzit 07-17-2012 10:20 AM

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.

jbennett 07-17-2012 10:24 AM

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!!

Kustom42 07-17-2012 11:36 AM

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.

jbennett 07-17-2012 11:43 AM

Thanks for all of your help as well Kustom!


All times are GMT -5. The time now is 02:42 AM.