Here is the article:
Unable to use external SSD for Bitcoin datadir in Ubuntu
As a Bitcoin enthusiast and a beginner with a full node setup on Ubuntu, I came across a frustrating issue that was plaguing my system. After setting up an external SSD drive to store the entire Bitcoin blockchain, I was eager to explore ways to optimize my data storage. However, every attempt to use it for the datadir (directory) of my Bitcoin node ended in failure.
Problem

When installing a full node on Ubuntu, you need to specify the datadir, where your node stores its Bitcoin data. The default datadir is usually located at /var/lib/mysqld or /var/lib/bitcoin, but for a full node, we want to use an external drive specifically designed to store large datasets such as an entire blockchain. This can be a separate SSD drive from the main machine.
Solution
After a bit of research and experimentation, I found that setting up the datadir using command line options was not enough to solve this problem. To overcome this obstacle, we need to manually configure the whole node data store.
Here are the steps to resolve this issue:
- Edit the file
/etc/apt/apt.conf.d/50-cloud-init: This file controls the configuration of the Ubuntu system and can be used to set external drives as primary or secondary storage.
- Set the variable
APT_STORAGE_PREFIX: add the following line to the file/etc/apt/apt.conf.d/50-cloud-init:APT_STORAGE_PREFIX=/mnt/bitcoin. Replace/mnt/bitcoinwith the path to your external SSD drive.
- Update APT: Run
sudo apt updatein the terminal to make sure you have the latest package lists.
Additional Tips
- Be sure to create a dedicated user for your full node, e.g.
bitcoin, and set its home directory to/home/bitcoin.
- Update your package list using
sudo apt upgradeorsudo apt full-upgradeto make sure all outdated packages are removed.
- If you are using a different storage device (eg LVM partition), be sure to update the
/etc/apt/apt.conf.d/50-cloud-initfile accordingly.
Conclusion
In this article, we explored the problem of using external SSD drives for Bitcoin datadir in Ubuntu and offered a solution. By modifying the /etc/apt/apt.conf.d/50-cloud-init file and updating APT, you can ensure that your full node data storage is optimized for large data sets such as the Bitcoin blockchain.
I hope this helps fellow Bitcoin enthusiasts and Ubuntu users overcome this frustrating problem!
