0

I am a newbie to Ubuntu. Using it since a couple of months back and still learning it. But today something weird happened. I was trying to free some disk space from my /boot directory. To do that I have launched Synaptic Package Manager and found initramfs package dependency update is broken and then I tried to remove this package and wanted to re install it.

I selected that package and clicked on Completely remove option thus all my ubuntu system went removed completely. Nothing left !!! Except the grub loader and Win7 in another partition of my HDD.

I have some important documents and files inside ubuntu.

So I am looking forward to if there any option if I can get back my system as it was before . I have searched google but found nothing that much helpful.

Can anyone please help?

  • when you try to boot into ubuntu you get something like grub> ? – Tarun Nov 26 '13 at 11:28
1

You did (one of) the worse thing ever in Linux. You mustn't remove package without care of what it's being done. That said you will need a Live USB/CD with the same architecture of your installed system (if it's Ubuntu 64-bits the recovery must be 64-bits too) so you can chroot into the device.

To chroot

After booting in your live system, open a terminal (for illustrative proposes I will use examples, you must change the values in bold). Verify your mount points:

sudo fdisk -l
/dev/sda1       339392512   368687103    14647296   83  Linux
/dev/sda2       368689152   390721535    11016192   83  Linux

Here comes something difficult. If you installed /boot in another partition you must mount it too. In my case, / is sda1 so I proceed to mount it.

sudo mount /dev/sda1 /mnt
sudo mount -o bind /proc /mnt/proc
sudo mount -o bind /dev /mnt/dev
sudo mount -o bind /dev/pts /mnt/dev/pts
sudo mount -o bind /sys /mnt/sys

If you didn't or aren't sure that you installed your /boot partition, just ignore this step:

sudo mount /dev/sda2 /mnt/boot

In this case I'm assuming the my /boot is sda2. You also need internet:

sudo cp /etc/resolv.conf /mnt/etc/resolv.conf

Now to chroot your system. Type:

sudo chroot /mnt /bin/bash

Once you have done this, lets repair your initramfs:

apt-get install initramfs-tools
update-initramfs

Then reboot your system. Done.

  • @ Braiam Wow what an answer. I am so happy reading this and the collaboration in among ubuntu users. Thanks many. Let me try this. I will confirm one done successfully. – Sayeed Nov 27 '13 at 4:14

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.