lnd
uses boltdb files (like channel.db
) to store its data (unless you're already using the new SQL database backend). It's necessary to "compact" these files every now and then, as deleted data still consumes disk space. Compaction is just a "copy-paste" process, where only non-deleted data is copied to the new file - which hopefully is a lot smaller than the original file.During compaction,
lnd
reads and writes rather small updates from/to these files. If your file system is slow (HDD based), this massively slows down the compaction process. If you're using a file system where it is possible to (temporarily?) disable the "sync" feature, you can make use of this to make compaction much faster. In my case, using ZFS, I can use zfs set sync=disabled tank/lnd
(where tank/lnd
is the file system I use for the boltdb data). Note that you should ONLY do this for compaction. Once lnd
is running normally, you absolutely need the "sync" feature. Otherwise, you're at risk of catastrophic financial loss (penalty transactions from your peers). However, for lnd
installations that only serve as a watchtower service, this might still be an acceptable risk (as the watchtower itself is just a backup).Furthermore, you can improve compaction and
lnd
startup time in general by reading the boltdb file once, for example using cat channel.db > /dev/null
. This way, instead of taking data in smaller chunks, the OS can read the file sequentially (which, usually, is much master) and store its contents in memory for future access.