The first setting can be added into the bitcoin.conf file:
- To change the data directory, create a file called /home/bitcoin/.bitcoin/bitcoin.conf and inside it type the line
datadir=/media/bitcoin_data
As for starting at boot, there is no such option in bitcoin.conf, however you can make a systemd service that starts bitcoind as the "bitcoin" user at system startup.
1. In your VM create a file called bitcoind.service with the following contents:
[Unit]
Description=Run Bitcoin Core as daemon
Wants=network-online.target
After=network.target network-online.target
[Service]
Type=simple
# you may have to change the path of bitcoind
ExecStart=/usr/local/bin/bitcoind # Add command line options here at your will
RemainAfterExit=no
[Install]
WantedBy=multi-user.target
2. Put this file in /usr/lib/systemd/system
3. Run the following commands:
sudo systemctl daemon-reload
sudo systemctl enable bitcoind.service
sudo systemctl start bitcoind.service # alternatively just restart the VM