-
Notifications
You must be signed in to change notification settings - Fork 0
/
cloud_init.sh
executable file
·62 lines (49 loc) · 1.43 KB
/
cloud_init.sh
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/bin/bash
# This is the init script to mount and configure the nvme drives on an m5d.12xlarge server
# make /tmp be a ram filesystem
cat <<EOF >> /etc/fstab
tmpfs /tmp tmpfs defaults,noatime,mode=1777,size=10g 0 0
tmpfs /var/spool tmpfs defaults,noatime,mode=1777,size=10m 0 0
tmpfs /var/tmp tmpfs defaults,noatime,mode=1777,size=10m 0 0
EOF
mount -a
# we're going to need some deps
apt update
apt install -y docker.io build-essential
mkdir -p /tmp/build
cd /tmp/build
git clone https://github.com/cilliemalan/the_big_sort
cd the_big_sort/src
make
make install
cd ..
cp *.sh /usr/bin/
cd /
rm -rf /tmp/build
# create and mount NVME partitions and filesystems
function initialize {
local drive=$1
local mountpoint=$2
local part=${drive}p1
sed -e 's/\s*\([\+0-9a-zA-Z]*\).*/\1/' << EOF | fdisk ${drive}
o # clear the in memory partition table
n # new partition
p # primary partition
1 # partition number 1
# default - start at beginning of disk
+535G # amount of space in the new partition
w # write the partition table
q # quit just in case
EOF
sleep 1
mkfs.ext4 ${part}
local uuid=$(blkid ${part} | sed -r 's/^.+UUID="(.+?)" TYPE.+/\1/')
echo "UUID=${uuid} ${mountpoint} ext4 noatime,discard,errors=remount-ro 0 0" \
>> /etc/fstab
mkdir -p ${mountpoint}
tune2fs -O ^has_journal ${part}
tune2fs -o discard ${part}
}
initialize /dev/nvme1n1 /src
initialize /dev/nvme2n1 /dst
mount -a