Linux tip: LVM snapshots are a handy feature, but they will destroy your boot time if they diverge very far.
I do a lot of development and testing in virtual machines. Sometimes if I want to try something disruptive, I’ll do it in a clone of some base image. Using LVM snapshots makes it easy and quick to create the new image.
But recently I noticed my workstation was taking abnormally long to boot. The command “
systemd-analyze blame” told me that fedora-storage-init.service alone was taking over two minutes. While I imagine this might happen occasionally with fsck, it certainly shouldn’t take so long every time.
I finally found out that the culprit was the LVM vgchange command which initializes the volumes, and apparently this can take quite a while with snapshots to enumerate the extents. I had a few old snapshotted machines I had used for testing, and the base images those had originated from had since diverged quite a bit due to simple update activity.
I didn’t need those tests anymore, so delete them and reboot — and I booted in only 15 seconds, which even includes a few seconds to enter the encryption passphrase! This is an order of magnitude faster — or rather, now I know the LVM snapshots were causing an order of magnitude slowdown.
Lesson learned, don’t keep LVM snapshots around for a long time. It’s too bad, because this capability is otherwise very useful…