How to solve Grub rescue and/or mounting hard drive problem
If the currrent fdisk -l output is literally just this:
ubuntu@ubuntu:~$ sudo fdisk -l
Disk /dev/sda: 160.0 GB, 160041885696 bytes 255 heads, 63 sectors/track, 19457 cylinders, total 312581808 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x000285b2 Device Boot Start End Blocks Id System
then you have somehow deleted your linux installation instead of the windows drive as you thought. This would be... unfortunate...
If you have a record of how the partitioning was set up, which is unlikely, then sometimes recreating the partitions will actually still have the disk data in place - but you have to be EXACT. If there was only one partition then it's worth a try of recreating a single, default linux (83) partition in fdisk & see if it contains data...
If not, then you need something like foremost, which is an undelete / file recovery tool that can scan your entire lost drive and copy files to a new drive - they will be un-named, and you will have loads of files, so this is going to keep you busy for some time. It will however sort them into types, which helps.
You may, of course, just have mixed up the drives - I suggest you check what's on the other two...
Related videos on Youtube
Germano Corrêa
PHP programmer, a11y developer, Zurb Foundation fan and FOSS evangelist.
Updated on September 18, 2022Comments
-
Germano Corrêa over 1 year
So, I have important files in this hard drive, and I need pick up them. To sum up, I had two HD on my machine: one with Ubuntu GNOME 14.04 and another two with Windows 7. I had to connect another HD with windows replacing the other one with windows, copy some files from this hard drive. After that, I connected only this HD and formatted it. Ok, no problem beyond a grub-rescue shell appearing, but I solved changing the boot order of the hard drives (no idea how).
Now, I need to pick up those files and place them into the windows hard driver, but again the grub-rescue shell. This time, I tried almost everything, mount it using a Live CD, some stuff in the grub-rescue, changing boot order, nothing. It's not even mounting it when I use windows or a live cd. In that first case, I hadn't a usb stick, but now I got one, I only want to mount the linux hard driver and copy those files.
Yes, I've searched for questions like this one here but didn't solved nothing...
So, here are some information and things I tried:
ubuntu@ubuntu:~$ sudo fdisk -l Disk /dev/sda: 160.0 GB, 160041885696 bytes 255 heads, 63 sectors/track, 19457 cylinders, total 312581808 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x000285b2 Device Boot Start End Blocks Id System ubuntu@ubuntu:~$ lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 149.1G 0 disk sr0 11:0 1 2G 0 rom /cdrom loop0 7:0 0 935.2M 1 loop /rofs ubuntu@ubuntu:~$ blkid /dev/sr0: LABEL="Ubuntu 14.04 LTS i386" TYPE="iso9660" ubuntu@ubuntu:~$ sudo mount -t ext4 /dev/sda /mnt mount: wrong fs type, bad option, bad superblock on /dev/sda, missing codepage or helper program, or other error In some cases useful info is found in syslog - try dmesg | tail or so
(this one I tried ext2, ext3, nothing changed)
ubuntu@ubuntu:~$ sudo fsck /dev/sda fsck from util-linux 2.20.1 e2fsck 1.42.9 (4-Feb-2014) ext2fs_open2: Bad magic number in super-block fsck.ext2: Superblock invalid, trying backup blocks... fsck.ext2: Bad magic number in super-block while trying to open /dev/sda The superblock could not be read or does not describe a valid ext2/ext3/ext4 filesystem. If the device is valid and it really contains an ext2/ext3/ext4 filesystem (and not swap or ufs or something else), then the superblock is corrupt, and you might try running e2fsck with an alternate superblock: e2fsck -b 8193 <device> or e2fsck -b 32768 <device>
Then I tried:
ubuntu@ubuntu:~$ sudo e2fsck -b 8193 /dev/sda e2fsck 1.42.9 (4-Feb-2014) e2fsck: Bad magic number in super-block while trying to open /dev/sda The superblock could not be read or does not describe a valid ext2/ext3/ext4 filesystem. If the device is valid and it really contains an ext2/ext3/ext4 filesystem (and not swap or ufs or something else), then the superblock is corrupt, and you might try running e2fsck with an alternate superblock: e2fsck -b 8193 <device> or e2fsck -b 32768 <device>
And:
ubuntu@ubuntu:~$ sudo e2fsck -b 32768 /dev/sda e2fsck 1.42.9 (4-Feb-2014) e2fsck: Bad magic number in super-block while trying to open /dev/sda The superblock could not be read or does not describe a valid ext2/ext3/ext4 filesystem. If the device is valid and it really contains an ext2/ext3/ext4 filesystem (and not swap or ufs or something else), then the superblock is corrupt, and you might try running e2fsck with an alternate superblock: e2fsck -b 8193 <device> or e2fsck -b 32768 <device>
I tried other things like:
ubuntu@ubuntu:~$ sudo grub-install --root-directory=/mnt /dev/sda Installing for i386-pc platform. grub-install: error: failed to get canonical path of `/cow'. ubuntu@ubuntu:~$ parted -l Warning: Unable to open /dev/sr0 read-write (Read-only file system). /dev/sr0 has been opened read-only. Error: Can't have a partition outside the disk!
I tried too something in the grub-rescue shell, like:
grub-rescue> ls (hd0)
Then I tried:
grub-rescue> ls (hd0)
And it said that the fylesystem is unknown, so I tried this (where n is any number between 1 and 8):
grub-rescue> ls (hd0,n)
Then I got there's not such partition, so I tried too:
grub-rescue> set prefix=(hd0)/boot/grub grub-rescue> set root=(hd0) grub-rescue> insmod (hd0)/boot/grub/i386-pc/linux.mod
Before I go on, I've stopped here because it says something about filesystem unknown (I tried too insmod (hd0)/boot/grub/linux.mod but didn't worked as well)
If I need solve this using windows I do can connect both hard drives and use the one with windows (puting it as priority at the BIOS).
Sorry if you don't understand something I said, I do not have a pretty good english... I tried to be as specific as possible... I really need those files, I was ready to format this hard drive, only finishing some stuff, I don't might if I loose the system, I just want those files.
Update:
I tried to mount the linux hard drive with Paragon ExtFS (a read and mount program for ext2, ext3, etc, hard driver) at Windows, but even there the HD wasn't mounting....
-
Germano Corrêa over 9 yearsAcctualy, I have two drives with windows and onde with linux (just pretend I had a good reason to do that). Let's say I have HD1 with windows, HD2 with windows and 3 with Ubuntu GNOME. Usually I just use the 1 and 3, the other is from another computer. So, I disconected the 1, so forget it. Using Ubuntu at HD3 I copy files from HD2 to the one with Ubuntu (3), disconected this last, formated the HD2 and them conected again Ubuntu. And then all I got was a problem :/
-
Germano Corrêa over 9 years@MarkWilliams I've formated using the Windows 7 CD...
-
Mark Williams over 9 yearsAccording to the fdisk output you posted above, you have only sda connected/detected - with no partitions. You now say you have HD2 & HD3 in the system; can you re-post the output of
sudo fdisk -l
now please? -
Germano Corrêa over 9 years@MarkWilliams The outpout it's the same thing as before... now I only got the linux hard drive conected (the HD3 I said before) that is this sda.... The HD1 and HD2 are Windows hard driver, but let's forget the 1 because I'm not using it. As I said, I formated the HD2 and now I need important files at HD3 (the one with linux)... I'm sorry if I'm not being clear.
-
-
Germano Corrêa over 9 yearsThanks for the help, I'll try to do what you said, but... You say recreate the partitions using a live cd? When you say "it's worth a try of recreating a single, default linux (83) partition in fdisk & see if it contains data..." if I do this and not follow the partition set up I'll lose something? Besides, I'll first try use foremost, thanks :D
-
Mark Williams over 9 yearsIf you use a live CD and start fdisk, & just create a single giant partition (type n & accept all the defaults) you won't overwrite any user data, so it's safe to start with that. If you are very lucky, you can save that with w, then just try remounting the 'new' partition - I have known that just work as if you never blanked it. If not, then it's foremost...
-
Germano Corrêa over 9 yearsDude, I created a single giant partition, and solved my problem :D Thank you man, I never thought it could do that :D
-
Mark Williams over 9 years:) Lucky man! Just FYI, fdisk affects the tables that tell the OS where bits of drive are; mkfs or whatever format actually put a directory structure on the drive, complete with empty file lists; as you hadn't actually done a format, you got away with it.