3

I have a laptop with Xubuntu installed.

At install I chose the full disk encryption option.

But yesterday i accidentally dd-ed a DSL image to sda1 (/boot partition) instead to sdb1 (pendrive).

How can i repair my /boot ?

  • pls tell us your ubuntu version – db429 Nov 3 '16 at 2:30
7

Hello i tested following commands in my laptop - yeah I deleted everything in /dev/sda1 and I got it working again - so here it is:

  • Get a live-image and boot from it.

  • First lets get a clean /dev/sda1 - open Gparted; reformat /dev/sda1 with ext2 and don't forget to set the "boot"-flag (right click on the partition and select appropriate option) and confirm the changes.

  • Now we will prepare everything to chroot into the installed system and then we switch into it: sudo cryptsetup luksOpen /dev/sda5 sda5_crypt sudo vgscan --mknodes sudo vgchange -ay sudo mount /dev/mapper/ubuntu--vg-root /mnt sudo mount /dev/sda1 /mnt/boot for i in /dev /dev/pts /proc /sys /run; do sudo mount -B $i /mnt$i; done sudo chroot /mnt

  • Okay let's delete and reinstall GRUB: apt purge grub-common (have your terminal in fullscreen-mode due to ncurses), this might ask you if it shall delete everything - select yes; now lets reinstall it with apt install grub-pc here select /dev/sda when asked.

  • Lastly we need to reinstall a kernel to get the needed initrd*- and vmlinuz*-images into /boot/ . We get currently installed kernels with apt list --installed linux-image-* and now we reinstall this kernel with apt install linux-image-[version-numbers]-generic --reinstall - don't forget to exchange the brackets with an actual version number.

  • Almost done; exit chroot with Ctrl-d and reboot!

used resources:

https://ubuntuforums.org/archive/index.php/t-1432656.html

https://help.ubuntu.com/community/Grub2/Installing

  • thx this post helped me again! – Oliver G. Jan 8 '18 at 19:57
  • Great answer! One additional issue that I needed to fix after that: The reformat of sda1 lead to a different uuid for that partition. So I needed to change the uuid in fstab after this procedure. – Stephen Friedrich Apr 18 '18 at 13:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.