Ubuntu – Accidentally deleted all kernel versions

bootkernel

I had dual booted my system with Windows 10 and Linux-Ubuntu-16.04.

I recently was modifying some configuration files in Linux-Kernel 4.17 which did not work so I had to delete that and restore to my normal 4.13 version. But in the verge of deleting I might have deleted both the kernels and now when I boot my system I can get only windows turned on with no option to select ubuntu.

Is it that my ubuntu has completely removed and I need to reinstall it again?

If I reinstall will I loose my present data in Windows and will I be able to gain data I stored in Linux OS?

What steps needs to be followed? Please help me out! I'm a core Linux user with all the files saved in it!

Best Answer

    • You can reinstall your Ubuntu without hitting Windows at all
    • To recover your data, I suggest you to use a bootable USB drive + another USB storage to save all important data inside it

    To do this important step, you need to :

    Boot on the USB, choose "Try Ubuntu" option (Live Ubuntu session)

    Open a terminal, and type the following command:

    sudo fdisk -l    ###find the partition which contains your data
    
    sudo mount /dev/sdaN /mnt  ####N is the partition number (can be sdbN, sdcN too)
    sudo mount --bind /dev /mnt/dev
    sudo mount --bind /sys /mnt/sys
    sudo mount --bind /run  /mnt/run
    sudo mount --bind /proc /mnt/proc
    sudo chroot /mnt           ####after this command, you re inside your previous Ubuntu partition
    

    Plug your storage USB, and mount it with :

    sudo mount /dev/sdU /opt    ####where U is the USB partition, seen with fdisk -l
    

    NB: You can also mount your USB storage at another place than /opt, but I think it's the least restrictive


    Now, you can copy all data from your sick partition to your USB storage; just don't forget to unmount and unplugged this device with sudo umount /opt before starting the installation

    You can now launch the re-installation of Ubuntu, just select the option "Remove Ubuntu" and not "Format the whole disk", you know what I mean