lncm / thebox-compose-system

docker-compose framework and installation scripts for creating bitcoin boxes

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add configurable pruning

nolim1t opened this issue · comments

Situation

I want to be able to support many devices/installations (*NIX based for now, Macs can run linux easily). Particularly pis.

Not all pis are equal and have different drive size

Solution

  • Detect the disks available
  • Partition Accordingly
  • Configure bitcoin.conf prune settings (defaults to 550) with what is appropriate. I think for every gigabyte add another 1000 to the prune, up to about 500 GB, then configure as a full archival node.
  • Integrate with noma?

Some codes

#!/usr/bin/env python3

import os
import sys
import glob
import re

usb_dev_pattern = ['sd.*']
usb_part_pattern = ['sd.[1-9]*']
sd_dev_pattern = ['mmcblk*']
sd_part_pattern = ['mmcblk.p[1-9]*']

def dev_size(device):
    path = '/sys/block/'
    num_sectors = open(path + device + '/size').read().rstrip('\n')
    sector_size = open(path + device + '/queue/hw_sector_size').read().rstrip('\n')
    return (int(num_sectors)*int(sector_size))

# Return number of devices
def usb_devs():
    devices = []
    for device in glob.glob('/sys/block/*'):
        for pattern in usb_dev_pattern:
            if re.compile(pattern).match(os.path.basename(device)):
                devices.append(os.path.basename(device))
    return devices

def main():
    if len(usb_devs()) == 0:
        print("No USB devices connected")
    else:
        print(usb_devs())

if __name__ == '__main__':
    main()

Already doing this with a disk partitioning tool in contrib/