-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a systemd service which, on boot, partitions local SSD and installs Rustup and Cargo on it for NayDuck to use. Since the disk is quite a bit larger than what we need, use part of it for swap which should help with Docker tests sometimes failing.
- Loading branch information
Showing
6 changed files
with
77 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
[Service] | ||
Type=oneshot | ||
RemainAfterExit=yes | ||
WorkingDirectory=/home/nayduck/nayduck | ||
ExecStart=/bin/sh systemd/setup-local-ssd.sh | ||
|
||
[Install] | ||
WantedBy=multi-user.target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#!/bin/sh | ||
|
||
set -eux | ||
|
||
dev=/dev/nvme0n1 | ||
dir=/datadrive | ||
|
||
# Sanity checks | ||
if ! [ -e "$dev" ]; then | ||
echo "$dev: device does not exist; nothing to do" | ||
exit 0 | ||
fi | ||
|
||
if ! [ -e "${dev}p1" ]; then | ||
# Partition the disk: | ||
# - p1 → data partition, will become /datadrive | ||
# - p2 → swap partition | ||
sfdisk "$dev" <<EOF | ||
size=360G | ||
type=swap | ||
write | ||
EOF | ||
|
||
# Data on the device is essentially lost on reboot and we’re treating it as | ||
# ephemeral. There’s no point in keeping journal. | ||
mkfs.ext4 -E discard -O ^has_journal "${dev}p1" | ||
mkdir -p "$dir" | ||
mount "${dev}p1" "$dir" -o discard,noatime,nobarrier | ||
chown nayduck:nayduck "$dir" | ||
|
||
cat >$dir/README <<EOF | ||
Data in this directory is ephemeral and may disappear on reboots. | ||
Don’t keep any data which cannot be recreated here. | ||
EOF | ||
chmod 644 "$dir/README" | ||
|
||
# Install Rustup and Cargo in /datadrive/home for NayDuck to use. Those always | ||
# take a lot of space so best keep them on our massive local SSD. | ||
mkdir -p "$dir/home" | ||
chown nayduck:nayduck "$dir/home" | ||
sudo -u nayduck CARGO_HOME="$dir/home/cargo" RUSTUP_HOME="$dir/home/rustup" ' | ||
set -eux | ||
curl https://sh.rustup.rs -sSf | sh -s -- -y | ||
"$CARGO_HOME/bin/rustup" target add wasm32-unknown-unknown | ||
"$CARGO_HOME/bin/cargo" install cargo-fuzz | ||
' | ||
else | ||
mount "${dev}p1" "$dir" -o discard,noatime,nobarrier | ||
fi | ||
|
||
# Enable swap on the second partition | ||
mkswap "${dev}p2" | ||
swapon "${dev}p2" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters