feat(Infini-SERVER): add data drive setup script
This commit is contained in:
parent
8e70f3e45a
commit
0313a4c4ef
2 changed files with 82 additions and 0 deletions
37
hosts/Infini-SERVER/data_setup.bash
Executable file
37
hosts/Infini-SERVER/data_setup.bash
Executable file
|
@ -0,0 +1,37 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
# [[file:readme.org::data_setup][data_setup]]
|
||||||
|
# [[[[file:/etc/nixos/hosts/Infini-SERVER/readme.org::boilerplate][boilerplate]]][boilerplate]]
|
||||||
|
DISK=$1
|
||||||
|
PARTITION_PREFIX=$2
|
||||||
|
|
||||||
|
sudo mkdir -p /mnt
|
||||||
|
# boilerplate ends here
|
||||||
|
|
||||||
|
# [[[[file:/etc/nixos/hosts/Infini-SERVER/readme.org::mount_check][mount_check]]][mount_check]]
|
||||||
|
if mountpoint -q -- "/mnt"; then
|
||||||
|
echo "ERROR: /mnt is a mounted filesystem, aborting"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
# mount_check ends here
|
||||||
|
|
||||||
|
# [[[[file:/etc/nixos/hosts/Infini-SERVER/readme.org::data_partitioning][data_partitioning]]][data_partitioning]]
|
||||||
|
echo "LOG: Partitioning $DISK for data storage"
|
||||||
|
sudo parted $DISK -- mktable gpt
|
||||||
|
sudo parted $DISK -s -- mkpart primary btrfs 0% 100%
|
||||||
|
# data_partitioning ends here
|
||||||
|
|
||||||
|
# [[[[file:/etc/nixos/hosts/Infini-SERVER/readme.org::data_filesystems][data_filesystems]]][data_filesystems]]
|
||||||
|
echo "LOG: Making data filesystems"
|
||||||
|
echo "- Making btrfa filesystem on ${DISK}${PARTITION_PREFIX}1"
|
||||||
|
sudo mkfs.btrfs "${DISK}${PARTITION_PREFIX}1" --csum xxhash -L "data"
|
||||||
|
# data_filesystems ends here
|
||||||
|
|
||||||
|
# [[[[file:/etc/nixos/hosts/Infini-SERVER/readme.org::data_subvolumes][data_subvolumes]]][data_subvolumes]]
|
||||||
|
echo "LOG: Making data subvolumes on ${DISK}${PARTITION_PREFIX}1"
|
||||||
|
sudo mount "${DISK}${PARTITION_PREFIX}1" /mnt
|
||||||
|
sudo btrfs subvolume create /mnt/root
|
||||||
|
sudo btrfs subvolume create /mnt/root/srv
|
||||||
|
sudo btrfs subvolume create /mnt/root/srv/minecraft
|
||||||
|
sudo btrfs subvolume create /mnt/root/srv/soft-serve
|
||||||
|
# data_subvolumes ends here
|
||||||
|
# data_setup ends here
|
|
@ -56,6 +56,19 @@ Setup for my main server hosting computer, using an Nvidia GPU and the =server=
|
||||||
<<installing>>
|
<<installing>>
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
|
||||||
|
#+NAME: data_setup
|
||||||
|
#+BEGIN_SRC bash :tangle data_setup.bash :shebang "#!/usr/bin/env bash" :noweb yes :comments noweb
|
||||||
|
<<boilerplate>>
|
||||||
|
|
||||||
|
<<mount_check>>
|
||||||
|
|
||||||
|
<<data_partitioning>>
|
||||||
|
|
||||||
|
<<data_filesystems>>
|
||||||
|
|
||||||
|
<<data_subvolumes>>
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
** Script Boilerplate
|
** Script Boilerplate
|
||||||
|
|
||||||
#+NAME: boilerplate
|
#+NAME: boilerplate
|
||||||
|
@ -165,3 +178,35 @@ HOME=/mnt/persist/home/infinidoge /mnt/persist/home/infinidoge/.config/emacs/bin
|
||||||
echo "LOG: Unmounting all"
|
echo "LOG: Unmounting all"
|
||||||
sudo umount -R /mnt
|
sudo umount -R /mnt
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
|
||||||
|
** Setup Data Drive
|
||||||
|
|
||||||
|
*** Partitioning
|
||||||
|
|
||||||
|
#+NAME: data_partitioning
|
||||||
|
#+BEGIN_SRC bash
|
||||||
|
echo "LOG: Partitioning $DISK for data storage"
|
||||||
|
sudo parted $DISK -- mktable gpt
|
||||||
|
sudo parted $DISK -s -- mkpart primary btrfs 0% 100%
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
|
*** Making Filesystems
|
||||||
|
|
||||||
|
#+NAME: data_filesystems
|
||||||
|
#+BEGIN_SRC bash
|
||||||
|
echo "LOG: Making data filesystems"
|
||||||
|
echo "- Making btrfa filesystem on ${DISK}${PARTITION_PREFIX}1"
|
||||||
|
sudo mkfs.btrfs "${DISK}${PARTITION_PREFIX}1" --csum xxhash -L "data"
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
|
*** Making Subvolumes
|
||||||
|
|
||||||
|
#+NAME: data_subvolumes
|
||||||
|
#+BEGIN_SRC bash
|
||||||
|
echo "LOG: Making data subvolumes on ${DISK}${PARTITION_PREFIX}1"
|
||||||
|
sudo mount "${DISK}${PARTITION_PREFIX}1" /mnt
|
||||||
|
sudo btrfs subvolume create /mnt/root
|
||||||
|
sudo btrfs subvolume create /mnt/root/srv
|
||||||
|
sudo btrfs subvolume create /mnt/root/srv/minecraft
|
||||||
|
sudo btrfs subvolume create /mnt/root/srv/soft-serve
|
||||||
|
#+END_SRC
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue