diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..8f5cdc5 Binary files /dev/null and b/.DS_Store differ diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..3d01139 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2021 Nikolai Nekrutenko + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/ProxMox GPU Passthrough b/ProxMox GPU Passthrough new file mode 100644 index 0000000..8295ca8 --- /dev/null +++ b/ProxMox GPU Passthrough @@ -0,0 +1,111 @@ +1 Enter BIOS/UEFI menu + +2. Enable the VT-d/AMD-d CPU flags + +Because some menus are different look for something like Enable Virtualization Technology + + + +3. Set boot priority for your UEFI-based Proxmox drive + +You may see Proxmox and (UEFI) Proxmox boot options or something similar + +You may need to disable CSM to ensure the system boots using UEFI + + + +Proxmox SSH/Shell + +4. SSH or Shell into Proxmox then: + +GRUB + +Edit /etc/default/grub and modify the appropriate line: + +Intel: GRUB_CMDLINE_LINUX_DEFAULT=quiet intel_iommu=on iommu=pt vga=off + +AMD: GRUB_CMDLINE_LINUX_DEFAULT=quiet amd_iommu=on iommu=pt vga=off + +Save and close file then run update-grub2 to apply the changes + +ZFS + +Edit /etc/kernel/cmdline and modify the appropriate line: + +Intel: root=ZFS=rpool/ROOT/pve-1 boot=zfs quiet intel_iommu=on iommu=pt + +AMD: root=ZFS=rpool/ROOT/pve-1 boot=zfs quiet amd_iommu=on iommu=pt + +Save and close file then run pve-efiboot-tool refresh to apply the changes + +You may need to put quiet ... iommu=pt on its own line + +Thanks to u/edfreitag for supplying the sourcing! + + + +5. Still in Proxmox SSH/Shell, edit Kernel Modules /etc/modules and add the following lines: + +vfio +vfio_iommu_type1 +vfio_pci +vfio_virqfd +6. Save and close modules file then run update-initramfs to add the kernel modules + +7. Reboot host machine + + + +Proxmox WebUI + +8. Create a new VM with OVMF BIOS and as a q35 machine. DO NOT SKIP setting processor type! + +# Use whatever other settings you want, but the following are required + +SYSTEM + BIOS: OVMF(UEFI) + Machine: q35 + +PROCESSOR + TYPE: IvyBridge # Your CPU may not be an IvyBridge +https://preview.redd.it/w9ir4kyafif61.png?width=722&format=png&auto=webp&s=202019ae95d2ad10fb081d2a0dc099f69b32dc9a + +9. Add your graphics card as a new PCI device + +10. Set device to use All functions and PCI Express. DO NOT set as primary GPU! + +11. Start VM and install OS + + + +Virtual Machine + +12. Boot OS and install graphics card driver + +13. Open Device Manager and confirm you see both the GPU name and an error 43 on your display driver + +14. Enable RDP (optional as this guide allows you to use both Console and RDP) + +15. Safely reboot then power down VM + + + +Proxmox VM Settings + +16. In Proxmox VM settings: + +Set Display to VirtIO-GPU (virtio) + +Set PCI Device as Primary GPU + + + +Endgame + +17. Start VM and confirm error 43 is gone + +18. Start gaming! + + + +Cheers! diff --git a/README.md b/README.md index 45e77c9..a51ca43 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,86 @@ -# minerwrangler +![logo](/resources/minerwrangler.png) -A bundle of bash scripts to make headless crypto mining on linux a simple reality. Unfortunately only NVIDIA support for now. \ No newline at end of file +

+ Get it? It's headless! +

+ +

+ A headless driver installer & crypto miner configurator +

+ +

+ Installation & Tutorial +

+ +

+ MinerWrangler is the ultimate bundle of bash scripts to ease your way into cryptocurrency mining that is open-source and gives you full control over your rigs—by default. No monitor, keyboard, or mouse required. Only NVIDIA support for now. +

+ +

+ + MIT license + + GPU Support +

+ + + +## The ultimate one-liner + +``` +git clone https://github.com/NikolaiTeslovich/minerwrangler.git && cd minerwrangler && chmod +x install1.sh && sudo ./install1.sh +``` + +## Features + +- [x] Simple and intuitive to use +- [x] One line to install +- [x] Full control over your rig(s) +- [x] Truly headless +- [x] Integrated with 💊 [OhGodAnETHlargementPill](https://github.com/admin-ipfs/OhGodAnETHlargementPill) (GTX 1080, GTX 1080Ti & TITAN Xp—GDDR5X GPUs) +> "ED (Ethereum Dysfunction) affects 1 in 10 NVIDIA GPUs in North America" + +- [x] Support for the latest & greatest version of Ubuntu Server LTS +- [x] Firewall is enabled by default +- [x] Command-line interface + +## Tested on + +* **GPUs** + * GTX 1080 + * RTX 2080 +* **Driver version** + * nvidia-driver-440 + * nvidia-driver-460 (default) + +## To do + +* Run the installation in a screen session for more bullet-proofness +* Add option to automatically mine on boot +* Script to more easily configure overclocks and fan speeds +* RVN mining support +* Break down existing code in detail +* XMRig support +* AMD GPU support +* Support other miners and algorithms + +## Preface + +NVIDIA drivers on Linux are rather finicky and do not like being overclocked without a monitor connected to them, so I had to trick them using a combination of **lightdm** and some other commands. + +After countless hours, probably even days of banging my head against the monitor in despair to have my rigs work headlessly, and be **actually be overclockable**, I wanted to find a way that was simple, yet have the code and process be open-source. In contrast to operating systems like HiveOS, or NHOS, using *MinerWrangler* in conjunction with Ubuntu Server, you can actually understand each step of the process and have full control over your rigs as providers of the blockchain. + +## Credits + +### Threads and forums that helped massively + +* [OC Nvidia GTX1070s in Ubuntu 16.04LTS for Ethereum mining](https://gist.github.com/bsodmike/369f8a202c5a5c97cfbd481264d549e9) - tricking NVIDIA drivers into allowing headless overclocking +* [How to create a bootable USB stick to flash a BIOS](https://askubuntu.com/questions/46886/how-to-create-a-bootable-usb-stick-to-flash-a-bios) - updating BIOS on an old computer + +### Logo + +* [Western retro font](https://www.dafont.com/western-retro.font) +* [Cowboy hat](https://www.pngitem.com/middle/hTiibR_guitar-clipart-cowboy-hat-cartoon-transparent-cowboy-hat/) +* [Cactus](http://clipart-library.com/clipart/cactus-clipart-34.htm) +* [Headless person from Dumb Ways To Die](https://dumbways2die.fandom.com/wiki/Hapless) +* [Ethereum logo](https://en.wikipedia.org/wiki/Ethereum#/media/File:Ethereum-icon-purple.svg) diff --git a/clockfan.sh b/clockfan.sh new file mode 100644 index 0000000..423aa74 --- /dev/null +++ b/clockfan.sh @@ -0,0 +1,42 @@ +#!/bin/bash + +# created by Nikolai + +# Enable persistence mode on all GPUs +nvidia-smi -pm ENABLED + +# Set power limits in Watts +# ------------------------- +# GPU 0 - set the power limit to 155 Watts +nvidia-smi -i 0 -pl 155 +# GPU 1 - set the power limit to 145 Watts +nvidia-smi -i 1 -pl 145 + +# Configure gpu fan speed by setting GPUFanControlState=1 and modifying the GPUTargetFanSpeed=fanspeed% +# ----------------------------------------------------------------------------------------------------- +# GPU 0 - enable fan speed control and set the target fan speed to 55% +DISPLAY=:0 XAUTHORITY=/var/run/lightdm/root/:0 sudo nvidia-settings \ +-a '[gpu:0]/GPUFanControlState=1' -a '[fan:0]/GPUTargetFanSpeed=55' +# GPU 1 - enable fan speed control and set the target fan speed to 75% +DISPLAY=:0 XAUTHORITY=/var/run/lightdm/root/:0 sudo nvidia-settings \ +-a '[gpu:1]/GPUFanControlState=1' -a '[fan:1]/GPUTargetFanSpeed=75' + +# Configure GPU memory speeds (VRAM) with GPUMemoryTransferRateOffset[performancestate]=Mhz_offset +# Notice how performancestates 2, 3 & 4 are used +# ---------------------------------------------- +# GPU 0 - Increase the memory speed by 1000 Mhz (500Mhz) +DISPLAY=:0 XAUTHORITY=/var/run/lightdm/root/:0 sudo nvidia-settings \ +-a '[gpu:0]/GPUMemoryTransferRateOffset[2]=1000' -a '[gpu:0]/GPUMemoryTransferRateOffset[3]=1000' -a '[gpu:0]/GPUMemoryTransferRateOffset[4]=1000' +# GPU 1 - Increase the memory speed by 1000 Mhz (500Mhz) +DISPLAY=:0 XAUTHORITY=/var/run/lightdm/root/:0 sudo nvidia-settings \ +-a '[gpu:1]/GPUMemoryTransferRateOffset[2]=1000' -a '[gpu:1]/GPUMemoryTransferRateOffset[3]=1000' -a '[gpu:1]/GPUMemoryTransferRateOffset[4]=1000' + +# Configure GPU core clock speed with GPUGraphicsClockOffset[performancestate]=Mhz_offset +# Once again, notice how performancestates 2, 3 & 4 are used +# ---------------------------------------------------------- +# GPU 0 - Increase the memory speed by 150 Mhz +DISPLAY=:0 XAUTHORITY=/var/run/lightdm/root/:0 sudo nvidia-settings \ +-a '[gpu:0]/GPUGraphicsClockOffset[2]=150' -a '[gpu:0]/GPUGraphicsClockOffset[3]=150' -a '[gpu:0]/GPUGraphicsClockOffset[4]=150' +# GPU 1 - Increase the memory speed by 150 Mhz +DISPLAY=:0 XAUTHORITY=/var/run/lightdm/root/:0 sudo nvidia-settings \ +-a '[gpu:1]/GPUGraphicsClockOffset[2]=150' -a '[gpu:1]/GPUGraphicsClockOffset[3]=150' -a '[gpu:1]/GPUGraphicsClockOffset[4]=150' diff --git a/config.sh b/config.sh new file mode 100644 index 0000000..75b14ba --- /dev/null +++ b/config.sh @@ -0,0 +1,72 @@ +#!/bin/bash + +# created by Nikolai + +# Ubuntu server 20.04.2 LTS + +#define colors for colored text +red=`tput setaf 1` +green=`tput setaf 2` +reset=`tput sgr0` + +confirm_install() { + local REPLY + while true; do + read -r -n 1 -p "${1:-Continue?} [y/n]: " REPLY + case $REPLY in + [yY]) + echo + ((var*=2)) + return 0 ;; + [nN]) + echo + ((var-=1)) + return 1 ;; + *) + echo " ${red}invalid input${reset}" + esac + done +} + +# SETTING UP THE PHOENIXMINER CONFIG +# Multiple-choice type of deal for finding the closest server +echo "Which region is closest to you" + +select region in US_East US_West Asia Europe + +do + case $region in + US_East|US_West|Asia|Europe) + break + ;; + *) + echo "Invalid selection" + ;; + esac +done +confirm_install "This region is closest to you? $region" || exit 0 + +# modify the eth.sh file for the server locations +if [[ $region =~ "US_West" ]]; then + sed -i "s/us1/us2/g" eth.sh +elif [[ $region =~ "Asia" ]]; then + sed -i "s/us1/asia1/g" eth.sh +elif [[ $region =~ "Europe" ]]; then + sed -i "s/us1/eu1/g" eth.sh +fi + +# update the eth.sh file with your ETH address +read -p 'Enter ETH wallet address: ' wallet +confirm_install "Double-check that this is your address? $wallet" || exit 0 +sed -i "s/ETHwalletaddr/$wallet/g" eth.sh + +# update the eth.sh file with your rig name +read -p 'Fancy rig name (only standard characters): ' rig +confirm_install "Is this the name you wanted? $rig" || exit 0 +sed -i "s/rigname/$rig/g" eth.sh + +echo "miner config complete" + +# STARTED WORKING ON OC SETTINGS AND SETUP +# variable that gets the number of graphics cards +# numgpus=$(nvidia-smi --query-gpu=name --format=csv,noheader | wc -l) diff --git a/eth.sh b/eth.sh new file mode 100644 index 0000000..c7e1964 --- /dev/null +++ b/eth.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +# created by Nikolai + +cd PhoenixMiner + +./PhoenixMiner -pool stratum+tcp://us1.ethermine.org:4444 -pool2 stratum+tcp://us1.ethermine.org:14444 -wal ETHwalletaddr.rigname diff --git a/install1.sh b/install1.sh new file mode 100644 index 0000000..985fa2b --- /dev/null +++ b/install1.sh @@ -0,0 +1,149 @@ +#!/bin/bash + +# created by Nikolai + +# Ubuntu server 20.04.2 LTS + +# DEFINING ALL THE VARIABLES + +#define colors for colored text +red=`tput setaf 1` +green=`tput setaf 2` +reset=`tput sgr0` + +#define the installation variable, and set it to one +var=1 + +# define variables for the manufacturer and model of the GPU(s), and hide the command line output +{ + vendor=$(lshw -class display | grep 'vendor' | uniq) + model=$(lshw -class display | grep 'product') +} &> /dev/null + +# DEFINING THE INSTALLATION FUNCTIONS +# define the confirm install function +confirm_install() { + local REPLY + while true; do + read -r -n 1 -p "${1:-Continue?} [y/n]: " REPLY + case $REPLY in + [yY]) + echo + ((var*=2)) + return 0 ;; + [nN]) + echo + ((var-=1)) + return 1 ;; + *) + echo " ${red}invalid input${reset}" + esac + done +} + +# define Nvidia installation +nvidia_install() { + # add the nvidia drivers ppa + add-apt-repository ppa:graphics-drivers/ppa -y + apt upgrade -y + # install all the necessary libraries, will ask config during install + latestnv=$(apt search nvidia-driver-[0-999] | grep -v "Transitional\|Übergangspaket" | grep "nvidia-driver-[400-999]" | sort -nr | head -n 1 | sed 's/\/.*//g') + apt install $latestnv nvidia-cuda-toolkit -y +} + +IFS=$'\n' +question="Choose your preferred miner Software: " +entrys=("T-Rex Miner" "Phoenix Miner" "Nanominer") + +PS3="$question " +select entry in "${entrys[@]}" "Abort"; do + +miner_install() { + if ((REPLY == 1 + ${#entrys[@]})); then + exit + break + + elif ((REPLY > 0 && REPLY <= ${#entrys[@]})); then + if [ "$entry" == "T-Rex Miner" ]; then + latest=$(curl -s https://github.com/trexminer/T-Rex/releases/latest | sed 's/.*href="\|">.*//g') + filename=$(curl -s "$latest" | grep -i "linux" | grep -i "text" | sed 's/.*">\|<\/.*//g') + wget "$(echo "$latest" | sed 's/tag/download/g')/$filename" + mkdir T-Rex && tar -zxvf $filename -C T-Rex + elif [ "$entry" == "Phoenix Miner" ]; then + dllink=$(curl -s https://phoenixminer.org/download/latest/ | grep "Linux" | grep "cutt" | sed 's/.*href="\|"\ rel.*//g' | head -n 1) + wget -r -p -k "$dllink" + cd cutt.ly/ + mv * phoenixminer.zip + unzip phoenixminer.zip + elif [ "$entry" == "Nanominer" ]; then + latest=$(curl -s https://github.com/nanopool/nanominer/releases/latest | sed 's/.*href="\|">.*//g') + filename=$(curl -s "$latest" | grep 'linux-[0-9].[0-9].[0-99]-cuda' | grep -i "text" | sed 's/.*">\|<\/.*//g') + wget "$(echo "$latest" | sed 's/tag/download/g')/$filename" + tar -xvf "$filename" + mv nanominer*/ nanominer + fi + fi + break +done +} + +# ETHlargementPill installation for GTX 1080, 1080TI and Titan XP +pill_install() { + # Download + wget https://github.com/admin-ipfs/OhGodAnETHlargementPill/raw/master/OhGodAnETHlargementPill-r2 + # Make the file executable, and rename it + chmod +x OhGodAnETHlargementPill-r2 + mv OhGodAnETHlargementPill-r2 ETHPill +} + +# THE CONDITIONAL INSTALLATON CODE +clear +if [[ $vendor =~ "NVIDIA" ]]; then + echo -e "${green}NVIDIA GPUs detected${reset}" "\U2714" +elif [[ $vendor =~ "AMD" ]]; then + echo "${red}AMD GPUs are not yet supported${reset}" + echo "exiting in 5 seconds" + sleep 5 + exit 0 +else + echo "${red}No GPUs detected${reset}" + echo "exiting in 5 seconds" + sleep 5 + exit 0 +fi +echo "$model" + +# setup questions +confirm_install "Is this the correct hardware?" || exit 0 +clear +printf "\U1F48A" && confirm_install "The pill? (GTX 1080, 1080Ti & Titan XP)" +clear + +# update and upgrade packages to the latest version +apt update && apt upgrade -y +# just such a useful tool, should be installed regardless of option +apt install screen -y +# allow ssh through firewall, and enable firewall for security purposes +ufw allow ssh +yes | ufw enable + +# installation +if [[ $vendor =~ "NVIDIA" ]]; then + nvidia_install + miner_install + if [[ $var = 4 ]]; then + pill_install + fi +else + exit 0 +fi + +# REBOOT SYSTEM AND GET READY TO MINE +# make the next install script executable, while removing permissions for the current one +chmod 0 install1.sh +chmod +x install2.sh +clear +# display a message, then reboot +echo "${red}Rebooting ...${reset}" +sleep 2 +reboot diff --git a/install2.sh b/install2.sh new file mode 100644 index 0000000..35496aa --- /dev/null +++ b/install2.sh @@ -0,0 +1,28 @@ +#!/bin/bash + +# created by Nikolai + +# Ubuntu server 20.04.2 LTS + +#define colors for colored text +red=`tput setaf 1` +green=`tput setaf 2` +reset=`tput sgr0` + +# install packages and run the nvidia-xconfig to make the system truly headless +apt upgrade -y +apt install --no-install-recommends xorg lightdm lightdm-gtk-greeter -y +nvidia-xconfig --enable-all-gpus --allow-empty-initial-configuration --cool-bits=28 --connected-monitor="DFP-0" +# setup the xorg config, notice how the "\ \ \ \" is used as indents +sed -i '/Option "ConnectedMonitor" "DFP-0"/a\ \ \ \ Option \ \ \ \ \ \ \ \ "Interactive" "False"' /etc/X11/xorg.conf + +# make the other scripts executable, while removing permissions for the current one +chmod 0 install2.sh +chmod +x mine.sh eth.sh clockfan.sh config.sh +# display some beautiful messages +echo -e "\U26CF" "${green}Happy Mining${reset} & ${red}Heating${reset}" "\U26CF" +sleep 3 +clear +echo "${red}Rebooting for the last time...${reset}" +sleep 2 +reboot diff --git a/mine.sh b/mine.sh new file mode 100644 index 0000000..b9486b3 --- /dev/null +++ b/mine.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +# created by Nikolai + +# check if the eth script exists, then start mining +test -f eth.sh && screen -S eth -d -m ./eth.sh || echo "no ETH script found" + +# check if the pill exists, then start mining +test -f ETHPill && screen -S pill -d -m sudo ./ETHPill || echo -e "no" "\U1F48A" "found" + +# list all the screens +screen -list + +echo "mining started, feel free to exit ssh" diff --git a/resources/minerwrangler.png b/resources/minerwrangler.png new file mode 100644 index 0000000..b1c669f Binary files /dev/null and b/resources/minerwrangler.png differ