Skip to content

Commit

Permalink
change datadir to /data
Browse files Browse the repository at this point in the history
The basic setup stores all data on the same external drive that
also holds the operating system. This storage is not mounted as a
separate drive.

Therefore, using a data directory like '/mnt/whatever' does not seem
appropriate and is misleading.

The new '/data/' directory can still be a mountpoint, or an external
drive can be mounted as '/mnt/data', with '/data' linking to it.
  • Loading branch information
Stadicus committed Nov 26, 2021
1 parent 08d125f commit 78649a0
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 43 deletions.
8 changes: 4 additions & 4 deletions bitcoin-core.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ You can read more on [How to securely install Bitcoin](https://medium.com/@luked
### Create data folder

Bitcoin Core uses by default the folder `.bitcoin` in the user's home.
Instead of creating this directory, we create a data directory in the general data location `/mnt/data` and link to it.
Instead of creating this directory, we create a data directory in the general data location `/data` and link to it.

* Switch to user "bitcoin"

Expand All @@ -105,13 +105,13 @@ Instead of creating this directory, we create a data directory in the general da
* Create the Bitcoin data folder

```sh
$ mkdir /mnt/data/bitcoin
$ mkdir /data/bitcoin
```

* Create the symbolic link `.bitcoin` that points to that directory

```sh
$ ln -s /mnt/data/bitcoin /home/bitcoin/.bitcoin
$ ln -s /data/bitcoin /home/bitcoin/.bitcoin
```

* Display the link and check that it is not shown in red (this would indicate an error)
Expand Down Expand Up @@ -234,7 +234,7 @@ Still logged in as user "bitcoin", let's start "bitcoind" manually.
This allows "admin" to work with bitcoind directly, for example using the command `bitcoin-cli`

```sh
$ ln -s /mnt/data/bitcoin /home/admin/.bitcoin
$ ln -s /data/bitcoin /home/admin/.bitcoin
```

### Autostart on boot
Expand Down
4 changes: 2 additions & 2 deletions btcrpcexplorer.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ For the BTC RPC Explorer to work, you need your full node to index all transacti
```

Please note that reindexing can take more than a day.
You can follow the progress using `sudo tail -f /mnt/data/bitcoin/debug.log`.
You can follow the progress using `tail -f ~/.bitcoin/debug.log`.

### Install NodeJS

Expand Down Expand Up @@ -166,7 +166,7 @@ found 12 vulnerabilities (8 moderate, 4 high)
```sh
BTCEXP_BITCOIND_HOST=127.0.0.1
BTCEXP_BITCOIND_PORT=8332
BTCEXP_BITCOIND_COOKIE=/mnt/data/bitcoin/.cookie
BTCEXP_BITCOIND_COOKIE=/data/bitcoin/.cookie
```

* Extend the timeout period due to the limited resources of the Raspberry Pi
Expand Down
20 changes: 10 additions & 10 deletions electrs.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,20 +135,20 @@ We get the latest release of the Electrs source code, verify it, compile it to a
* Create the Electrs data directory

```sh
$ sudo mkdir /mnt/data/electrs
$ sudo chown -R electrs:electrs /mnt/data/electrs
$ sudo mkdir /data/electrs
$ sudo chown -R electrs:electrs /data/electrs
```

* Switch to the "electrs" user and create the config file with the following content

```sh
$ sudo su - electrs
$ nano /mnt/data/electrs/electrs.conf
$ nano /data/electrs/electrs.conf
```

```sh
# RaspiBolt: electrs configuration
# /mnt/data/electrs/electrs.conf
# /data/electrs/electrs.conf

# Bitcoin Core settings
network = "bitcoin"
Expand All @@ -158,7 +158,7 @@ We get the latest release of the Electrs source code, verify it, compile it to a

# Electrs settings
electrum_rpc_addr = "127.0.0.1:50001"
db_dir = "/mnt/data/electrs/db"
db_dir = "/data/electrs/db"
index_lookup_limit = 1000

# Logging
Expand All @@ -170,14 +170,14 @@ We get the latest release of the Electrs source code, verify it, compile it to a
It will immediately start with the initial indexing of the Bitcoin blocks.

```sh
$ electrs --conf /mnt/data/electrs/electrs.conf
$ electrs --conf /data/electrs/electrs.conf
```

```sh
Starting electrs 0.9.3 on aarch64 linux with Config { network: Bitcoin, db_path: "/mnt/data/electrs/db/bitcoin", daemon_dir: "/home/bitcoin/.bitcoin", daemon_auth: CookieFile("/home/bitcoin/.bitcoin/.cookie"), daemon_rpc_addr: 127.0.0.1:8332, daemon_p2p_addr: 127.0.0.1:8333, electrum_rpc_addr: 127.0.0.1:50001, monitoring_addr: 127.0.0.1:4224, wait_duration: 10s, jsonrpc_timeout: 15s, index_batch_size: 10, index_lookup_limit: Some(1000), reindex_last_blocks: 0, auto_reindex: true, ignore_mempool: false, sync_once: false, disable_electrum_rpc: false, server_banner: "Welcome to electrs 0.9.3 (Electrum Rust Server)!", args: [] }
Starting electrs 0.9.3 on aarch64 linux with Config { network: Bitcoin, db_path: "/data/electrs/db/bitcoin", daemon_dir: "/home/bitcoin/.bitcoin", daemon_auth: CookieFile("/home/bitcoin/.bitcoin/.cookie"), daemon_rpc_addr: 127.0.0.1:8332, daemon_p2p_addr: 127.0.0.1:8333, electrum_rpc_addr: 127.0.0.1:50001, monitoring_addr: 127.0.0.1:4224, wait_duration: 10s, jsonrpc_timeout: 15s, index_batch_size: 10, index_lookup_limit: Some(1000), reindex_last_blocks: 0, auto_reindex: true, ignore_mempool: false, sync_once: false, disable_electrum_rpc: false, server_banner: "Welcome to electrs 0.9.3 (Electrum Rust Server)!", args: [] }
[2021-11-09T07:09:42.744Z INFO electrs::metrics::metrics_impl] serving Prometheus metrics on 127.0.0.1:4224
[2021-11-09T07:09:42.744Z INFO electrs::server] serving Electrum RPC on 127.0.0.1:50001
[2021-11-09T07:09:42.812Z INFO electrs::db] "/mnt/data/electrs/db/bitcoin": 0 SST files, 0 GB, 0 Grows
[2021-11-09T07:09:42.812Z INFO electrs::db] "/data/electrs/db/bitcoin": 0 SST files, 0 GB, 0 Grows
[2021-11-09T07:09:43.174Z INFO electrs::index] indexing 2000 blocks: [1..2000]
[2021-11-09T07:09:44.665Z INFO electrs::chain] chain updated: tip=00000000dfd5d65c9d8561b4b8f60a63018fe3933ecb131fb37f905f87da951a, height=2000
[2021-11-09T07:09:44.986Z INFO electrs::index] indexing 2000 blocks: [2001..4000]
Expand Down Expand Up @@ -216,7 +216,7 @@ Electrs needs to start automatically on system boot.

# Service execution
###################
ExecStart=/usr/local/bin/electrs --conf /mnt/data/electrs/electrs.conf
ExecStart=/usr/local/bin/electrs --conf /data/electrs/electrs.conf

# Process management
####################
Expand Down Expand Up @@ -439,7 +439,7 @@ Make sure to check the [release notes](https://github.com/romanz/electrs/blob/ma
$ sudo mv ./target/release/electrs /usr/local/bin/
# Update the Electrs configuration if necessary (see release notes)
$ nano /mnt/data/electrs/electrs.conf
$ nano /data/electrs/electrs.conf
# Start Electrs
$ sudo systemctl restart electrs
Expand Down
12 changes: 6 additions & 6 deletions faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ Copy it to a USB thumbdrive, so that you can restore it later.
* Copy the whole LND data directory to the thumbdrive

```sh
$ sudo rsync -rhv /ext/mnt/lnd /mnt/thumbdrive/
$ sudo rsync -rhvP --append-verify /mnt/ext/lnd /mnt/thumbdrive/
```

* Also make sure to create a Static Channel Backup file and copy it to the thumbdrive
Expand All @@ -72,7 +72,7 @@ That could result in you losing all your funds.
* Move your LND directory to prevent the node starting again by accident.

```sh
$ sudo mv /ext/mnt/lnd /ext/mnt/lnd-do-never-start-again
$ sudo mv /mnt/ext/lnd /mnt/ext/lnd-do-never-start-again
```

Once you set up your new RaspiBolt 3, restore your old LND node setup.
Expand All @@ -86,7 +86,7 @@ Once you set up your new RaspiBolt 3, restore your old LND node setup.
$ sudo mkdir /mnt/thumbdrive
$ lsblk -pli
$ sudo mount /dev/sdb1 /mnt/thumbdrive/
$ sudo rsync -rhv /mnt/thumbdrive/ /ext/mnt/lnd
$ sudo rsync -rhvP --append-verify /mnt/thumbdrive/lnd /data
```

### Backup & Restore Bitcoin data
Expand All @@ -101,13 +101,13 @@ When **Reusing the old drive** for your new node, you must first copy the data t
* Example for network copy

```sh
$ rsync -rhv [email protected]:/mnt/ext/bitcoin /your-local-directory
$ rsync -rhvP --append-verify [email protected]:/mnt/ext/bitcoin /your-local-directory
```

* Example for local drive-to-drive copy with both drives mounted

```sh
$ rsync -rhv /mnt/old-raspibolt-drive/bitcoin /mnt/new-drive/mnt/data
$ rsync -rhvP --append-verify /mnt/old-raspibolt-drive/bitcoin /mnt/raspibolt-v3-drive/data
```

---
Expand All @@ -120,7 +120,7 @@ For a specific command, you can enter `man [command]` to display the manual page
| command | description | example |
| -- | -- | -- |
| `cd` | change to directory | `cd /home/bitcoin` |
| `ls` | list directory content | `ls -la /mnt/ext` |
| `ls` | list directory content | `ls -la /data` |
| `cp` | copy | `cp file.txt newfile.txt` |
| `mv` | move | `mv file.txt moved_file.txt`
| `rm` | remove | `rm temporaryfile.txt`
Expand Down
26 changes: 13 additions & 13 deletions lnd.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,16 +90,16 @@ Now that LND is installed, we need to configure it to work with Bitcoin Core and
* Create the LND data directory

```sh
$ sudo mkdir /mnt/data/lnd
$ sudo chown -R lnd:lnd /mnt/data/lnd
$ sudo mkdir /data/lnd
$ sudo chown -R lnd:lnd /data/lnd
```

* Also create a separate directory for the channel backup.
Alternatively, you can [mount a USB thumbdrive to this location](https://linuxconfig.org/howto-mount-usb-drive-in-linux){:target="_blank"} for added redundancy.

```sh
$ sudo mkdir /mnt/lnd-backup
$ sudo chown -R lnd:lnd /mnt/lnd-backup
$ sudo mkdir /data/lnd-backup
$ sudo chown -R lnd:lnd /data/lnd-backup
```

* Open a "lnd" user session
Expand All @@ -111,8 +111,8 @@ Now that LND is installed, we need to configure it to work with Bitcoin Core and
* Create symbolic links pointing to the LND and bitcoin data directories

```sh
$ ln -s /mnt/data/lnd /home/lnd/.lnd
$ ln -s /mnt/data/bitcoin /home/lnd/.bitcoin
$ ln -s /data/lnd /home/lnd/.lnd
$ ln -s /data/bitcoin /home/lnd/.bitcoin
```

* Display the links and check that they're not shown in red (this would indicate an error)
Expand All @@ -134,13 +134,13 @@ To give some perspective: other Lightning implementations like c-lightning or Ec
* As user "bitcoin", create a text file and enter your LND wallet `password [C]`. Save and exit.

```sh
$ nano /mnt/data/lnd/password.txt
$ nano /data/lnd/password.txt
```

* Tighten access privileges and make the file readable only for user "lnd":

```sh
$ chmod 600 /mnt/data/lnd/password.txt
$ chmod 600 /data/lnd/password.txt
```

To improve the security of your wallet, check out these more advanced methods:
Expand All @@ -154,23 +154,23 @@ To improve the security of your wallet, check out these more advanced methods:
Save and exit.

```sh
$ nano /mnt/data/lnd/lnd.conf
$ nano /data/lnd/lnd.conf
```

```sh
# RaspiBolt: lnd configuration
# /mnt/data/lnd/lnd.conf
# /data/lnd/lnd.conf

[Application Options]
alias=YOUR_FANCY_ALIAS
debuglevel=info
maxpendingchannels=5
listen=localhost
backupfilepath=/mnt/lnd-backup/channel.backup
backupfilepath=/data/lnd-backup/channel.backup

# Password: automatically unlock wallet with the password in this file
# -- comment out to manually unlock wallet, and see RaspiBolt guide for more secure options
wallet-unlock-password-file=/mnt/data/lnd/password.txt
wallet-unlock-password-file=/data/lnd/password.txt
wallet-unlock-allow-create=true

# Channel settings
Expand Down Expand Up @@ -277,7 +277,7 @@ Once LND is started, the process waits for us to create the integrated Bitcoin w

These 24 words (combined with your optional passphrase `password [D]`) is all that you need to restore the Bitcoin on-chain wallet.
The current state of your channels, however, cannot be recreated from this seed.
For this, the Static Channel Backup stored at `/mnt/lnd-backup/channel.backup` is updated continuously.
For this, the Static Channel Backup stored at `/data/lnd-backup/channel.backup` is updated continuously.

🚨 This information must be kept secret at all times.
**Write these 24 words down manually on a piece of paper and store it in a safe place.**
Expand Down
4 changes: 2 additions & 2 deletions rtl.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ We do not want to run Ride the Lightning alongside bitcoind and lnd because of s
* Create a new user, copy the LND credentials and open a new session
```sh
$ sudo adduser --disabled-password --gecos "" rtl
$ sudo cp /mnt/data/lnd/data/chain/bitcoin/mainnet/admin.macaroon /home/rtl/admin.macaroon
$ sudo cp /data/lnd/data/chain/bitcoin/mainnet/admin.macaroon /home/rtl/admin.macaroon
$ sudo chown rtl:rtl /home/rtl/admin.macaroon
$ sudo su - rtl
```
Expand Down Expand Up @@ -165,7 +165,7 @@ Now we take the sample configuration file and add change it to our needs.

```sh
"macaroonPath": "/home/rtl"
"configPath": "/mnt/data/lnd/lnd.conf"
"configPath": "/data/lnd/lnd.conf"
```
* Save and exit

Expand Down
8 changes: 4 additions & 4 deletions system-configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,15 +149,15 @@ The “Advanced Packaging Tool” (apt) makes this easy.

## Data directory

We'll store all application data in the dedicated directory `/mnt/data/`.
We'll store all application data in the dedicated directory `/data/`.
This allows for better security because it's not inside any user's home directory.
Additionally, it's easier to move that directory somewhere else, for instance to a separate drive, as you can just mount any storage option to `/mnt/data/`.
Additionally, it's easier to move that directory somewhere else, for instance to a separate drive, as you can just mount any storage option to `/data/`.

* Create the directory and make user "bitcoin" its owner

```sh
$ sudo mkdir -p /mnt/data
$ sudo chown bitcoin:bitcoin /mnt/data
$ sudo mkdir /data
$ sudo chown bitcoin:bitcoin /data
```

---
Expand Down
4 changes: 2 additions & 2 deletions troubleshooting.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,8 @@ $ sudo su - bitcoin
$ touch /home/bitcoin/test
$ ls -la /home/bitcoin/
.
lrwxrwxrwx 1 bitcoin bitcoin 16 Nov 13 21:47 .bitcoin -> /mnt/ext/bitcoin
lrwxrwxrwx 1 bitcoin bitcoin 12 Nov 13 22:28 .lnd -> /mnt/ext/lnd
lrwxrwxrwx 1 bitcoin bitcoin 16 Nov 13 21:47 .bitcoin -> /data/bitcoin
lrwxrwxrwx 1 bitcoin bitcoin 12 Nov 13 22:28 .lnd -> /data/lnd
-rw-r--r-- 1 bitcoin bitcoin 0 Nov 27 18:36 test
.
```
Expand Down

0 comments on commit 78649a0

Please sign in to comment.