Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How to shrink a live partition (/dev/xvda3). I have done this before, but it is two years ago and cannot remember. I have a freshly installed Ubuntu Server:

Filesystem     1K-blocks    Used Available Use% Mounted on
/dev/xvda3     855622016 1355060 810803888   1% /
udev              245452       4    245448   1% /dev
tmpfs              99792     168     99624   1% /run
none                5120       0      5120   0% /run/lock
none              249480       0    249480   0% /run/shm
/dev/xvda1         99286   12387     81773  14% /boot

I need to split /dev/xvda3, making it 15G and then create a new partition /dev/xvda4 with the remaining 8xxG. I need this so I can mount it separately and share it with other servers.

Not afraid of dataloss, as it is a fresh install and can reinstall the (virtual) server with the click of the mouse.

share|improve this question
    
What's your actual question? What have you tried already? (GPartEd perhaps?) – Ƭᴇcʜιᴇ007 Apr 3 '13 at 19:18
    
No I tried 'resize2fs' but it cannot shrink a live partition. I was going to do that and then use fdisk to change the partition size, reboot and then use resize2fs to fill the space. But don't expect I could do that unless all data is put at the beginning of the partition (unless that is the case on a fresh install) – Luuk D. Jansen Apr 3 '13 at 19:23
up vote 1 down vote accepted

ext[34] does not allow the shrinking of filesystems that are mounted.

Your going to need to boot into a rescue image (linode/rackspace) or mount the disk to a new instance (EC2).

From there you can

  1. Shrink xvda3 (May be called xvdb3) using resize2fs
  2. Resize the partition. I recommend make it a bit bigger then step one to ensure there is no dataloss
  3. Create your new partition.
share|improve this answer

You must log in to answer this question.

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