From a79bd35f11c394f4fa8b02ba48c31aca85bfefea Mon Sep 17 00:00:00 2001 From: Xiaosu Lyu Date: Wed, 30 Nov 2022 23:15:23 -0500 Subject: [PATCH] upload script --- runtime/tests/add_partion.sh | 57 ++++++++++++++++++++++++++++++++++++ runtime/tests/no_hyper.sh | 21 +++++++++++++ runtime/tests/set_cpu.sh | 1 + 3 files changed, 79 insertions(+) create mode 100755 runtime/tests/add_partion.sh create mode 100755 runtime/tests/no_hyper.sh create mode 100755 runtime/tests/set_cpu.sh diff --git a/runtime/tests/add_partion.sh b/runtime/tests/add_partion.sh new file mode 100755 index 00000000..0d97a33a --- /dev/null +++ b/runtime/tests/add_partion.sh @@ -0,0 +1,57 @@ +#!/bin/bash + +setVim(){ +echo "hi comment ctermfg=3 +set hlsearch + +if has(\"autocmd\") + au BufReadPost * if line(\"'\\\"\") > 1 && line(\"'\\\"\") <= line(\"$\") | exe \"normal! g'\\\"\" | endif +endif + +" > ~/.vimrc +} + +setVim + +#remember github username and password +git config --global credential.helper store + +do_partition() { +echo "doing partition" +echo "n +p +1 + ++400G +w +" | sudo fdisk /dev/sdb && sleep 4 && sudo mkfs.ext4 /dev/sdb1 +} + +add_partition() { + has_sdb=`sudo fdisk -l /dev/sdb|grep "/dev/sdb: 1.9 TiB"` + no_partition=`sudo fdisk -l /dev/sdb|grep "Device"` + #echo $has_sdb + if [[ $has_sdb == *"Disk /dev/sdb: 1.9 TiB"* ]]; then + if [ -z "$no_partition" ]; + then + do_partition + else + echo "/dev/sdb already has paritions" + exit + fi + else + echo "no /dev/sdb or its capacity is not 1.1 TiB" + exit + fi +} + +mount_partition() { + sudo mkdir /my_mount + sudo mount /dev/sda4 /my_mount + df -h +} +#add_partition +sudo mkfs.ext4 /dev/sda4 +mount_partition +sudo chmod 777 /my_mount + diff --git a/runtime/tests/no_hyper.sh b/runtime/tests/no_hyper.sh new file mode 100755 index 00000000..86adce62 --- /dev/null +++ b/runtime/tests/no_hyper.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +# DISCLAIMER: +# Script taken from http://askubuntu.com/questions/201937/ubuntu-detect-4-cpus-and-i-have-only-2-cpus + + +echo "Disabling hyperthreading..." + +CPUS_TO_SKIP=" $(cat /sys/devices/system/cpu/cpu*/topology/thread_siblings_list | sed 's/[^0-9].*//' | sort | uniq | tr "\r\n" " ") " + +# Disable Hyperthreading +for CPU_PATH in /sys/devices/system/cpu/cpu[0-9]*; do + CPU="$(echo $CPU_PATH | tr -cd "0-9")" + echo "$CPUS_TO_SKIP" | grep " $CPU " > /dev/null + if [ $? -ne 0 ]; then + echo 0 > $CPU_PATH/online + fi +done + +lscpu | grep -i -E "^CPU\(s\):|core|socket" + diff --git a/runtime/tests/set_cpu.sh b/runtime/tests/set_cpu.sh new file mode 100755 index 00000000..07a5188d --- /dev/null +++ b/runtime/tests/set_cpu.sh @@ -0,0 +1 @@ +sudo cpupower frequency-set -g performance