1

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?

4
  • 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, 2011 at 9:47
  • @Chopper3, it's vSphere. I'll update the qeustion. Jul 4, 2011 at 9:51
  • Again, that's a product range not a product...
    – Chopper3
    Jul 4, 2011 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. Jul 4, 2011 at 10:04

2 Answers 2

4

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
5
  • thanks a lot for your answer, but what if vgs command shows that I have 0 free space? Jul 4, 2011 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, 2011 at 14:48
  • relevent parted document page is here
    – Decado
    Jul 4, 2011 at 14:52
  • hmm, parted returns Error: The location 200GB is outside of the device /dev/sda. Jul 7, 2011 at 5:28
  • our Linux adiministrator got back from vaction and managed to create a new partition in separate location. Thanks for you answers. Jul 7, 2011 at 10:45
2

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!

3
  • how do I set up LVM? any good pointers are really appreciated. Jul 4, 2011 at 10:14
  • how do I check if it is already setup? Jul 4, 2011 at 10:16
  • I updated the question with details from LVM. Jul 4, 2011 at 10:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .