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.

I have an Amazon Line AMI with two drives, one for root and one for data,

8G     /
1024G  /data

the data partition almost full 93% /data, and I want to extend the data partition without wiping the disk.

Is it possible to change an existing filesystem on a non-LVM partition and turned it into an LVM logical volume without having to wipe the disk ?

share|improve this question

3 Answers 3

No it is not possible to change an existing non-LVM partition into to LVM without pvcrating on it, destroying the data on there. You'll have to do something like:

  1. Get a new 1024G disk, and vgcrate new_vg /dev/newdisk (replace new_vg and newdisk as appropriate)
  2. lvcreate -L+100%FREE -n new_lv (replace new_lv as appropriate)
  3. Format and mount it somewhere
  4. move the files (probably requires a service window)
  5. when old disk is copied, you can umount it vgextend new_vg /dev/datadisk (the disk currently mounted on /data)
  6. and lvextend -L+100%FREE new_vg/new_lv , then grow the fs: resize2fs /dev/new_vg/new_lv

Either that or make a backup of the files, umount the disk and repeat 1-4 (without the getting of new disk)

share|improve this answer

Take a snapshot of the disk, then create a new bigger volume from that snapshot. If your AMI uses cloud-init then it will automatically grow to fill it. If it does then edit the partition table in fdisk (make the partition as big as you want it to be) then reboot and use resize2fs to do an online resize.

share|improve this answer
    
but the maximum volume in Amazon is 1024G. –  user161834 Aug 17 '13 at 2:29

If you don't want to take the potentially time-consuming LVM conversion path, here's another approach that may or may not work for you, depending what kind of directory layout you have under /data.

Use mount points! In essence:

  • Get a new 1024 GB disk
  • Create a filesystem (an LVM partition, if you so will) on it
  • Mount your new filesystem somewhere temporary place, like /data/tmp if that does not exist already
  • Copy some big dir of your /data, such as /data/bigdata to /data/tmp
  • Rename the original /data/bigdata to other name, such as /data/bigdata.old
  • Create a new dir /data/bigdata
  • Unmount /data/tmp (your new disk)
  • Mount your new disk on top of /data/bigdata

OK, I admit this is far from ideal, but something like this had to be done before the volume managers came in existence. Petter H has a better idea in his answer and you should probably follow that anyway.

share|improve this answer

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.