Merge remote-tracking branch 'upstream-pull/82/head'

This commit is contained in:
Jonas Nick 2019-07-03 09:46:04 +00:00
commit 3a73e54f0b
No known key found for this signature in database
GPG Key ID: 4861DBF262123605
2 changed files with 90 additions and 1 deletions

81
contrib/vbox-resize-disk1.sh Executable file
View File

@ -0,0 +1,81 @@
#!/usr/bin/env nix-shell
#! nix-shell -i bash -p jq
while getopts ":d:m:s:f:yh" opt; do
case $opt in
d)
DEPLOYMENT="$OPTARG"
;;
m)
MACHINE="$OPTARG"
;;
s)
NEW_SIZE="$OPTARG"
;;
f)
DISK_FILE="$OPTARG"
;;
y)
YES="yes"
;;
h)
echo "Usage: $0 [-d <deployment>] [-m <machine>] [-s <size>] [-f <file>] [-y]"
echo ""
echo "Options:"
echo " -d <deployment> NixOps deployment name. Default: bitcoin-node."
echo " -m <machine> NixOps machine name. Default: bitcoin-node."
echo " -s <size> New disk size in megabytes. Default: 307200 (300gb)."
echo " -f <file> Path to vbox disk file/VDI. Default: read from nixops export."
echo " -y Don't ask for confirmation."
exit 0
;;
\?)
echo "Invalid option: -$OPTARG" >&2
exit 1
;;
:)
echo "Option -$OPTARG requires an argument." >&2
exit 1
;;
esac
done
DEPLOYMENT=${DEPLOYMENT:-"bitcoin-node"}
MACHINE=${MACHINE:-"bitcoin-node"}
NEW_SIZE=${NEW_SIZE:-307200}
DISK_FILE=${DISK_FILE:-$(nixops export -d $DEPLOYMENT | jq -r '..|."virtualbox.disks"?|select(.!=null)' | jq -r .disk1.path)}
echo "Resizing virtualbox disk for use with nixops and nix-bitcoin."
echo "Using deployment: $DEPLOYMENT"
echo "Using machine: $MACHINE"
echo "Using size: $NEW_SIZE"
echo "Using disk file: $DISK_FILE"
if [ "$YES" != "yes" ]; then
read -p "Continue? [Y/n] " -n 1 -r
echo
if [[ ! "$REPLY" =~ ^[Yy]$ ]]; then
exit 1
fi
fi
set -ex
nixops stop -d $DEPLOYMENT
VBoxManage modifyhd --resize $NEW_SIZE "$DISK_FILE"
nixops start -d $DEPLOYMENT
# (
# echo d # [d]elete 50gb partition
# echo n # [n]ew partitoin
# echo p # [p]rimary partition
# echo # partition number (Accept default: 1)
# echo # first sector (Accept default: 1)
# echo # last sector (Accept default: determined by $NEW_SIZE)
# echo w # [w]rite changes
# ) | fdisk
nixops ssh -d $DEPLOYMENT $MACHINE -- '(echo d; echo n; echo p; echo; echo; echo; echo w; ) | fdisk /dev/sda'
nixops reboot -d $DEPLOYMENT
nixops ssh -d $DEPLOYMENT $MACHINE -- resize2fs /dev/sda1
nixops ssh -d $DEPLOYMENT $MACHINE -- df -h

View File

@ -115,7 +115,15 @@ You can also build Nix from source by following the instructions at https://nixo
This will now create a nix-bitcoin node on the target machine. This will now create a nix-bitcoin node on the target machine.
6. Nixops automatically creates an ssh key for use with `nixops ssh`. Access `bitcoin-node` through ssh in nix-shell with 6. Resize the virtualbox disk
```
./contrib/vbox-resize-disk1.sh
```
NixOps provides a virtualbox disk thats 50gb in size, but we need more than that to house the Bitcoin blockchain. By default, his script will resize the disk to 300gb. Run it with `-h` to see options. Make sure to run this from within your nix-shell.
7. Nixops automatically creates an ssh key for use with `nixops ssh`. Access `bitcoin-node` through ssh in nix-shell with
``` ```
nixops ssh operator@bitcoin-node nixops ssh operator@bitcoin-node