2

I have dual boot system, but while booting my system with window 7, I deleted swap partition mistakenly. Now it is showing no such partition grub rescue.

I installed very important software in Ubuntu and I don't want to reinstall it again. Is there any method to resolve it?

Gryu
  • 7,559
  • 9
  • 33
  • 52

3 Answers3

4

You don't need Internet connection, just you need Ubuntu in CD/Flash.

Boot from live CD/Flash and do steps:

  1. After booting from live Ubuntu, first of all open gparted and check if you installed Ubuntu in which partition ex:/dev/sdaX, where X is your installed partition (Type gparted in dash and open it).

I am consider for example you installed Ubuntu on /dev/sda4 and I explain steps.

  1. Then mount /dev/sda4 by the following commands (you can replace it by partition that you will see in gparted application):

    sudo mount /dev/sda4 /mnt
    for i in /sys /proc /run /dev;do sudo mount --bind "$i" "/mnt$i";done
    
  2. Now we mounted the /dev/sda4 that installed Ubuntu here. just run below command to switch to root directory of Ubuntu patrtition:

    sudo chroot /mnt
    
  3. And run below command to install grub to main partition /dev/sda:

    grub-install /dev/sda
    
  4. Update grub and exit and reboot your system. it will fix.

    update-grub
    exit
    sudo reboot
    

I hope this helps.

αғsнιη
  • 35,660
  • Performing this with update makes sure that the latest grub package will be installed. Because the version on the liveUSB is older than the one on his computer if he updated before. So having the same answer but without internet doesn't make it different ;) – OdinRW Sep 18 '14 at 19:01
  • Yes it is. I am not sure if doing this will solve it. I can't force the problem manually to check the solution :) Anyway we will see if he will ever show up again :p He solved his problem apparently – OdinRW Sep 18 '14 at 19:03
  • 1
    hehehe just did the same at same time! Cheers! – OdinRW Sep 18 '14 at 19:04
2

You can also try to use this [tool](https://help.ubuntu.com/community/Boot-Repair. I didn't try myself :)

YOU NEED INTERNET CONNECTION TO SOLVE THIS

So this you have to do it carefully as you might destroy your OS completely. Now you have just corrupted the grup (and sure deleted swap but you can create it later). First boot from a live USB and open terminal. Then use fdisk to locate the partition where your OS is installed.

sudo fdisk -l

You will get somethings like

/dev/sda1    Linux
/dev/sda2    Extended

Now we want the one that has Linux next to it. In my case it's /dec/sda1. We will mount it now.

sudo mkdir /mnt/temp
sudo mount /dev/sda1 /mnt/temp

Now you have to act as the chroot to modify the root partition.

for i in /dev /dev/pts /proc /sys; do sudo mount -B $i /mnt/temp$i;  done
sudo cp /etc/resolv.conf /mnt/temp/etc/resolv.conf
sudo chroot /mnt/temp

Then you have to delete the grub components and reinstall them again.

apt-get purge grub grub-pc grub-common
apt-get update && apt-get install grub grub-pc grub-common
update-grub 
exit

Then you can reboot your system and it will be just fine. It's time to create a swap again (if you want), you can check here. Otherwise I can help you further.

OdinRW
  • 632
  • I think you can use the sudo grub-install --root-directory=/mnt/temp/ /dev/sda command instead of purging and reinstalling grub if you don't have internet. This command installs grub to the MBR of /dev/sda. Then, run sudo update-grub as usual and continue. – mchid Sep 18 '14 at 14:35
0

The easiest way would be to boot from a live cd/dvd or USB. Then yo can start the gparted program. There you can recreate the swap partition, you deleted earlier. Then you just install grub customizer and rewrite the grub. https://launchpad.net/~danielrichter2007/+archive/ubuntu/grub-customizer

Grub customizer will automatically recognize your operating systems. You can change the order, which on will start automatically. You can set the delay time in seconds, you can fully customize the boot menu if you wish. Then you just restart the system, and everything should be working just fine.

Have fun. Benjoy!