Skip to content

Instantly share code, notes, and snippets.

@dataslayermedia
Last active April 4, 2024 16:02
Show Gist options
  • Save dataslayermedia/fd95b15e5b30acd0b5f5cf9032ba9a5d to your computer and use it in GitHub Desktop.
Save dataslayermedia/fd95b15e5b30acd0b5f5cf9032ba9a5d to your computer and use it in GitHub Desktop.
Setting Up an Ethereum 2.0 Node via Geth on Linux // Useful Commands

Useful Commands When Downloading Geth on Linux

geth --http --miner.etherbase 0x15E57AE0eb022a2Ce9E750dF2618441a9F47d595

Print drives on machine

lsblk

Mount an external drive

mount /dev/sda1 /mount-eth2

Open the Geth Javascript Console

geth attach http://127.0.0.1:8545

Check Progress within Geth Javascript Console

var lastPercentage = 0;
var lastBlocksToGo = 0;
var timeInterval = 10000;
setInterval(function () {
    var percentage = eth.syncing.currentBlock / eth.syncing.highestBlock * 100;
    var percentagePerTime = percentage - lastPercentage;
    var blocksToGo = eth.syncing.highestBlock - eth.syncing.currentBlock;
    var bps = (lastBlocksToGo - blocksToGo) / (timeInterval / 1000);
    var etas = 100 / percentagePerTime * (timeInterval / 1000);
    var etaM = parseInt(etas / 60, 10);
    console.log(parseInt(percentage, 10) + '% ETA: ' + etaM + ' minutes @ ' + bps + 'bps');
    lastPercentage = percentage;
    lastBlocksToGo = blocksToGo;
console.log("Remaining Blocks: " + (eth.syncing.highestBlock - eth.syncing.currentBlock));
}, timeInterval);

Upload directory to Google Cloud Storage

gsutil -m cp -r gs://ethereum-chaindata ./

Check Delta of Synced Blocks

eth.syncing.highestBlock - eth.syncing.currentBlock

SSH Into a Compute Engine Instnace Via Local Termianl

ssh -i ~/.ssh/geth username@EXTERNAL_IP

Monitor System Resource Utlization Status

htop

Start Syncing Node

geth --http --miner.etherbase 0xA92f293fF7f639f9d604662d12eac76a103942DD --datadir /ethereum-chain --ipcdisable --cache 60000 --maxpeers 500



geth --http --miner.etherbase 0xA92f293fF7f639f9d604662d12eac76a103942DD --datadir /ethereum-chain --ipcdisable --cache 3000 --maxpeers 5


geth --http --miner.etherbase 0xA92f293fF7f639f9d604662d12eac76a103942DD --datadir /mount-eth2/blockchain --ipcdisable

Start Miner

geth --http --miner.etherbase 0xA92f293fF7f639f9d604662d12eac76a103942DD --datadir /mount-eth2/blockchain --ipcdisable --cache 30048 --maxpeers 150 --mine --miner.threads=4 --metrics

Kill Geth

killall -HUP geth

Show Eth Wallet Address

eth.coinbase

Mount a Virtual Remote Hard Drive

sshfs -o default_permissions,IdentityFile=~/.ssh/geth username@34.66.7.156:/chain2/ /ethereum-chain

List Directory Contents by Size

du -shc ./*

Install Geth on Linux

sudo tar -xvf  geth-linux-amd64-1.8.16-477eb093.tar.gz     

cd geth-linux-amd64-1.8.16-477eb093   

sudo chmod +x geth     

sudo cp geth /usr/local/bin/    

geth version  

TMUX

tmux ls

Detach from Screen

ctrl + b + d

Attach to Screen

tmux attach -t 0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment