This is a guide on how I managed to do mining on Magi Coin (XMG) on La Frite, a single board computer by Libre Computer. This coin mining is not a get rich solution, rather it is a good experience on how crypto mining works. Coin Magi (XMG) is a CPU only coin. You can't mine Magi with a GPU. Magi is a POW and POS coin.
Installing Magi Wallet
I am running headless armbian bionic OS (20.02.3) on my La Frite with the OS installed on an 8GB flash disk. We need to install dependencies required to install Magi Wallet on the La Frite.
sudo apt install -y git automake libdb-dev libboost-all-dev libminiupnpc-dev libgmp-dev libdb5.3++-dev
The La Frite that I am using is only 1GB RAM. Running the wallet takes up a lot of memories, so I have to create swapfile. I added 1G swap size using the following command.
sudo fallocate -l 1G /swapfile
Give root access to the swap file.
sudo chmod 600 /swapfile
Set up the swap area.
sudo mkswap /swapfile
Activate the swapfile.
sudo swapon /swapfile
To use this swapfile permanently, paste the code in fstab.
sudo nano /etc/fstab /swapfile swap swap defaults 0 0
Verify that swap is active:
sudo swapon --show sudo free -h
Now we can clone the Magi project into La Frite.
git clone https://github.com/magi-project/magi
Go into magi directory and start our wallet compilation.
cd ~/magi/src make -f makefile.unix xCPUARCH=armv7l
It is safe to ignore any warnings, but errors will cause the compilation not completed. Compilation takes a few hours to complete.
Use the following command to enable wallet to be called from any directory.
cd ~/magi/src sudo install -m 755 magid /usr/bin/magid
Create wallet configuration file.
sudo nano ~/.magi/magi.conf
Add the following into the file.
rpcuser=[any username] rpcpassword=[any password] rpcport=8232 server=1 listen=1 rpcallowip=127.0.0.1 addnode=188.8.131.52 addnode=184.108.40.206 posii=1 stakesplitthreshold=500 stakecombinethreshold=500
The blockchain size will keep growing, it is better that we create a symbolic link to an external disk. I am using an 8GB flash disk with ext4 format.
To ensure our flash disk is mounted each time we reboot, edit /etc/fstab:
/dev/sdb1 /mnt/[your mount directory] ext4 defaults
You can check disk location with the command: fdisk -l
Create symbolic link to the external disk.
cd /mnt/[your mount directory] sudo mkdir magi_data ln -s /mnt/[your mount directory] ~/.magi
.magi is located in home directory, is where the wallet will write program to. Symbolic link will instead let the wallet writes to our external disk.
Download the blockchain data, to save some time from blockchain syncing.
Extra the blocks and database folders and move into ~/.magi.
tar -xvf m-blocks-chain.tar.gz cd m-block-chain mv blocks database -t ~/.magi
Finally, let's initiate our wallet.
If the following error occur, give permission to the wallet directory.
sudo chown <your username>:<your usergroup> -R ~/.magi
Restart magid -daemon.
You can use the command top to check if magid is running. Ctrl + C to quit the process.
It may takes several minutes for the wallet to run. Use getinfo to check your wallet status.
We need to encrypt our wallet for safety purposes.
magid encryptwallet PASSWORD
Next, unlock the wallet for staking.
magid walletpassphrase PASSWORD 9999999 true
To see what other commands available.
Remember to backup your wallet regularly and move out of the machine.
magid backupwallet ~/YYYYMMDD_wallet.dat
Installing Magi CPUminer
We may have to install more dependencies such as gawk, gcc if errors occurred during compilation. We can see which dependencies are missing in the errors.
sudo apt install gawk, gcc
Clone cpuminer project.
git clone https://github.com/magi-project/m-cpuminer-v2
Run the following commands.
./autogen.sh ./configure CFLAGS="-O2 -mcpu=cortex-a53 -mfpu=neon-vfpv4" sed -i -- 's/-march=native/-mcpu=cortex-a53/g' Makefile make
You can sign up with any Mining Pool. We need to register a 'worker', which is our La Frite. We need to set a worker username and password. Once done, we can let our worker do the mining.
m-minerd -t 3 -o stratum+tcp://MiningPoolURL:Port -u Login.Worker -p Password
- -t 3 : limits the amount of cores uses. La Frite has 4 cores. Try not to use all the cores.
- MiningPoolURL : the URL of Mining Pool.
- Port : the port number that Mining Pool use.
- Login : your Mining Pool username.
- Worker : your worker name.
- Password : your worker password.
Tips: Use screen command to run miner on another screen. Press Ctrl + A then D to detach screen and keep the miner running. Use command screen -r to re-attach the screen.
My La Frite is able to achieve 10kH/s on average. Hope that this guide helps any one who wishes to learn about crypto mining.