Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

We have a virtual Linux server (Fedora Core 2.6.35.6-45.fc14.x86_64) running on VMWare vSphere. Initially it had 3 SCSCI drives 32Gb each. Now we have extended a disk that was mounted under "/home" to 256GB. But Linux server, obviously, does not see that change after restart. Is there a safe way to extend that ext4 partition from 32GB to 256GB withou losing any data?

I've made a search on Google before asking this question and many advice to use GParted. But it seems not the option for me now as I only have shell access to that server at the moment.

EDIT: This is an output from df:

[root@d0001-prf01 dmr]# df -T
Filesystem    Type   1K-blocks      Used Available Use% Mounted on
/dev/mapper/vg_d0011prf01-lv_root
              ext4    31705024   3385376  27997620  11% /
tmpfs        tmpfs     4098300        88   4098212   1% /dev/shm
/dev/sda1     ext4      495844     31317    438927   7% /boot
/dev/mapper/vg_d0011prf01-lv_home
              ext4    23674012  11840672  10630756  53% /home

I can provide more partition information if needed.

EDIT: I can see that LVM is set up on that Linux server:

lvm> lvs
  LV      VG            Attr   LSize  Origin Snap%  Move Log Copy%  Convert
  lv_home vg_d0011prf01 -wi-ao 22.94g
  lv_root vg_d0011prf01 -wi-ao 30.72g
  lv_swap vg_d0011prf01 -wi-ao  9.81g

Does it mean I can use lvresize command?

share|improve this question
    
VMWare is a company by the way, not a product, any chance you might let us know which of them you're talking about? –  Chopper3 Jul 4 '11 at 9:47
    
@Chopper3, it's vSphere. I'll update the qeustion. –  Andrey Adamovich Jul 4 '11 at 9:51
    
Again, that's a product range not a product... –  Chopper3 Jul 4 '11 at 9:57
    
@Chopper3, let me know what information you need more about it. I'm not VMWare product expert and to me it seems that problem is more Linux related, but not underlying virtualization software. In vSphere client I can see that SCSCI disk that is used for /home partition has 256GB and I see that linux uses only 24GB of that. –  Andrey Adamovich Jul 4 '11 at 10:04
add comment

2 Answers

up vote 4 down vote accepted

Yes, looks like you can use lvresize, assuming you have space in the volume group.

See if you have some free space:-

sudo vgs -v vg_d0011prf01

If you do, then you can resize the volume using. the following will increase the size by 2Gig.

sudo lvextend -L+2G /dev/mapper/vg_d0011prf01-lv_home

Then resize the volume using resize2fs like:-

sudo resize2fs /dev/mapper/vg_d0011prf01-lv_home
share|improve this answer
    
thanks a lot for your answer, but what if vgs command shows that I have 0 free space? –  Andrey Adamovich Jul 4 '11 at 14:24
    
Okay, then you need to re-size the partition to the full 256G, using Caleb's parted answer, then run pvresize <partion name>. Then vgs should report some free space available to resize the volumes. –  Decado Jul 4 '11 at 14:48
    
relevent parted document page is here –  Decado Jul 4 '11 at 14:52
    
hmm, parted returns Error: The location 200GB is outside of the device /dev/sda. –  Andrey Adamovich Jul 7 '11 at 5:28
    
our Linux adiministrator got back from vaction and managed to create a new partition in separate location. Thanks for you answers. –  Andrey Adamovich Jul 7 '11 at 10:45
add comment

There are several tools for re-sizing partitions, parted (or gparted for a graphical interface) is probably the best bet. There are two steps here. First you have to grow the partition into the new space, then you have to grow the file system to use the whole partition.

I do recommend switching to using LVM. The flexibility to manage this sort of change down the road is well worth the effort to set it up. You could even add a new partition in the new blank space, configure LVM inside it, start a volume group and a file system in it, copy your data over to the new space, then hose the current partition, add it to the volume group, and expand onto it.

Whatever you do, don't do anything unless you have your system backed up!

share|improve this answer
    
how do I set up LVM? any good pointers are really appreciated. –  Andrey Adamovich Jul 4 '11 at 10:14
    
how do I check if it is already setup? –  Andrey Adamovich Jul 4 '11 at 10:16
    
I updated the question with details from LVM. –  Andrey Adamovich Jul 4 '11 at 10:28
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.