Skip to main content

0G Storage Node

Installation

Installing Dependencies

sudo apt install curl git wget htop tmux build-essential jq make lz4 gcc unzip -y

Installing GO

cd $HOME
VER="1.21.3"
wget "https://golang.org/dl/go$VER.linux-amd64.tar.gz"
sudo rm -rf /usr/local/go
sudo tar -C /usr/local -xzf "go$VER.linux-amd64.tar.gz"
rm "go$VER.linux-amd64.tar.gz"
[ ! -f ~/.bash_profile ] && touch ~/.bash_profile
echo "export PATH=$PATH:/usr/local/go/bin:~/go/bin" >> ~/.bash_profile
source $HOME/.bash_profile
[ ! -d ~/go/bin ] && mkdir -p ~/go/bin

Installing Rust

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source ~/.profile
source ~/.cargo/env

Initializing and configuring the Storage node

git clone https://github.com/0glabs/0g-storage-node.git
cd $HOME/0g-storage-node
git stash
git fetch --all --tags
git checkout v1.1.0
git submodule update --init
cargo build --release

Set config

rm -rf $HOME/0g-storage-node/run/config-testnet-turbo.toml

curl -o $HOME/0g-storage-node/run/config-testnet-turbo.toml https://snapshot.kgnodes.xyz/snapshot/0gchain/config-testnet-turbo.toml

### Add your Rpc Endpoint and Miner Private Key into config-testnet-turbo.toml file

Create Service

sudo tee /etc/systemd/system/zgsd.service > /dev/null <<EOF
[Unit]
Description=ZGS Node
After=network.target

[Service]
User=root
WorkingDirectory=$HOME/0g-storage-node/run
ExecStart=$HOME/0g-storage-node/target/release/zgs_node --config config-testnet-turbo.toml --miner-key Private-key --blockchain-rpc-endpoint https://evmrpc-testnet.0g.ai/
Restart=on-failure
RestartSec=10
LimitNOFILE=65535

[Install]
WantedBy=multi-user.target
EOF

Start Service

sudo systemctl daemon-reload
sudo systemctl enable zgsd
sudo systemctl restart zgsd

Snapshot

systemctl stop zgsd
rm -rf $HOME/0g-storage-node/run/db/flow_db
wget https://snapshot.kgnodes.xyz/snapshot/0gchain/snap_flow_db_20250721_220247.tar.lz4 -O $HOME/0g-storage-node/run/db/flow_db.tar.gz && tar -xzvf $HOME/0g-storage-node/run/db/flow_db.tar.gz -C $HOME/0g-storage-node/run/db/
systemctl start zgsd

Check Logs

tail -f ~/0g-storage-node/run/log/zgs.log.$(TZ=UTC date +%Y-%m-%d)