0

I have removed mbr by mistake.

Now I can't boot ubuntu, so I want to reinstall grub.

I'm following this instructions.

The problem is that I'm getting this error:

grub-install --boot-directory=/media/cab64688-2d97-4bbd-9f32-7bc0badb40a8/boot /dev/sdb
rm: cannot remove `/media/cab64688-2d97-4bbd-9f32-7bc0badb40a8/boot/grub/915resolution.mod': Read-only file system

So, problem is that my existing ubuntu partition is mounted read only. When I try:

sudo mount /dev/sdb7  /media/ubuntu_mpt
mount: block device /dev/sdb7 is write-protected, mounting read-only

So I failed to install grub since I'm in read only mode.

Any idea?

Thanks in advance.

EDIT: After apt-get install grub, I repeated the process and got:

Probing devices to guess BIOS drives. This may take a long time.
Unknown partition table signature
sed: can't read /media/cab64688-2d97-4bbd-9f32-7bc0badb40a8_/boot/grub/device.map: No such file or directory
grep: /media/cab64688-2d97-4bbd-9f32-7bc0badb40a8_/boot/grub/device.map: No such file or directory
/dev/sda does not have any corresponding BIOS drive.

EDIT: Requested outputs:

fdisk -l

Disk /dev/sda: 163.9 GB, 163927522816 bytes
255 heads, 63 sectors/track, 19929 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Disk /dev/sda doesn't contain a valid partition table

Disk /dev/sdb: 640.1 GB, 640133946880 bytes
255 heads, 63 sectors/track, 77825 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x3dcf5202

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1   *           1        3917    31463271    7  HPFS/NTFS
/dev/sdb2            3918       77826   593667163    f  W95 Ext'd (LBA)
/dev/sdb5            3918       43080   314576766    7  HPFS/NTFS
/dev/sdb6           77328       77826     4000768   82  Linux swap / Solaris
/dev/sdb7           43081       77197   274041856   83  Linux
/dev/sdb8           77197       77327     1045504   82  Linux swap / Solaris

Partition table entries are not in disk order

Disk /dev/sdc: 4043 MB, 4043284480 bytes
125 heads, 62 sectors/track, 1018 cylinders
Units = cylinders of 7750 * 512 = 3968000 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x6f20736b

This doesn't look like a partition table
Probably you selected the wrong device.

   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1   ?      100405      247697   570754815+  72  Unknown
Partition 1 has different physical/logical beginnings (non-Linux?):
     phys=(357, 116, 40) logical=(100404, 79, 11)
Partition 1 has different physical/logical endings:
     phys=(357, 32, 45) logical=(247696, 24, 51)
Partition 1 does not end on cylinder boundary.
/dev/sdc2   ?       21767      271577   968014120   65  Novell Netware 386
Partition 2 has different physical/logical beginnings (non-Linux?):
     phys=(288, 115, 43) logical=(21766, 48, 47)
Partition 2 has different physical/logical endings:
     phys=(367, 114, 50) logical=(271576, 60, 42)
Partition 2 does not end on cylinder boundary.
/dev/sdc3   ?      241276      491086   968014096   79  Unknown
Partition 3 has different physical/logical beginnings (non-Linux?):
     phys=(366, 32, 33) logical=(241275, 3, 30)
Partition 3 has different physical/logical endings:
     phys=(357, 32, 43) logical=(491085, 14, 39)
Partition 3 does not end on cylinder boundary.
/dev/sdc4   ?      372346      372354       27749+   d  Unknown
Partition 4 has different physical/logical beginnings (non-Linux?):
     phys=(372, 97, 50) logical=(372345, 119, 25)
Partition 4 has different physical/logical endings:
     phys=(0, 10, 0) logical=(372353, 14, 33)
Partition 4 does not end on cylinder boundary.

Partition table entries are not in disk order

mount
aufs on / type aufs (rw)
none on /proc type proc (rw,noexec,nosuid,nodev)
none on /sys type sysfs (rw,noexec,nosuid,nodev)
fusectl on /sys/fs/fuse/connections type fusectl (rw)
none on /dev type devtmpfs (rw,mode=0755)
none on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=0620)
/dev/sr0 on /cdrom type iso9660 (ro,noatime)
/dev/loop0 on /rofs type squashfs (ro,noatime)
none on /sys/kernel/debug type debugfs (rw)
none on /sys/kernel/security type securityfs (rw)
none on /dev/shm type tmpfs (rw,nosuid,nodev)
tmpfs on /tmp type tmpfs (rw,nosuid,nodev)
none on /var/run type tmpfs (rw,nosuid,mode=0755)
none on /var/lock type tmpfs (rw,noexec,nosuid,nodev)
binfmt_misc on /proc/sys/fs/binfmt_misc type binfmt_misc (rw,noexec,nosuid,nodev)
gvfs-fuse-daemon on /home/ubuntu/.gvfs type fuse.gvfs-fuse-daemon (rw,nosuid,nodev,user=ubuntu)
/dev/sda on /media/Backup type ext4 (rw,nosuid,nodev,uhelper=udisks)
/dev/sdb7 on /media/cab64688-2d97-4bbd-9f32-7bc0badb40a8_ type ext4 (ro,nosuid,nodev,uhelper=udisks)

ls -lA /dev/disk/by-label
total 0
lrwxrwxrwx 1 root root 9 2011-06-12 18:32 Backup -> ../../sda
lrwxrwxrwx 1 root root 9 2011-06-12 18:31 Ubuntu\x2011.04\x20i386 -> ../../sr0
15
  • Could you show the output of sudo fdisk -l, mount and ls -lA /dev/disk/by-label?
    – Lekensteyn
    Jun 12, 2011 at 18:53
  • @Lekensteyn Please find requested outputs in last edit of my question. Thanks.
    – umpirsky
    Jun 12, 2011 at 19:09
  • What is /dev/sdc used for? I can see that /dev/sdb contains the Ubuntu installation (and a Windows one?). Are you using a disk as partition without a partition table? I've never seen that before :o
    – Lekensteyn
    Jun 12, 2011 at 19:10
  • /dev/sdc is my USB flash stick, you can ignore that. yes, ubuntu and win are on /dev/sdb. I'm not sure I understand "without a partition table" part. I simpley have them both on save hdd, but separated partitions. Eevrithing worked well, untill I formatted /dev/hda :)
    – umpirsky
    Jun 12, 2011 at 19:15
  • If I understand well, /dev/sda is your backup drive. Is it an external one? If so, please try unplugging it. I would also set up a proper partition table and partition on it using a tool like GParted.
    – Lekensteyn
    Jun 12, 2011 at 19:28

5 Answers 5

3

Just insert live cd and began ubuntu with livecd.Then goto

Applications->Accessories->Terminal then type sudo fdisk -l and find ubuntu installed partition.

then type the following in terminal

sudo mkdir /media/sdax ( here x is ubuntu installed partition number)

sudo mount /dev/sdax /media/sdax

sudo grub-install --root-directory=/media/sdax /dev/sda

then restart your system without live cd and type the following in terminal

sudo update-grub

2
  • That is something, will have that in mind if I have similar problems in the future. Hope someone will find your answer useful.
    – umpirsky
    Jun 13, 2011 at 16:47
  • These instructions worked perfectly on my system after I, too, ran into problems after trying to resize partitions (and after my Windows 7 got a virus). Thanks!
    – Kelley
    Jul 29, 2011 at 1:50
2

I fixed the problem with the help of UNetbootin. Installed it and managed to boot into my ubuntu system (cnosole mode or poor graphic mode). Whatever you boot from this two, just run grub-install /dev/sdb where /dev/sdb is boot hdd set in bios. Restart and grub should work.

0

use the command like this-->

sudo mount /dev/ROOT_PARTITION /opt  
sudo grub-install --root-directory=/opt /dev/sda
6
  • Thanks, but what is ROOT_PARTITION? On device sdb I have windows installed on sdb1 and Ubuntu on sdb7.
    – umpirsky
    Jun 12, 2011 at 18:22
  • So I guess ROOT_PARTITION would be sdb7 and in second line /dev/sda would change to /dev/sdb, right?
    – umpirsky
    Jun 12, 2011 at 18:28
  • yes you guessed right about the first part but /dev/sda must be your primary hdd device which loads first in your boot order which usually is /dev/sda.
    – 2hamed
    Jun 12, 2011 at 18:31
  • Still mounts as read only and still same error: sudo mount /dev/sdb7 /opt mount: block device /dev/sdb7 is write-protected, mounting read-only grub-install --root-directory=/opt /dev/sdb Probing devices to guess BIOS drives. This may take a long time. Unknown partition table signature sed: can't read /opt/boot/grub/device.map: No such file or directory grep: /opt/boot/grub/device.map: No such file or directory /dev/sdb does not have any corresponding BIOS drive
    – umpirsky
    Jun 12, 2011 at 18:33
  • that's weird! have no clue on that. sorry...
    – 2hamed
    Jun 12, 2011 at 18:37
0

Just download and install "Boot repair" http://mygeekopinions.blogspot.com/2011/06/install-boot-repair-in-ubuntu-1104.html . Just like that. I did it 1 hore ago, and bingo!

3
  • The whole problem was that the partition was mounted read only, so any software you install on system that is booted from CS would have same problem, unable to write to partition.
    – umpirsky
    Jun 13, 2011 at 16:46
  • Are you sure that you cannot change this with Gparted? Download parted magic here. partedmagic.com/doku.php?id=start. Burn it on Cd - and you can boot with this Cd - and automatically search an existing kernel to boot. Then you can dot everything you want. Jun 14, 2011 at 17:05
  • Hm, interesting.
    – umpirsky
    Jun 14, 2011 at 18:27
0

I just had to tackle a similar problem, and all I had to hand was an Ubuntu 14.04 "mini" boot disk - so this is how I did it:

  1. Boot off the mini boot disk and select "rescue mode" in advanced options (probably doesn't matter which you choose actually)
  2. When you get the installer started select "go back" to get the main menu.
  3. Select "start a shell". TBH any Linux boot disk that will give you a shell will get you this far.
  4. Mount the linux partition
  5. Bind-mount /dev, /proc and /sys into the mounted partition
  6. Chroot into that partition
  7. Run grub-install and update-grub2 from the chroot (the mini didn't have the grub tools installed.

# mount /dev/sda5 /mnt # mount -o bind /dev /mnt/dev # mount -o bind /proc /mnt/proc # mount -o bind /sys /mnt/sys # chroot /mnt /bin/bash ~# grub-install --root-directory=/ /dev/sda ~# update-grub2 ~# ^D # reboot

Et voila - grub is back.


(code indents not working on this site...?)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .