Oops I killed my GRUB ...
Did you know that ...
So on my hard drive, I originally had a windows partition (from my original windows xp tablet pc edition), a linux partition (formatted ext3fs for my ubuntu installation), and a 3 GB linux-swap partition. I suddenly decided over the weekend that I wanted to make a vmware image of my windows partition (since that's the virtual machine program used in this tutorial).
However, VMware converter required 12mb, and I didn't have that much space left on my windows partition. So, I went and made an image of my mom's tablet computer, then backed up everthing I wanted to keep from my windows partition and then proceded to use GParted to delete the windows partition.
Now, I couldn't just leave all that space gaping there, right? So I tried to move my linux partition foward on the drive, but of course, GParted said "no!" So, I copied my hd2 (then linux partition) foward, then deleted the original hd2, then expanded both my original swap partition and my new linux partition. So here's a diagram to help you visualize:
| | hd1 - windows | | | hd2 - linux | | | hd3 - swap | | |
| | hd1 - linux (copy of old one) | | | hd2 - swap | | |
Now, I happily rebooted my hard computer, eager to install that huge virtual machine so I can used windows under linux. However, now my grub file is messed up! After trying the Super Grub Disk (which didn't help at all - it only had confusing menus and awful options that went around and around in a voyage circulaire), I eventually booted into a Ubuntu Edgy live cd, ready to (sigh) reinstall my entire system. However, when the time came to reformat my hard drive, I refused to give up! I prodded around, sudo nano'ed /boot/grub/menu.lst (after backing up, of course), yet still I couldn't get it. Eventually, I found the solution in the man pages (ah ... the good old Linux Programmer's Manual Pages ... ) under update-grub. So here's the entire code for what I did ... hope it helps anyone else with this problem :)
sudo bashdouble check to make sure it looks like / on your original linux ... if now, then something's wrong and you might need a reinstall :'(
enter root password here
mkdir /media/linux
mount /dev/hda1 /media/linux
chroot /media/linux
dir
dir /boot/grub/backup your current menu.lst ... it may not work, but it's still better than trying to write your own from scratch :)
cp /boot/grub/menu.lst /boot/grub/menu.lstyou might want to remove anything else that says menu.lst or similar ... not tested, so be careful ... better to back them up first, then remove
rm /boot/grub/menu.lst
update-grubwhen it asks you if you really want to make one, say yes ... there might be some other options I'm missing here, feel free to ask questions in the comments
update-grubthe first run generates the menu.lst file ... the second run configures it according to default settings
reboot
Now my computer works perfectly, with no glitches, and I've even managed to keep my tweakings to GRUB that I originally had without redoing all those tweaks! Apparently, update-grub was smart enough to figure out and keep my original GRUB settings. Yeah! ^_^
Thanks to Zach for telling me about chroot!
Well, now you know!
No comments:
Post a Comment