Last active
April 22, 2020 15:19
-
-
Save Ending2015a/8e4bf53f1d4d2a075c36141b7eed9765 to your computer and use it in GitHub Desktop.
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
#!/bin/bash | |
set -x | |
# update package info | |
sudo apt-get update | |
# download kernel | |
KERNEL_VERSION="4.15.1" | |
LINUX_KERNEL=linux-${KERNEL_VERSION} | |
LINUX_KERNEL_TAR=${LINUX_KERNEL}.tar.gz | |
# ~151M | |
wget https://cdn.kernel.org/pub/linux/kernel/v4.x/${LINUX_KERNEL_TAR} | |
tar zxvf ${LINUX_KERNEL_TAR} | |
sudo mv ${LINUX_KERNEL}/ /usr/src/ | |
# delete tar | |
rm ${LINUX_KERNEL_TAR} | |
# install dependencies | |
sudo apt-get install -y fakeroot build-essential libncurses5-dev kernel-package openssl bison flex libssl-dev | |
# create 2G swap | |
sudo dd if=/dev/zero of=/swapfile bs=1k count=2048000 | |
sudo mkswap /swapfile | |
sudo swapon /swapfile | |
IFS=' ' read -r -a MEMORY_SPACE <<< "$(free -t | grep Total)" | |
if [ ${MEMORY_SPACE[-1]} -lt 2048000 ]; then | |
echo -e "NOTICE: The Total Memory is less than 2G, the kernel compilation process might fail!" | |
fi | |
# make kernel | |
cd /usr/src/${LINUX_KERNEL} | |
sudo cp /boot/config-$(uname -r) .config | |
# configure kernel | |
sudo make oldconfig | |
sudo make menuconfig | |
# create file to prevent from `cannot state 'REPORTING-BUGS' error` | |
sudo touch REPORTING-BUGS | |
# at least 30G space | |
#time sudo fakeroot make-kpkg -j16 --initrd --revision "0.0.custom" --append-to-version -$(date +%s) kernel_image kernel_headers | |
# this will reduce 14G disk space | |
#sudo make-kpkg clean | |
# install kernel | |
#sudo dpkg -i linux-image ... | |
#sudo dpkg -i linux-header ... | |
# reboot | |
#sudo reboot | |
#cannot use CONFIG_STACK_VALIDATION=y, please install libelf-dev | |
set +x |
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
#!/bin/bash | |
# you can download this script by typing the following command: | |
# wget https://ppt.cc/fbnhvx -O remove_kernel.sh | |
sudo apt-get remove $(dpkg -l | egrep '^ii linux-(im|he)' | awk '{print $2}' | grep -v `uname -r`) |
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
#!/bin/bash | |
set -x | |
# https://ppt.cc/fxkHjx | |
# install tensorflow & run mnist example | |
# NOTICE: you need totally at least 1024M memory (or swap) for installing TensorFlow, | |
# otherwise, MemoryError will be raised | |
sudo apt-get install -y python3-pip | |
sudo pip3 install --upgrade setuptools | |
sudo pip3 install tensorflow | |
wget https://gist.githubusercontent.com/Ending2015a/c0c5e44b430e24056e96ec96794389cf/raw/a8194be52cb9f0539140283b0e5abbb8e8b8906c/mnist.py -O ~/mnist.py | |
python3 mnist.py | |
set +x |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment