4

I'm playing a little bit with LVM. I've noticed that I can add a new HDD, include it in the volume group, and add some space to all of the existing volumes without unmounting theirs filesystem or rebooting the whole machine. But when I tried to do the opposite thing, i.e. to reduce the volumes' space and remove the drive from the system, I was unable to do it online. This can be achieved when the filesystems are unmounted, or from live cd/dvd/pendrive (root filesystem).

So the question is, why the filesystem can't be shrunk online?

1 Answer 1

6

Presumably you already found this: https://serverfault.com/questions/528075/is-it-possible-to-on-line-shrink-a-ext4-volume-with-lvm so the short answer is "because the folks who wrote ext4 don't support this."

The slightly longer answer is that it's hard, especially if maintaining any sort of backward compatibility with ext2. Finding all the bits and pieces of the filesystem that are in use past the end of the desired new size, then moving them all back within that new size is hard enough. Now do it while all the existing aspects of a filesystem's daily chores are still taking place and it becomes super easy to destroy your data. The ext4 folks have essentially said that if you need to shrink... do it safely.

The very long answer delves deep into the internal operations of filesystems and is probably more than you really want to know. But if you do: this might be a good (free) place to start: http://www.nobius.org/~dbg/practical-file-system-design.pdf

2
  • > The slightly longer answer is that it's hard, especially if maintaining any sort of backward compatibility with ext2 Ahh, linux priorities. Commented Jun 17, 2019 at 18:08
  • @duane You also forgot about the "and it becomes super easy to destroy your data". Anyway, this is open source. If it is important to you, write (and test!) the code yourself or pay someone to do so. I believe the requirement is so rare (and unmounting is possible in most cases) that noone bothered. (I.e., if it is so mission-critical that it cannot be paused, then the additional cost for the disk is probably negligible.) Commented Jan 28, 2020 at 15:31

You must log in to answer this question.

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