When buying droplets, as DigitalOcean calls their cloud VM's, they are always configured with one large ext4 partition.

I have an app that needs an LVM partition, so I need a creative way to shrink the root partition to e.g. 25%, and use the rest for LVM. I can do it on a fresh instance, where I can reboot all I want.

For performance reasons I really would like to avoid a loop device, where I create an LVM partition in a file on top of ext4.


Can someone come up with a creative way to shrink a live ext4 filesystem, where reboots are fine?


3 Answers 3


For Digital Ocean in particular, you can boot the droplet into a rescue image.

For older distributions that boot from an external kernel, you can select to boot it into a rescue image yourself.

For newer distributions that boot from a kernel inside the droplet, you can file a support ticket to have the rescue image mounted as an ISO. Once you are done with your operations, update the support ticket to have the rescue image removed, and reboot.


Take a look at this answer, and a variety of searching, but the short answer is what you are talking about is not possible on a live filesystem unless it is possible to unmount the partition you wish to resize. Since it does not seem like that is possible in this case rebooting to a rescue image is probably the best option.

If rebooting to a rescue image is not an option, but rebooting to a new image is and you have a good backup of the image you want there may be a novel solution. It seems like it would be possible to use Clonezilla with the clone to smaller partition options to clone your existing system onto a new instance that takes up less space. This of course assumes that there is enough free space to shrink the ext4 filesystem onto a smaller partition, but you probably would not have asked the question if there was not enough freespace to shrink the partition.


You can shrink an online root partition without any reboots: consult this answer. This answer is very well written and easy to follow. So this would work on any type of dedicated or VPS solution.

TLDR; this solution implies to pivot_root to tmpfs so you can umount safely your root partition live and fiddle with it. Once done, you'll pivot_root back on your new root partition.

This allows pretty much any manipulation on the root file system (move it, change filesystem, changing it's physical device...).

No reboot are required in the process, and this allows to bypass limitation of not being able to shrink mount ext4 partition.

I have personally used this, and it works very well on debian system also, with very few corrections. I'm very surprised not to see this in-depth solution a little more linked to the many question in stackexchange web sites that deals with the same issue.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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