Add configurable pruning
nolim1t opened this issue · comments
nolim1t - f6287b82CC84bcbd commented
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?
nolim1t - f6287b82CC84bcbd commented
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()
nolim1t - f6287b82CC84bcbd commented
Already doing this with a disk partitioning tool in contrib/