-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathramstrap.sh
More file actions
43 lines (35 loc) · 1.75 KB
/
ramstrap.sh
File metadata and controls
43 lines (35 loc) · 1.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/bin/bash
## setup #######################################################################################
# URI of a debian mirror
dmir="http://ftp.us.debian.org/debian/"
# check for a zram directory in your home directory
if [ -d $HOME/zram ]; then
sudo export ZHOME=$HOME/zram
# if there isn't one, make one
else
sudo mkdir -v $HOME/zram && sudo export ZHOME=$HOME/zram
fi
################################################################################################
# First, probe the zram module. It is unlikely to be in your kernel by default.
# If it's already in there, modprobing it will not cause any problems.
sudo modprobe zram
# This line doesn't need to be this complicated. It writes the name of the
# available zram block device to temp, then zramctl initializes it using temp
# (dependent on a zram block device being available)
sudo echo "$(zramctl -f)" > temp && sudo zramctl -s 2048M -t 8 "$(cat temp)"
# exports the name of the zram block device to $ZBLOCK
sudo export CHECK="$(cat temp)"
sudo export ZBLOCK="$CHECK"
# checks for any irregularities, informs the kernel of the zram device, makes an ext4 fs,
# and mounts it on the $HOME/zram directory. For other architectures, change the --arch
# flag, and you can include packages (seperated by commas) after include. They must be in the
# Debian main repo for the debootstrap script to run completely.
if [ "$ZBLOCK" = "$CHECK" ]; then
sudo blkid --probe $ZBLOCK
sudo mkfs.ext4 -v $ZBLOCK
sudo mount $ZBLOCK -v -t ext4 $ZHOME
sudo debootstrap --include=build-essential bullseye $ZHOME "${dmir}"
else
echo "ERROR..." && sudo echo "zblock: $ZBLOCK zhome: $ZHOME check: $CHECK"
fi
#################################################################################################