Skip to content

Instantly share code, notes, and snippets.

@x4x
Last active September 23, 2022 02:18
Show Gist options
  • Save x4x/d99e46b8b6bdf2850c945a9abfdb1b33 to your computer and use it in GitHub Desktop.
Save x4x/d99e46b8b6bdf2850c945a9abfdb1b33 to your computer and use it in GitHub Desktop.
GRUB Reparatur chroot
#!/bin/bash
# different keymaps:
# /usr/share/keymaps/i386/
# /usr/share/kbd/keymaps/i386/
# /usr/share/X11/xkb/symbols/
#loadkeys de
setxkbmap de
# mount
cryptsetup luksOpen /dev/sda3 <uuid>
# chroot
sudo mount /dev/sda1 /mnt
#sudo mount /dev/sdXY /mnt/boot # for separate Boot-Partition
#sudo mount /dev/sdX1 /mnt/boot/efi # uefi boot
#sudo mount /dev/mapper/<xyz> /mnt # if LVM, cryptmd or somthing simular is used
sudo mount -o bind /dev /mnt/dev
sudo mount -o bind /sys /mnt/sys
sudo mount -t proc /proc /mnt/proc
sudo mount -o bind /run /mnt/run
#sudo cp /proc/mounts /mnt/etc/mtab
sudo chroot /mnt /bin/bash
update-initramfs -u -k all #remake initramfs
grub-install /dev/sda
#grub-install --recheck /dev/sda
update-grub
## networking has to be configured on host system
dhclient
ip addr add IP/NETMASK dev DEVICE
ip route add default via IP dev DEVICE
## grub cli
echo nameserver 8.8.8.8 > /etc/resolv.conf
apt-get update
apt-get install grub
grub
#> device (hd1) /dev/cciss/c0d0
# use tub to see avelable hdds
#> root (hd1,0)
#> setup (hd1)
#> quit
# copy the OS
#sudo cp -afv /mnt/a/* /mnt/b/
# /proc /dev /run are empty folders
# than cange the uuid from the disk in /mnt/b/etc/fstab
# you can get the uuids by doing 'ls -l /dev/drisk/by-uuid/'
# close and unmount
umount /mnt/boot/efi /mnt/boot
umount /mnt
#vgchange -an <vgpath>
#vgchange -ay <vgpath>
dmsetup ls
dmsetup remove <name>
cryptsetup luksClose /dev/mapper/vol
dpkg --get-selections > selections
sudo dpkg --clear-selections
sudo dpkg --set-selections < selections
sudo apt-get --reinstall dselect-upgrade
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment