Ubuntu VM creation for wallet development - Zacorich/omegacoin GitHub Wiki
STEP 1[skip to Step 3] - Install and configure OpenBox + ObConf + Gnome terminal + VirtualBox Guest to get ubuntu_16.04_x64-openbox-v1
-- install xord + openbox - 385MB of aditional space - 5 minutes
sudo apt-get update && sudo apt-get upgrade
sudo apt-get install -y xorg openbox obconf feh lxappearance compton tint2 clipit lxpolkit
-- install gnome terminal & htop - +200MB - 2min
sudo apt-get install -y gnome-terminal htop
ubuntu
nano ~/.xinitrc
#!/bin/bash
exec openbox-session
startx
-- install VirtualBox Guest Additions for Linux 5.2.8 - 30 minutes
sudo apt-get install -y dkms build-essential linux-headers-generic linux-headers-$(uname -r)
sudo apt-get install -y gcc make perl
sudo mount /dev/cdrom /media/cdrom
cd /media/cdrom
sudo su
./VBoxLinuxAdditions.run
reboot
--Reboot your machine, and the Guest Additions will be working. You should see a
--bit of a performance increase, as well as the extra features (shared clipboard,
--shared folders, and more) awarded by this installation.
-- set gnome-terminal / Edit / Preferences / Shortcuts / Copy (Ctrl+C), Paste(Ctrl+V)
-- set host VirtualBox / Devices / Shared Clipboard / Bidirectional
-- test how copy-paste seamlessly works
--finish openbox installation
mkdir ~/.config
mkdir ~/.config/openbox
cp /etc/xdg/openbox/autostart.sh ~/.config/openbox/
cp /etc/xdg/openbox/menu.xml ~/.config/openbox/
cp /etc/xdg/openbox/rc.xml ~/.config/openbox/
nano ~/.config/openbox/autostart
lxpolkit &
#clipit & #a tray clipboard manager
compton & #the compositor
tint2 & #the panel
-- make sure when we login with ubuntu user it runs startx once if no display
nano ~/.bashrc
if [[ ! $DISPLAY && $XDG_VTNR -eq 1 ]]; then
exec startx
fi
--install some file manager - 60M
sudo apt-get install -y pcmanfm gparted
--remove some useless packages
sudo apt remove snapd
STEP 2 - Publish snapshot for public use. Create ubuntu_16.04_x64-openbox-v1 from Step 1 VirtualBox snapshot
- Open Oracle VM VirtualBox Manager GUI app
- select the image we worked on and make sure "Current State(changed)" is selected
- Press "Clone" button; give it a name; Clone type: Full Clone ; Snapshots: Current machine state; press "Clone"
- Open CloneVDI and by keeping old UUID and enabling "Compact drive while copying" clone huge source *.vdi after VirtualBox(doens't do compacting) to destination packed *-clone.vdi ; once done switch those places
- Upload C:\Users<Username>\VirtualBox VMs<Created clone> to some public place
Download folder and run ubuntu_16.04_x64-openbox-v1.vbox file : ubuntu_16.04_x64-openbox-v1
Sudo username: ubuntu Sudo password: ubuntu Root password: ubuntu
STEP 4[skip to Step 5] - Install omegacoin dependencies using ubuntu_16.04_x64-openbox-v1 image as a base
-
[OPTIONAL]set host VirtualBox \ Devices \ Shared Folders \ Shared Folders Settings \ Add Share - Folder path: E:\ ; Auto-mount; Make Permanent ; Do this on both virtual machines and reboot them; to copy omegacoin precompiled project to save time run #sudo cp -R ~/CLionProjects/omegacoin/ /media/sf_E_DRIVE/omegacoin on vm containing it and run #mkdir -p ~/CLionProjects/omegacoin/ #sudo cp -R /media/sf_E_DRIVE/omegacoin ~/omegacoin/ ; sudo chown -R ubuntu:ubuntu ~/omegacoin/ ; chmod 777 -R ~/omegacoin/
-
Give 2 Cores and 3GB of RAM to vm with VirtualBox
-
Install following dependencies for Ubuntu 16.04x64
#!/bin/sh
sudo add-apt-repository ppa:bitcoin/bitcoin
sudo apt-get update
sudo apt-get install -y libdb4.8-dev libdb4.8++-dev
sudo apt-get install -y git autoconf build-essential libtool autotools-dev automake pkg-config libssl-dev libevent-dev bsdmainutils
sudo apt-get install -y libboost-all-dev
sudo apt-get install -y libqt5gui5 libqt5core5a libqt5dbus5 qttools5-dev qttools5-dev-tools libprotobuf-dev protobuf-compiler
STEP 5[skip to Step 6] - Compile latest wallet linux version using ubuntu_16.04_x64-omega-deps as a base image [Official compilation instruction for Ubuntu 16.04x64 quick compilation]
-
Download image with pre-installed dependencies and run ubuntu_16.04_x64-omega-deps.vbox : link ;
-
Login as ubuntu user and open terminal from openbox toolbar Sudo username: ubuntu Sudo password: ubuntu Root password: ubuntu
-
Clone(1 minute) and compile(1 hour on 2 core 3 GB RAM) latest version of the wallet
-- image already contain some previous release version of the code with omegacoin official master branch remote configured
cd ~ ; rm -Rf ~/omegacoin
git clone https://github.com/omegacoinnetwork/omegacoin.git
cd ~/omegacoin
-- list available tag names and find the latest release tag name in https://github.com/omegacoinnetwork/omegacoin/releases
git tag -l
-- checkout by tag name. example for 0.12.5.1 version: git checkout tags/0.12.5.1
git checkout tags/<tag name>
-- autogen(30 sec), configure(1 min), make(42m53s), install(30 sec) and make binary light
./autogen.sh
./configure
make
sudo make install
sudo strip /usr/local/bin/omegacoind
-- feel free to use /usr/local/bin/omegacoind on x64 linux systems
- install clion
cd ~
sudo apt-get install -y wget
wget https://download.jetbrains.com/cpp/CLion-2018.2-RC3.tar.gz
tar -xzf CLion-2018.2-RC3.tar.gz
--http://tipsonubuntu.com/2016/07/31/install-oracle-java-8-9-ubuntu-16-04-linux-mint-18/
sudo add-apt-repository ppa:webupd8team/java
sudo apt update; sudo apt install -y oracle-java8-installer
--start your 30 day clion trial
~/clion-2018.2/bin/clion.sh
nano ~/.local/share/applications/clion.desktop
[Desktop Entry]
Exec=/home/ubuntu/clion-2018.2/bin/clion.sh
Name=Clion 2018.2
GenericName=Clion 2018.2
Comment=Clion 2018.2
Icon=clion.png
Encoding=UTF-8
Terminal=true
Type=Application
Categories=Application;Network;
-- make sure clion.desktop is executable
chmod +x ~/.local/share/applications/clion.desktop
-- copy clion icon to ~/.icons
mkdir ~/.icons/
cp /home/ubuntu/clion-2018.2/bin/clion.png ~/.icons/clion.png
--in tint2 / Properties / Launcher and clion to toolbar
--configure empty trash command on tint2
sudo apt-get remove -y gvfs-bin
sudo apt-get install -y trash-cli
trash-empty
nano ~/.local/share/applications/empty-trash.desktop
[Desktop Entry]
Exec=trash-empty
Name=Empty Trash
GenericName=Empty Trash
Comment=Empty Trash
Encoding=UTF-8
Terminal=true
Type=Application
Categories=Application;Network;
-- make sure it is executable
chmod +x ~/.local/share/applications/empty-trash.desktop
-- in PCManFM create bookmark for Trash folder. To delete without trash use shift+delete
/home/ubuntu/.local/share/Trash/files
- open terminal and build omega wallet for the first time from official branch
cd ~ ; rm -Rf ~/omegacoin
git clone https://github.com/omegacoinnetwork/omegacoin.git
cd ~/omegacoin
-- list available tag names and find the latest release tag name in https://github.com/omegacoinnetwork/omegacoin/releases
git tag -l
-- checkout by tag name. example for 0.12.5.1 version: git checkout tags/0.12.5.1
git checkout tags/<tag name>
-- autogen(30 sec), configure(1 min), make(42m53s), install(30 sec) and make binary light
./autogen.sh
./configure
make
sudo make install
sudo strip /usr/local/bin/omegacoind
- start 30 day clion trial: ~/clion-2018.2/bin/clion.sh and create omegacoin project from source. Open clion terminal and run
--compile code after change
time make
--optional install
sudo make install
sudo strip /usr/local/bin/omegacoind
-
Create omegacoind, omegacointx, omegacoin-cli, omegacoin-qt configurations in clion read how to generate CMakeLists.txt file
- File / Import Project...
- Select directory to import: /home/ubuntu/omegacoin
- Import CMake project: press ok and open new project in This Window
- Make sure omegacoin target appeared in configurations to select and add one by one following executables with omegacoin target selected : src/omegacoind , src/omegacoin-tx, src/omegacoin-cli, src/qt/omegacoin-qt
- Remove build before launch in every configuration as we use #make to build project currently not cmake
-
Start omegacoin-qt configuration in debug mode and select configuration folder to be /home/ubuntu/omegacoin/.omegacoincore/ and sync with mainnet (+500MB)
-
Install log viewer and open logs in gnome terminal
sudo apt-get install -y lnav
-- create log shortcut to start quickly
nano ~/.local/share/applications/omega-logs.desktop
[Desktop Entry]
Exec=gnome-terminal -x bash -c "lnav -t /home/ubuntu/omegacoin/.omegacoincore/debug.log"
Name=Omega logs
GenericName=Omega logs
Comment=Omega logs
Encoding=UTF-8
Terminal=true
Type=Application
Categories=Application;Network;
-- make sure clion.desktop is executable
chmod +x ~/.local/share/applications/omega-logs.desktop
-- use i key from your keyboard to switch lnav output to histogram view
-- use p key to view the log parser result
-- use m key to mark the top log line
-- use e / shift+e to navigate around errors only
- Install wireshark to analyse network in detail
sudo apt-get install libcap2-bin wireshark
sudo dpkg-reconfigure wireshark-common
-- be default only root can sniff packets we need to allow non-superuser to do that as well
-- ubuntu is a username here
sudo chgrp ubuntu /usr/bin/dumpcap
sudo chmod 750 /usr/bin/dumpcap
sudo setcap cap_net_raw,cap_net_admin+eip /usr/bin/dumpcap
-- add wireshart to tint2 toolbar and start it from there
-- here is a good article on how to analyse bandwidth
-- http://blog.davidvassallo.me/2010/03/22/measuring-bandwidth-using-wireshark/
-
close clion and then in terminal run(to enable clion licensing window for someone who will use this image): rm -Rf /home/ubuntu/.CLion2018.2/config/eval/ ; check for licensing window to appear by running clion again
-
[Can skip if ubuntu was installed without encryption feature]Stop user folder encryption that is an option you can enable during ubuntu install - solution
--remove swap partition
swapoff -a
sudo gparted
-- delete swap partition and reboot ; then wait for some mystical encryption during boot
-- after reboot run gparted again and increase partition size to take all 10 GB disk - no restart needed for that
-- remove clion installation folder without settings
rm -Rf ~/clion-2018.2/
-- make sure /home/ubuntu folder is smaller than free space available on the disk(2.7G < 3.3G)
-- https://askubuntu.com/questions/4950/how-to-stop-using-built-in-home-directory-encryption
sudo cp -rp /home/ubuntu /home/ubuntu.backup
-- logout and login as root
--make sure /home/ubuntu is not mounted following command must return nothing
mount | grep ecryptfs
--remove ecryptfs crap from backup
sudo rm -Rf /home/ubuntu.backup/.ecryptfs /home/ubuntu.backup/.Private
--move encrypted folder to new place to trick ecryptfs
move /home/ubuntu /home/ubuntu-old
--move backup back to user
mv /home/ubuntu.backup /home/ubuntu
--Login as ubuntu user and check that everything works and eCryptfs does not kick in.
mount | grep ecryptfs
--Remove the original contents of user’s home folder and the encrypted data.
sudo rm -rf /home/ubuntu-old
sudo rm -rf /home/.ecryptfs/ubuntu
--reboot for eCryptfs to free up resources
--can also remove the eCryptfs service completely
sudo apt-get remove -y ecryptfs-utils libecryptfs0
--edit fstab crypttab and remove swap partition from the lists
sudo nano /etc/fstab
sudo nano /etc/crypttab
cryptsetup remove cryptswap1
-- reboot to experience faster boot without cryptswap to kick in
-- reinstall clion just and make sure clion fsnotify works correctly
cd ~
wget https://download.jetbrains.com/cpp/CLion-2018.2-RC3.tar.gz
tar -xzf CLion-2018.2-RC3.tar.gz
--increase fs.inotify.max_user_watches so clion can feel better
sudo nano /etc/sysctl.conf
--add line: fs.inotify.max_user_watches=524288
sudo sysctl -w fs.inotify.max_user_watches=524288
reboot
sudo sysctl -a | grep fs.inotify.max_user_watches
- remove any useless files before publishing final image
sudo apt install -y gparted
sudo gparted
-- increase partition size with ui
-- install disk space usage visual tool
sudo add-apt-repository ppa:nathan-renniewaldock/qdirstat
sudo apt-get update
sudo apt install qdirstat
sudo qdirstat
-- delete /var/cache/oracle-jdk8-installer/jdk-8u181-linux-x64.tar.gz
-- delete omege debug binaries in /usr/local/bin/omega*
sudo rm -f /usr/local/bin/*omega*
-- empty apt cache
sudo apt-get clean
-- empty trash
-- delete any useless files from /home/ubuntu folder(must be not encrypted to analyse it with qdirstat)
-- delete compiled debug binaries of omega
cd /home/ubuntu/omegacoin/
rm -f ./src/omegacoind ./src/omegacoin-tx ./src/omegacoin-cli ./src/qt/omegacoin-qt ./src/test/test_omegacoin ./src/bench/bench_omegacoin
-
Say hello to "Fat Sheep" and create snapshot clone with VirtualBox, pack it with CloneVDI tool, increase disk size to 12GB, !!!Keep old UUID and compact it during cloning. - 6.83 GB (7,344,234,496 bytes) yay!
-
Upload final image into ubuntu-16.04x64-omega-clion
-
If mistakenly generated new UUID in step 11 and uploaded VDI image already. Mistake: uploaded VDI with 5aa73c9b-42d3-4a37-bbe8-e7842e6c00e7 UUID(selected generate new one in CloneVDI), but VirtualBox clone created from snapshot UUID is bd1af39f-5f9c-44f5-a591-a41ee52d6701
"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" showhdinfo "ubuntu-16.04x64-omega-clion.vdi"
REM "C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" internalcommands -?
REM change VDI image UUID to the one uploaded already and correct vbox file to use correct UUID too - 5aa73c9b-42d3-4a37-bbe8-e7842e6c00e7
"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" internalcommands sethduuid "ubuntu-16.04x64-omega-clion.vdi" "5aa73c9b-42d3-4a37-bbe8-e7842e6c00e7"
REM edit vbox file 2 tags value to use correct UUID of VDI image -
REM VirtualBox / Machine / MediaRegistry / HardDisks / HardDisk / uuid="5aa73c9b-42d3-4a37-bbe8-e7842e6c00e7"
REM VirtualBox / Machine / StorageControllers / StorageController name="SATA" / ttachedDevice type="HardDisk" / Image / uuid="5aa73c9b-42d3-4a37-bbe8-e7842e6c00e7"
pause