Linux users guide¶
This guide runs a node on Linux, on Ethereum Classic or on the Mordor test network, from an installed geth to a service that starts at boot. Running a node covers what every platform shares.
Commands are shown for both networks. Use the lines for the network you chose, and keep its flag on every command.
1. Install¶
Install geth as Installation shows for x86_64 or ARM, then check it:
1 | |
2. Choose the network¶
| Network | Flag | Data directory |
|---|---|---|
| Ethereum Classic | --classic | ~/.ethereum/classic |
| Mordor | --mordor | ~/.ethereum/mordor |
With no flag, the node runs Ethereum Classic. This guide passes --classic anyway, so that every command says which network it is for.
3. Start the node¶
Other nodes reach yours on port 30303, over TCP and UDP. Allow it through your firewall (A host firewall), then start the node:
1 2 | |
The node runs in the foreground and logs to the terminal. Its first line names the network: Starting Core-Geth on Ethereum Classic... or Starting Core-Geth on Mordor testnet.... What a healthy first sync looks like explains the lines that follow.
For a configuration, add its flags after the network flag, such as geth --classic --http --http.api eth,net,web3, and add them to ExecStart in step 6 as well.
To keep the chain on another disk, add --datadir, such as --datadir /data/core-geth/mordor. Then give attach the socket inside that directory: geth --mordor attach /data/core-geth/mordor/geth.ipc.
4. Check that it syncs¶
In a second terminal:
1 2 3 4 5 6 7 8 9 | |
attach looks for the node’s socket in the data directory of the network you name. Without --mordor, it looks in ~/.ethereum/classic and does not find a Mordor node: no such file or directory. How to tell it is done lists every sign of a finished sync.
5. Use it¶
attach without --exec opens an interactive console on the node. Type exit to leave it; the node keeps running.
1 | |
For wallets and programs, start the node with --http, such as geth --mordor --http. It serves JSON-RPC on 127.0.0.1:8545. From a second terminal:
1 2 | |
The result is 0x3d on Ethereum Classic and 0x3f on Mordor. Read RPC exposure before you serve it beyond 127.0.0.1.
6. Keep it running: a systemd service¶
The project ships no service unit, so this one is an example to adapt. It runs the node as a dedicated user, starts it at boot, restarts it if it fails, and gives it five minutes to stop.
Create the user. --create-home matters: geth attach needs a home directory it can write to, even when you give it the socket’s path.
1 | |
Save the unit. For Ethereum Classic, save this as /etc/systemd/system/core-geth.service:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | |
For Mordor, save the same unit as /etc/systemd/system/core-geth-mordor.service, with these three lines in place of the ones they match:
1 2 3 | |
Start it now and at every boot, then follow its log. For Mordor, use core-geth-mordor in place of core-geth. Reading the system journal takes membership of the adm or systemd-journal group, or sudo:
1 2 3 | |
What the unit’s settings do:
StateDirectoryhas systemd create the data directory under/var/lib, owned bygeth. To keep a data directory you already synced in the foreground, put its path in--datadirinstead, and make it owned bygeth.ExecStartuses the path Installation installsgethto. A configuration’s flags go at the end of it.Restart=on-failurerestarts the node after it exits with an error or dies from a signal such as SIGKILL. A node that shuts itself down because the disk is nearly full exits cleanly, so systemd leaves it stopped (running out of disk).TimeoutStopSec=300is how long systemd waits after its SIGTERM before it kills the node with SIGKILL. Five minutes is well beyond every clean stop measured, including one made during a first sync (stop times). A killed node skips the shutdown that writes its state to disk.
The node’s socket belongs to geth, and only geth and root can connect to it, so run attach as geth. -H gives it geth’s home directory to write to:
1 2 | |
Both services on one host also need separate ports: Mordor beside Ethereum Classic on one host.
7. Stop it cleanly¶
- In the foreground: press Ctrl-C once, then wait for
Blockchain stoppedand the prompt. - As a service:
sudo systemctl stop core-geth, orcore-geth-mordor. systemd waits up toTimeoutStopSecfor the node to finish.
Pressing Ctrl-C again does not speed it up. Stop it safely shows what a clean stop logs, and why a stop during the first sync takes longer.
8. Update it¶
Stop the node, install the new release’s geth the same way as in step 1, and start the node again. Upgrading within v1.13.x lists what to read and check. A node on a v1.12.x release follows the Linux migration guide instead.