Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: geek-trader on July 24, 2011, 03:02:43 AM



Title: Self contained, cross platform USB stick client & wallet
Post by: geek-trader on July 24, 2011, 03:02:43 AM
Hello.

Today I was playing around trying to make a self-contained USB Bitcoin client.  The bitcoin executable, wallet.dat & blockchain would all live on the USB stick.

I'm on a Mac at home.  I have it working on the mac.  I use a shell script to launch the OSX bitcoin client with the -datadir parameter, to the datadir on the USB stick using a relative path.

USB dir structure:

root
  * bin
      -> Bitcoin_osx.app
  * data
      -> all the bitcoin data files and wallet.dat
-> Run_Bitcoin_OSX.command

The "Run_Bitcoin_OSX.command" is:

Code:
#!/bin/sh
echo $0;
DIR=`dirname "$0"`
echo $DIR
cd "$DIR"
exec bin/Bitcoin_osx.app/Contents/MacOS/bitcoin -datadir=./data

I need to try this approach for Linux (should work) and Windows (I have no idea)

Next steps:

* On Monday, at work, on my Linux desktop, I'll get Linux working
* Somehow get access to a Windows desktop (I guess I have friends with Windows at home) and try that
* Once it's all working cross platform, try some cross platform encryption.

Suggestions / Ideas / I'm totaly wrong?
 


Title: Re: Self contained, cross platform USB stick client & wallet
Post by: ottoxgam on July 28, 2011, 05:28:18 AM
This sounds like something that I would use. Any updates?


Title: Re: Self contained, cross platform USB stick client & wallet
Post by: jamesg on July 28, 2011, 11:10:27 AM
I would also like to know if this is something that is cross platform. Please update.


Title: Re: Self contained, cross platform USB stick client & wallet
Post by: marcus_of_augustus on July 31, 2011, 10:32:55 PM

bitcoin does a lot of disk activity so hardware is a consideration. If you run this 24/7 you may expect USB drive failures (got back-up?), I corrupted a USB running bitcoin like this.

What is a perhaps a better method, not quite as secure but just about, is to move the whole -datadir into a RAM disk (/dev/shm/ on ubuntu/debian), although it is quite large but still doable at around 700-800Mb.

0. Mount USB with bitcoin client and datadir

(Ubuntu/Debian)
1. Check available space on RAM disk
Code:
$ df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda1              53G  8.9G   42G  18% /
none                  743M  668K  742M   1% /dev
none                  749M  1.5M  748M   1% /dev/shm
none                  749M   96K  749M   1% /var/run
none                  749M     0  749M   0% /var/lock

/dev/shm needs to be bigger than 750M. Make sure you aren't running some other RAM hogging code that could cause issues (i.e. don't run any other programs unless you know what you are doing.)

2. Copy .bitcoin folder onto RAM disk
Code:
$cp -R /media/MyUSBDrive/.bitcoin /dev/shm/.bitcoin

3. Run bitcoin
Code:
bitcoin -datadir=/dev/shm/.bitcoin

When you are done copy the whole thing back from RAM onto USB (first $srm the existing wallet.dat on USB if one exists, make sure you have another copy of wallet.dat elsewhere because at this point you will only have one copy and it is in RAM, be careful) and then reboot.

4. Secure remove previous wallet
Code:
$srm /media/MyUSBDrive/.bitcoin/wallet.dat

5. Remove existing datadir on USB drive
Code:
$rm -rf /media/MyUSBDrive/.bitcoin

6. Copy everything back from RAM onto USB drive (could also do an update and skip step 5 above)
Code:
$cp -R /dev/shm/.bitcoin/ /media/MyUSBDrive/.bitcoin

7. Check wallets are identical (probably should encrypt first anyway but outside of scope here)
Code:
$diff /dev/shm/.bitcoin/wallet.dat /media/MyUSBDrive/.bitcoin/wallet.dat

8. Reboot.


Title: Re: Self contained, cross platform USB stick client & wallet
Post by: geek-trader on August 01, 2011, 01:07:52 AM
My Linux box at work can't run the bitcoin client, the OS is too old.  And I still don't have access to a Windows box.

However, there is this thread: http://forum.bitcoin.org/index.php?topic=4868.msg71216#msg71216  that I found.  He's on windows and using the same approach as me.

So it should work.


Title: Re: Self contained, cross platform USB stick client & wallet
Post by: Smalleyster on August 01, 2011, 01:12:38 AM
LinuxCoin.


Title: Re: Self contained, cross platform USB stick client & wallet
Post by: geek-trader on August 01, 2011, 01:21:33 AM
LinuxCoin.

I do run Linuxcoin from USB for my mining rig. 

But I'd like to run the client in the OS that is already running, not re-boot into linux.  Especially since Macs can't boot a non-Mac OS from USB.  Well, not easily. 

I already have my secure bank on a bootable Ubuntu live CD. With several backups, of course.

I'm still looking into various "more secure" alternatives to running the client directly.  Looking into VirtualBox right now.

Of course, version 0.4 could come out with an encrypted wallet.dat and save the day, but we don't know when that might be.

I don't really have enough BTC to matter, and half of what I DO have is in MtGox, so this is really more for my own curiosity than anything else.