May 7, 2023 05:42 AM
(This post was last modified: May 7, 2023 05:45 AM by Nightmare.)
That is a simple chroot script,i used this to repair my grub many times on ubuntu!
Here it is:
If anyone has a better one please share,or any recommendations!
Here it is:
Code
#!/bin/bash
clear
#Colors
black() { echo "$(tput setaf 0)$*$(tput setaf 9)"; }
red() { echo "$(tput setaf 1)$*$(tput setaf 9)"; }
green() { echo "$(tput setaf 2)$*$(tput setaf 9)"; }
yellow() { echo "$(tput setaf 3)$*$(tput setaf 9)"; }
blue() { echo "$(tput setaf 4)$*$(tput setaf 9)"; }
magenta() { echo "$(tput setaf 5)$*$(tput setaf 9)"; }
cyan() { echo "$(tput setaf 6)$*$(tput setaf 9)"; }
white() { echo "$(tput setaf 7)$*$(tput setaf 9)"; }
#REDbold="\e[1;31m" #Alter fonts to red bold
#REDN="\e[0;31m" #Alter fonts to red normal
GRN="\e[1;32m" #Alter fonts to green bold
GRNN="\e[0;32m" #Alter fonts to green normal
BLU="\e[1;36m" #Alter fonts to blue bold
BLUN="\e[0;36m" #Alter fonts to blue normal
YEL="\e[1;33m" #Alter fonts to yellow bold
YELN="\e[0;33" #Alter fonts to yellow normal
PUR="\e[1;35m" #Alter fonts to purple bold
PURN="\e[0;35m" #Alter fonts to purple normal
CYA="\e[1;36m" #Alter fonts to cyan normal
CYAN="\e[0;36m" #Alter fonts to purple bold
dgrey="\033[0;34m"
port="\033[0;33m"
RED="\033[1;31m"
GREEN="\033[2;32m"
YELLOW="\033[1;33m"
BLUE="\033[1;34m"
RED="\033[0;31m"
ENDCOLOR="\033[0m"
echo -e $GREEN"Enter the name of the partition that your system is installed to chroot on it(etc.. /dev/sdb5):"$ENDCOLOR
read name
sleep 0.5
echo -e $RED"removing old chroot environments.."$ENDCOLOR
rm -rf /mnt/ubuntu
sleep 0.5
mkdir /mnt/ubuntu
sleep 0.5
echo -e $RED"mounting $name filesystem"$ENDCOLOR
sudo mount $name /mnt/ubuntu
sleep 0.5
chroot /mnt/ubuntu apt -y install lvm2
sleep 0.5
mount -o bind /proc /mnt/ubuntu/proc
sleep 0.5
mount -o bind /dev /mnt/ubuntu/dev
sleep 0.5
mount -o bind /dev/pts /mnt/ubuntu/dev/pts
sleep 0.5
mount -o bind /sys /mnt/ubuntu/sys
sleep 0.5
mount --bind /run/udev /mnt/ubuntu/run/udev
sleep 0.5
cp /etc/resolv.conf /mnt/ubuntu/etc/resolv.conf
sleep 0.5
chroot /mnt/ubuntu /bin/bash
wait
echo -e $port"umounting $name filesystem"$ENDCOLOR
sleep 0.5
umount /mnt/ubuntu/run/udev
sleep 0.5
umount /mnt/ubuntu/proc
sleep 0.7
sudo umount /mnt/ubuntu/dev
sleep 0.5
umount /mnt/ubuntu/dev/pts
sleep 0.5
umount /mnt/ubuntu/sys
sleep 0.5
sudo umount /mnt/ubuntu
sleep 0.5
echo -e $GREEN"exiting chroot environment"$ENDCOLOR
echo "done" | festival --ttsIf anyone has a better one please share,or any recommendations!


![[Image: sig.gif]](https://i.ibb.co/dsQz4qzN/sig.gif)