Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
You probably deleted the partition that had the /boot/grub/menu.lst that contains info that grub uses to boot up the OSes you have installed. If you want to totally remove grub, then boot from a windows startup disk and do "fdisk /mbr". If you still have linux installed and want to boot it you may have to use your distributions installation disk to chroot into the Linux root partition and try to recreate the /grub/menu.lst.
grub > root (hd0,?)
where hd? is the partion you installed linux kernel into
if you not sure try them all 0, 1, 2, etc ... until you get something that says ext2, ext3, or reiserfs detected.
grub > kernel /vmlinuz ro root=/dev/hda?
where hda? is most likely just whatever worked in the previous command + 1
by the way grub has tab completion so after "kernel /" ... hit tab .... so what your chooses are.
grub > boot
umm, linux is now booting!
Well, my copy of Partition Magic 8 is sitting in the Win98 subsection of this machine, where I can't check it to see if it's got some sort of partition recovery tool, but let me suggest this:
IF you just inadvertently deleted the partition without also actually destroying its contents with a shredding or zero-fill sort of action, and IF you happened to write down the precise boundaries of the deleted partition (if it was immediately adjacent to other partitions, you can probably deduce what the boundaries were from the listing provided by the "p" option of the Linux fdisk utility), AND if you know what sort of partition it was (probably ext3 and very likely "/boot," since grub doesn't even load), you just might try re-creating the partition with Linux fdisk. You can do that from the Linux Recovery option in your distribution software. If you figure out precisely what the partition parameters are, then you may be able to tell your system to look for a partition in this location. Then, if you're lucky and if nothing else has overwritten the contents of the deleted partition in the meantime -- I'd avoid all attempts to write to this disk until you have a chance to try out this solution -- you just might try to boot Linux again and find out that it works...
Something similar just worked for me. I'd screwed up my MBR, trying to add a really large partition on a really large drive and forgetting that the software I was using (not Partition Magic 8) wasn't smart enough to handle the situation. The drive was marked "BAD" by PM8, which refused to do anything with it. So I used Seagate software to zero out the MBR and then started recreating everything again, using exactly the same specs as before. This installation has more than 10 partitions and toward the end I defined several of them at once. In each case I'd restore a partition from a compressed image file backup, check it, and then go on to the next partition... so, having defined the last three partitions, I was checking the restore for the first one in the set and just on a whim took a look at the second one, too... and it was already restored even though I had not copied it back: the code hadn't changed, and defining the partition told the system where to look for it, so voila, once defined it was restored too...
These tips should give you a general sense of what this possible solution takes. They gloss over the precise steps they entail. Let me know if you need more specific advice.
Notes:
1. Remember that like any sort of partition creation, the machine will have to be restarted before the changes written to the disk's MBR can be recognized.
2. In this situation you do NOT want to re-create a Linux file system for the partition or to perform any other actions like formatting that could write to the space occupied by the lost partition. Keep in mind that the stuff IN the partition may still be there; the only thing that's missing is information in the drive's MBR that tells the system to look for a partition in this location.
3. I can see lots of possible reasons why the above approach might fail. Your message is short and so one doesn't know exactly what you were trying to do when you wiped out the partition, or what you have tried to do since. Still, there would seem to be a chance that you could recover without a reinstall.
4. Unless you've already used the machine a lot, so that there are a lot of user files in it, or you've put a lot of work into customization or additional software installations, then is reinstalling really all that much work? It might not be any worse than other alternatives.
Originally posted by chbin Or you can use the grub command line?
grub > root (hd0,?)
where hd? is the partion you installed linux kernel into
if you not sure try them all 0, 1, 2, etc ... until you get something that says ext2, ext3, or reiserfs detected.
grub > kernel /vmlinuz ro root=/dev/hda?
where hda? is most likely just whatever worked in the previous command + 1
by the way grub has tab completion so after "kernel /" ... hit tab .... so what your chooses are.
grub > boot
umm, linux is now booting!
i have tried all of the above, hda6 and hda7 are showing as ext2fs, partition type 0x83. When i try kernel/vmlinuz....etc i get "error 15: file nout found."
Is there anything else i can try without reinstalling? I had this problem before and had to reinstall, i would rather know how to fix it in case i have the same problem again. Plus i have files in my user dir that i don't want to lose.
Try the following at grub's prompt to find out where it is installed: 'find /boot/grub/stage1', This should return something like (hd0,0), which equates to hda1. If you say hda6/7 are ext2 you should get (hd0,5/6).
Next you can try the steps chbin enumerated or run 'setup'.
Just crank up a LiveCD - Knoppix is good.
Mount any partitions you can find and see if your data is there.
Otherwis have a look at the systemrescuecd - has a heap of recovery tools.
I've also heard good things about testdisk
Fast, and seems to do partition recovery well.
boot with the linux cd and press f5 .when you get shell prompt sh#: type the following commands there-
sh#: chroot /mnt/sysimage
sh#: grub -install /dev/hda
sh#:exit
sh#:exit
the system will reboot and grub screen will be restored.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.