Mining LBRY from a Live Ubuntu USB drive

in lbry •  8 years ago  (edited)

If you have an extra computer around and would like to mine LBRY (LBC) but don't want to go through the effort of installing a virtual machine or creating a dual boot... This might be for you.

Here is an example situation: you have a extra computer but you don't want to mess with disks, formatting, dual booting and stuff like that. So what do you do? You create a live USB Ubuntu stick that you plug in the back and let it run for as long as you need it to. The only thing that you need from that computer is it's CPU power. If the computer needs to go back into it's original state, transfer the mined funds to a wallet that is more permanent and you are done. Unplug the USB and the computer will look like it has never been touched.

Requirements

  1. Computer with USB boot support and a free USB slot.
  2. USB stick bigger than 2 gigabytes.
  3. Internet access on that computer
  4. Ubuntu image
  5. Rufus
  6. A lot of freaggin' CPU power

Ubuntu Image

So assuming you have a free computer that you want to mine with we are starting off creating a bootable Ubuntu usb drive. First of all we are going to need a Ubuntu image. You can get it at http://www.ubuntu.com/download/desktop or if you want to try alternative downloads (like a torrent) you can get it at http://www.ubuntu.com/download/alternative-downloads.

Rufus

Next we need Rufus! It's a great tool to write an image to USB with and make it bootable. When booting it up you might see all fields empty, that's because you haven't inserted your USB yet. The interface should look like the image below after inserting an USB stick. Use the same settings as I did and make sure to select "ISO Image" under "Create a bootable disk using" dropdown menu.

Rufus interface
Rufus interface

Now hit the little disk button and select your Ubuntu Image like below.

Select your Ubuntu image
Select your Ubuntu image

Now hit start and you will be seeing the next pop up.

03_rufus

In this case we are fine with the recommended setting. Now next we make the biggest life decision ever! Are you dedicated to wipe you entire usb schtick? Make sure you have made a backup before wiping this! You will lose all your data currently on it!

Wiping all data WHAT?!
Wiping all data WHAT?!1!

Booting into live Ubuntu


Now that we have our image on our USB it is bootable! Make sure your computer is off and plug it into a USB port in your computer. While going through your BIOS startup most of the time it will say something like: "Hit button [x] to enter startup menu". HIT THAT KEY! Because we need to select our USB drive to boot from! Most of the time the boot menu key will be F8, F9 or ESC. I've seen a lot of different ones. Once you are in the boot menu select your USB drive and we are off!

When it's finally done booting into your USB you should have screen in front of you like below. Long and behold the Ubuntu Installer!

Try Ubuntu
Try Ubuntu

Wait what? Install Ubuntu, that's not what we came for?! Noooo! We want to hit Try Ubuntu!

Ubuntu live!
Ubuntu live!

Woohoo! We are now running live Ubuntu desktop! Just remember, this is not installed on your local hard disk... It's running live from your USB stick! That means everything you do here will be erased once you shutdown. So don't make the mistake of rebooting! Phew, now that we've got our Ubuntu live running let's get to mining! This step is suprisingly quick! First of all, make sure you know how many processors you want to commit to the job. In Ubuntu we can easily see with System Monitor how many processors we have!

Ubuntu System Monitor
Ubuntu System Monitor

Oef! I guess I'm lucky.... But now get your sweet buns over to https://lbry.io/faq/mining-credits. But for reading pleasure I'll copy what they say over there in here.

Open your terminal either via the menu or via ctrl+alt+t and type the following commands:

  1. wget https://s3.amazonaws.com/files.lbry.io/bins.zip
  2. unzip bins.zip
  3. ./lbrycrdd -server -printtoconsole -gen -genproclimit=<number of proccessors you want to use>
  4. example in my case: ./lbrycrdd -server -printtoconsole -gen -genproclimit=16
  5. If you need to start over, run rm -rf bins.zip lbry* ~/.lbry*. Note: this will delete your wallet and any credits you may have.
Awesome, at this point we should be mining!!!

Mining LBRY (LBC)!
Mining LBRY (LBC)!

If you want to double check if you are indeed mining. Open up a new terminal and hit this command: ./lbrycrd-cli getgenerate. This should return true if you are indeed mining. Also your processor usage should be going through the roof!

But wait, you have been mining for over 4 hours now and you have no idea if you have cashed in any LBC yet?! Before you lose your cool, lets see how it looks when we have solved a block!

Block found!
Block found!

Shazam! We have found a block! But how do we check if we got it in our wallet already? We can use ./lbrycrd-cli getwalletinfo for that. Below you can see that we have 29 LBC in immature balance. This means that the reward is there, but still needs 100 confirmations to mature. Usually this will take 4 hours to actually transfer to your normal balance. Once it is in your balance, you can do with it what you want!

Wallet information
Wallet information

So now lets say you have those 29 coins confirmed and it doesn't list under immature_balance but under balance. How do we get the coins from the live Ubuntu to a more reliable place to store the coins? You can use:

./lbrycrd-cli sendtoaddress <ADDRESS> <AMOUNT> "<COMMENT>"

In example:

./lbrycrd-cli sendtoaddress bbAMzSkboLfWnqqrT6BoxVufbJcMjkzENr 20 "From Mining"

On your coin storage computer use ./lbrycrd-cli getnewaddress. This will create a new address on your storage computer. Use this address in the sendtoaddress command. Congratulations! You just transfered your mined coins to a more secure place!

Keep away your pesky sister


So now that we have got everything running and going, you might want to enable a lock screen so nobody can actually touch your computer. By default the live Ubuntu doesn't allow locking the computer, but we have a little trick for that. Open a new terminal (ctrl+alt+t) and input this command:

gsettings set org.gnome.desktop.lockdown disable-lock-screen 'false'

next we will use command passwd to set a password for the current user. It will prompt for the current password, that is empty. So you can hit enter and continue filling in your new password. After this is done you can lock your screen! (windows button+ l). Just log back in and you see your miner at work!

Automating the payout process

Thanks to ryango at the LBRY slack, we can also make the payout process automatic! He has written a little script that you can use with cron! (Cron is an service or daemon to execute commands or scripts at a given time and date).
#!/bin/bash
###Save this file as cashout.sh in the same dir as lbrycrd-cli and make it executable with 'chmod u+x cashout.sh'###
# Change YOURLBCADDRESSGOESHERE to your receiving LBC address
#get the balance of the wallet (won't include immature coins)
BAL="$(./lbrycrd-cli getbalance)"
#subtract .0002 to save some for tx fees
SENDBAL=$(bc <<< "${BAL}-0.0002")
#send the calculated amount to your address

./lbrycrd-cli sendtoaddress YOURLBRYADDRESSGOESHERE $SENDBAL

So after you have saved this file to cashout.sh we want to make this execute every 4 hours, we need to make a cron entry! So in the terminal do sudo nano /etc/crontab and add the following line to the end of the file:

* 4 * * * ubuntu /home/ubuntu/cashout.sh

Now restart the service with service cron restart. It should now send cash to the address in the cashout.sh file every 4 hours (if of course you have successfully mined coins). If this for some reason does not execute every 4 hours you can execute the file yourself by typing ./cashout.sh in the terminal.

Also if you are reading this in the future make sure to edit the cashout.sh file to accumulate for enough fees. Currently it subtracts .0002 for fees, but this could get higher in the future, so make sure you accomodate the appropriate fees!

Warning!


You are running a live Ubuntu from a USB stick. Do not remove the USB from the computer at any time for you might lose your coins. Also make sure you frequently transfer your mined coins to a safe place because once you reboot the computer IT WILL BE GONE. There are some wallet backup capabilities, check out https://en.bitcoin.it/wiki/Original_Bitcoin_client/API_calls_list for a full list of commands. Since LBRY wallet is a fork from the bitcoin wallet a lot of these commands will work.

THAT IS IT! Holy smokes we've covered a lot. But now we can finally mine, lay back and enjoy the sun. Happy mining!
 
 
 
Join the LBRY slack at LBRY.slack.com.

If you liked this article and would like to sign up for LBRY, you can use my referral and help me out a bit. http://lbry.io/get/?r=vRrE3

My LBRY donation address: bbAMzSkboLfWnqqrT6BoxVufbJcMjkzENr

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  
  ·  8 years ago Reveal Comment

Nice breakdown, It worth given lbry a chance to succeed

It's running live from your USB stick! That means everything you do here will be erased once you shutdown. So don't make the mistake of rebooting!

Do not remove the USB from the computer at any time for you might lose your coins.

You can make a Live USB with persistence enabled, meaning that any files you save are saved to the USB drive, so you don't lose anything on reboot. I don't know if you can do it from Windows, but the Live USB Creator tool in Ubuntu has a one-click option for persistence:

Awesome tip scrawl! I'll be using this feature very likely!

Thanks for the share. Can you make a tutorial on windows?

Thanks again :)