3

I am migrating to a new server where I'm going to use LVM partitioning on a RAID 1 array (2 hard drives). I have read some tutorials which advise to leave some space unused so that I can expand the partition later, if needed.

Now, with the new hardware that is large for my uses, I could afford that, but I wonder if this makes any sense: why would I do that? Is it somehow easier, say, to expand /var into unused space later on, than to shrink main partition and expand /var?

Nickolai Leschov
  • 457
  • 4
  • 8
  • 22

2 Answers2

4

Should you... depends. One huge reason to keep extra space around is so you can use LVM snapshots. With no free space you cannot use them.

As for the reasoning 'so you can expand into it later'.. meh. I'd rather size accordingly and not run into the need to expand later on. Expanding 0 times is easier/faster than expanding 1 time.

As for being easier to simply expand vs shrink and expand, it's obviously easier. One command to grow the logical volume, another to grow the filesystem -vs- one to shrink the filesystem, one to shrink the logical volume (of shrunken filesystem), one to grow the other logical volume, another to expand the filesystem.

If you're comfortable shrinking filesystems and logical volumes then it's not really any harder. Just more steps.

  • Ah, snapshots. That might be the real reason to keep extra space. I wonder how I might be using them? I was going to run several virtual machines on a host system, and most of the stuff would happen within the virtual machines. Does it imply that it's actually more important for me to set up LVM *within* virtual machines? – Nickolai Leschov Mar 24 '14 at 23:32
  • I would just use LVM on everything. On the VMs adding disk space is easier with LVM IMO (pvresize/vgresize/lvresize vs editing the partitions and hope you don't enter a wrong number). On the host system I would keep extra space around if you plan on backing up the VMs. If you need to pause the VMs to get a consistent backup you would only need to pause as long as it takes to create the snapshot (a few seconds at most). Then you can backup the snapshot while the VMs are happily running. –  Mar 24 '14 at 23:38
  • So, to clarify, where should I leave free space on the host system to take snapshots (unallocated, or allocated and free) and how do I take them? – Nickolai Leschov Mar 26 '14 at 13:08
  • The space should be free on your volume group. –  Mar 26 '14 at 15:52
3

to expand /var into unused space later on, than to shrink main partition

Expanding logical volumes and filesystems can be done while the system is running and the filesystem is mounted (for the more common filesystems). Shrinking a filesystem means you have to unmount that filesystem (for the FS, that support a shrink). If you are talking about your root, or some other critical filesystem, this means taking your system offline and possibly booting from some kind of rescue media to perform the resize of the filesystem and volume.

So leaving yourself free space means you can expand a filesystem, or create new ones when you need to with little or no apparent impact on normal operations.

Zoredache
  • 130,897
  • 41
  • 276
  • 420