Sauvetage en Direct d'Ubuntu

Aperçu

Comment j'ai réussi à revenir au démarrage depuis une ancienne partition après avoir modifié la partition de démarrage active à l'aide de « testdisk » et m'être retrouvé dans une situation délicate.

Désolé, mais je n'ai pas eu le temps de traduire ce document, le reste est donc en anglais.

Create/Fix Grub 2 boot

  1. Boot from Ubuntu Live USB

    Choose 'try ubuntu'. Boot Normal mode Without persistence Open a terminal window.

  2. Detect Partition to install GRUB

sudo fdisk -l

output:

Disk /dev/sda: 465.8 GiB, 500107862016 bytes, 976773168 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: dos
Disk identifier: 0x5f540829

Device Boot Start End Sectors Size Id Type
/dev/sda1 2048 156205055 156203008 74.5G 83 Linux
/dev/sda2 * 156205056 968665087 812460032 387.4G 83 Linux
/dev/sda3 968665088 976771071 8105984 3.9G 82 Linux swap / Solaris

Note:

/dev/sda1 is the one that we can still boot from.
/dev/sda2 is the one I made active (causing the problem)
  1. Mount Partition(s)
sudo mount /dev/sda1 /mnt

Now point /dev and a few others to locations on the partition so grub uses those.
for i in /dev /dev/pts /proc /sys; do sudo mount -B ${i} /mnt${i} ; done`
  1. Maskerade as though ''/mnt' were now ''/''
sudo chroot /mnt
# You can get back to the main root with <ctrl>d
  1. install grub
grub-install --recheck /dev/sda
# The recheck checks/rebuilds the partition map grub uses.
  1. update grub
update-grub
exit
  1. unmount partitions
for i in /sys /proc /dev/pts /dev ; do sudo umount /mnt${i}; done

sudo umount /mnt
  1. reboot computer

    The steps above corrected my problem, but I still had to choose a grub recovery option to boot properly.

    This is because the active partition is still set to the one that does not work. We need to switch the active partition.

    To do that, I booted up using grub recovery option.

    I Then logged into the Ubuntu 16.04 partition and used the GUI app called disks . I edited the (wrong) active partition to turn off "bootable", then edited the correct partition to turn it on.

    After that reboot brought up the working partition hands free.

Note1

This Note is all but copied from the link where I learned how to do this stuff:

How To install/repair GRUB with Ubuntu Live CD/Flash

Note2

testdisk is a popular tool to recover data from faulty partitions.

But Since our partitions were pretty well intact, we did not need it in this case.

Publié le par Pierre Bernatchez dans «dépanner». Mots-clés: Ubuntu, récupération, démarrage, partition, disque, comment faire