Advertisement
peetaur

reinstall GRUB2

May 20th, 2015
991
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.68 KB | None | 0 0
  1.     # mount the rootfs somewhere
  2.     mount /dev/sda1 /mnt/root
  3.     # also if you have a separate /boot, mount that also, eg.
  4.     mount /dev/sda2 /mnt/root/boot
  5.  
  6.     cd /mnt/root
  7.    
  8.     # next 4 lines: general, non-arch based (works for arch too, but pacman won't work within chroot)
  9.     mount -o rbind /dev dev
  10.     mount -o rbind /proc proc
  11.     mount -o rbind /sys sys
  12.     chroot /mnt/root
  13.  
  14.     # next 1 line: archlinux based (requires arch-install-scripts package)
  15.     arch-chroot /mnt/root
  16.    
  17.         blkid
  18.         vim /etc/fstab
  19.             make sure UUIDs are right
  20.            
  21.         # If you dual boot, and grub is chainloaded, disk is more like /dev/sda1 rather than /dev/sda
  22.         grub-install $disk
  23.         # in some distros, it's /boot/grub2/grub.cfg; for debian and arch, "update-grub" does the same.
  24.         grub-mkconfig -o /boot/grub/grub.cfg
  25.    
  26.         vim /boot/grub/grub.cfg
  27.             (optional)
  28.             Make sure UUIDs are right.
  29.             If you are not using uuids, but using /dev/sdX names instead, I highly recommend changing now to use UUIDs instead.
  30.            
  31.         #debian based: (not sure if it's -c or -u)
  32.             update-initramfs -u
  33.         #openSUSE:
  34.             mkinitrd
  35.         #arch/manjaro; replace "linux" with your kernel name. List first with ls.
  36.             mkinitcpio -p /etc/mkinitcpio.d/linux.preset
  37.         #arch/manjaro alternative; (add kernel version in there, based on filenames in /lib/modules/)
  38.             mkinitramfs -g /boot/initramfs-...-x86_64.img -k ...
  39.        
  40.         exit
  41.  
  42.     #optional... unmount
  43.     cd /
  44.  
  45.     # next 1 line: general, non-arch based
  46.     umount /mnt/root/*
  47.  
  48.     umount /mnt/root
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement