LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 03-08-2007, 12:37 PM   #16
abibibo
LQ Newbie
 
Registered: Feb 2007
Location: Ontario, CA
Distribution: Ubuntu 8.04, FC9
Posts: 25

Original Poster
Rep: Reputation: 15

justsimran,
No need to apologize. My linux knowledge is pretty basic so I appreciate all the help I can get.

As far as waiting--its stable, its linux--unless I do something else stupid to crash the system I'll gladly wait days for a clean, sure way of fixing the MBR before rebooting this machine.

Good point on the patch. I better download it now while I got network access.

Thanks again.

Darren
 
Old 03-08-2007, 12:47 PM   #17
justsimran
Member
 
Registered: Mar 2007
Location: Aus
Distribution: RHEL-4,5,UBUNTU,SUSE,FEDORA-6,7
Posts: 109

Rep: Reputation: 15
thats cool Darren, hope everything works out for you!!
All the best!
I will also make sure i get enough material for fedora's problem
Simran
 
Old 03-08-2007, 09:49 PM   #18
Quakeboy02
Senior Member
 
Registered: Nov 2006
Distribution: Debian Linux 11 (Bullseye)
Posts: 3,407

Rep: Reputation: 141Reputation: 141
As a reminder, syg00, a member with almost 2700 posts, has already given you good advice. Running around in a circle, panicking and trying to get a consensus of advice from other new Linux users isn't likely to get you a better, more reliable solution.

Your partition table is lost. It's a nuisance, but if your data was on /dev/hda1, then this is little more than a nuisance. All is NOT lost if you can't get your MBR restored. All you need is to boot from a liveCD to be able to carry on. The important thing is that you do nothing to make the situation worse. IOW, do not do anything that affects any sector other than sector 0. Reread syg00's post, look up testdisk on the net and get an understanding of what it does. Don't assume that just because you develop a rapport with other users that their advice is better than someone else's.
 
Old 03-09-2007, 02:50 AM   #19
abibibo
LQ Newbie
 
Registered: Feb 2007
Location: Ontario, CA
Distribution: Ubuntu 8.04, FC9
Posts: 25

Original Poster
Rep: Reputation: 15
I certainly appreciate everyone who has given me advice, though with my limited knowledge the testdisk utility presently seems to be getting me closer to my goal. So for now, back to my questions in post #8.

Letting testdisk analyze the partition structure I get:
Code:
Results
   * HPFS - NTFS              0   1  1  7831 254 63  125821017
     NTFS, 64 GB / 59 GiB
   P Linux                 7832   0  1  7863 254 63     514080 [/boot]
     EXT3 Sparse superblock, 263 MB / 251 MiB
   L Linux                31046   1  1 31077 254 63     514017 [/boot]
     EXT3 Sparse superblock, 263 MB / 250 MiB
   L Linux LVM            31078   1  1 38911 254 63  125853147
     LVM2, 64 GB / 60 GiB
Two concerns with this screen. 1. The NTFS is set as boot (*). I assume I need to switch this to primary and make the linux primary the boot partition? (btw. I know how to do it, but am unsure if i should). 2. There is also a large FAT32 shared between OS's. This doesnt show up on this screen, but when I press continue it is on the next screen as the extended:
Code:
Disk /dev/hda - 320 GB / 298 GiB - CHS 38913 255 63

     Partition                  Start        End    Size in sectors
 1 * HPFS - NTFS              0   1  1  7831 254 63  125821017
 2 P Linux                 7832   0  1  7863 254 63     514080 [/boot]
 3 E extended LBA         31046   0  1 38911 254 63  126367290
 5 L Linux                31046   1  1 31077 254 63     514017 [/boot]
 6 L Linux LVM            31078   1  1 38911 254 63  125853147

[  Quit  ]  [Search! ]  [ Write  ]  [Extd Part]
                              Return to main menu
If I select [Extd Part] its size appears to be what I remember it as. However, after reading the testdisk documentation I'm still not sure why it doesn't show up as a FAT32. Do I need to edit this?

Now for an update. On the last screen I pressed [Search!] to do a more thorough examination. Result:
Code:
Disk /dev/hda - 320 GB / 298 GiB - CHS 38913 255 63
     Partition               Start        End    Size in sectors
D HPFS - NTFS              0   1  1  6526 254 63  104856192
D HPFS - NTFS              0   1  1  7831 254 63  125821017
D Linux                 7832   0  1  7863 254 63     514080 [/boot]
D FAT32 LBA             7832   1  1 31045 254 63  372932847
L Linux                31046   1  1 31077 254 63     514017 [/boot]
L Linux LVM            31078   1  1 38911 254 63  125853147

Structure: Ok.  Use Up/Down Arrow keys to select partition.
Use Left/Right Arrow keys to CHANGE partition characteristics:
*=Primary bootable  P=Primary  L=Logical  E=Extended  D=Deleted
Keys A: add partition, L: load backup, T: change type, P: list files,
     Enter: to continue
NTFS, 64 GB / 59 GiB
file list for first partition unreadable. Second seems correct. 3rd (linux) damaged--probably from previous install. 4th (Fat32) correct file listing of my shared drive. 5th (linux) file list good. 6th--no option to list files. So, I'm still somewhat unsure how to proceed. Seems like I should load backup of the 2nd NTFs and of the 4th (Fat32). As it is If i press continue without loading backups I get:

Code:
Disk /dev/hda - 320 GB / 298 GiB - CHS 38913 255 63

     Partition                  Start        End    Size in sectors
 1 E extended LBA         31046   0  1 38911 254 63  126367290
 5 L Linux                31046   1  1 31077 254 63     514017 [/boot]
 6 L Linux LVM            31078   1  1 38911 254 63  125853147


[  Quit  ]  [ Write  ]  [Extd Part]
                       Write partition structure to disk
which definitely isn't correct.

Once the partition table is correct, with /boot set as * bootable I plan on writing the partition table and then using grub to write the MBR.

Anyone got any input?

Thanks,
D
 
Old 03-09-2007, 06:34 AM   #20
justsimran
Member
 
Registered: Mar 2007
Location: Aus
Distribution: RHEL-4,5,UBUNTU,SUSE,FEDORA-6,7
Posts: 109

Rep: Reputation: 15
Quote:
Originally Posted by Quakeboy02
As a reminder, syg00, a member with almost 2700 posts, has already given you good advice. Running around in a circle, panicking and trying to get a consensus of advice from other new Linux users isn't likely to get you a better, more reliable solution.

Your partition table is lost. It's a nuisance, but if your data was on /dev/hda1, then this is little more than a nuisance. All is NOT lost if you can't get your MBR restored. All you need is to boot from a liveCD to be able to carry on. The important thing is that you do nothing to make the situation worse. IOW, do not do anything that affects any sector other than sector 0. Reread syg00's post, look up testdisk on the net and get an understanding of what it does. Don't assume that just because you develop a rapport with other users that their advice is better than someone else's.
Hello Quakeboy

I appriciate your advice you have given,, but if you have forgotten this forum is there to help people using linux and having problems in it,,instead of saying about "NEW USERS",, i guess everyone always make a new start in this forum
If someone has 2500 posts that means he is in this forum for quite a long time,, i want you to please double check your words (the words on net)


thanks
 
Old 03-09-2007, 07:52 AM   #21
abibibo
LQ Newbie
 
Registered: Feb 2007
Location: Ontario, CA
Distribution: Ubuntu 8.04, FC9
Posts: 25

Original Poster
Rep: Reputation: 15
Allright. I decided to move forward and wrote the partition table with testdisk, changing the linux (primary, not logical) partition to the active partition.

Although I still haven't rebooted, i ran fdisk and get the following partition table:
Code:
Command (m for help): p

Disk /dev/hda: 320.0 GB, 320072933376 bytes
255 heads, 63 sectors/track, 38913 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/hda1               1        7832    62910508+   7  HPFS/NTFS
/dev/hda2   *        7833        7864      257040   83  Linux
/dev/hda3            7865       38913   249401092+   f  W95 Ext'd (LBA)
/dev/hda5           31047       31078      257008+  83  Linux
/dev/hda6           31079       38912    62926573+  8e  Linux LVM
while the partition numbering is different than what /proc/partitions was previously (see post #8), the content seems the same.

Now, trying to setup up grub and rewrite the MBR I do:
Code:
grub> root (hd0,1)
 Filesystem type is ext2fs, partition type 0x83

grub> setup (hd0)
 Checking if "/boot/grub/stage1" exists... no
 Checking if "/grub/stage1" exists... no

Error 2: Bad file or directory type

grub> find /boot/grub/stage1

Error 15: File not found
however, I can see /boot/grub/stage1 from a file browser (though it is not a "english" textfile when i open it).

So, how do I point grub to this file or otherwise correctly rewrite the MBR?

Thanks again!
 
Old 03-09-2007, 08:01 AM   #22
justsimran
Member
 
Registered: Mar 2007
Location: Aus
Distribution: RHEL-4,5,UBUNTU,SUSE,FEDORA-6,7
Posts: 109

Rep: Reputation: 15
Quote:
Originally Posted by abibibo
Allright. I decided to move forward and wrote the partition table with testdisk, changing the linux (primary, not logical) partition to the active partition.

Although I still haven't rebooted, i ran fdisk and get the following partition table:
Code:
Command (m for help): p

Disk /dev/hda: 320.0 GB, 320072933376 bytes
255 heads, 63 sectors/track, 38913 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/hda1               1        7832    62910508+   7  HPFS/NTFS
/dev/hda2   *        7833        7864      257040   83  Linux
/dev/hda3            7865       38913   249401092+   f  W95 Ext'd (LBA)
/dev/hda5           31047       31078      257008+  83  Linux
/dev/hda6           31079       38912    62926573+  8e  Linux LVM
while the partition numbering is different than what /proc/partitions was previously (see post #8), the content seems the same.

Now, trying to setup up grub and rewrite the MBR I do:
Code:
grub> root (hd0,1)
 Filesystem type is ext2fs, partition type 0x83

grub> setup (hd0)
 Checking if "/boot/grub/stage1" exists... no
 Checking if "/grub/stage1" exists... no

Error 2: Bad file or directory type

grub> find /boot/grub/stage1

Error 15: File not found
however, I can see /boot/grub/stage1 from a file browser (though it is not a "english" textfile when i open it).

So, how do I point grub to this file or otherwise correctly rewrite the MBR?

Thanks again!
how did you find root(hd0,1)

did you run this command: find /grub/stage1 <---
 
Old 03-09-2007, 08:12 AM   #23
abibibo
LQ Newbie
 
Registered: Feb 2007
Location: Ontario, CA
Distribution: Ubuntu 8.04, FC9
Posts: 25

Original Poster
Rep: Reputation: 15
choosing root(hd0,1) was based off fdisk's showing hda2 as the active partition. However, good point on ommiting /boot/ from the find command. This found it on hda5 (the linux logical partition). Install now seems atleast partially successfull:
Code:
grub> find /grub/stage1
 (hd0,4)

grub> root (hd0,4)
 Filesystem type is ext2fs, partition type 0x83

grub> setup (hd0,4)
 Checking if "/boot/grub/stage1" exists... no
 Checking if "/grub/stage1" exists... yes
 Checking if "/grub/stage2" exists... yes
 Checking if "/grub/e2fs_stage1_5" exists... yes
 Running "embed /grub/e2fs_stage1_5 (hd0,4)"... failed (this is not fatal)
 Running "embed /grub/e2fs_stage1_5 (hd0,4)"... failed (this is not fatal)
 Running "install /grub/stage1 (hd0,4) /grub/stage2 p /grub/grub.conf "... succ
eeded
Done.
Two things: Do I need to worry about the non-fatal errors? Do I need to switch hda5 to the active partition using testdisk(not actually sure if this is possible since it is a logical partition)?

If No to both of the above--I'm I good to go on rebooting the system?

Thanks for getting back so fast.

D
 
Old 03-09-2007, 08:25 AM   #24
justsimran
Member
 
Registered: Mar 2007
Location: Aus
Distribution: RHEL-4,5,UBUNTU,SUSE,FEDORA-6,7
Posts: 109

Rep: Reputation: 15
Quote:
Originally Posted by abibibo
choosing root(hd0,1) was based off fdisk's showing hda2 as the active partition. However, good point on ommiting /boot/ from the find command. This found it on hda5 (the linux logical partition). Install now seems atleast partially successfull:
Code:
grub> find /grub/stage1
 (hd0,4)

grub> root (hd0,4)
 Filesystem type is ext2fs, partition type 0x83

grub> setup (hd0,4)
 Checking if "/boot/grub/stage1" exists... no
 Checking if "/grub/stage1" exists... yes
 Checking if "/grub/stage2" exists... yes
 Checking if "/grub/e2fs_stage1_5" exists... yes
 Running "embed /grub/e2fs_stage1_5 (hd0,4)"... failed (this is not fatal)
 Running "embed /grub/e2fs_stage1_5 (hd0,4)"... failed (this is not fatal)
 Running "install /grub/stage1 (hd0,4) /grub/stage2 p /grub/grub.conf "... succ
eeded
Done.
Two things: Do I need to worry about the non-fatal errors? Do I need to switch hda5 to the active partition using testdisk(not actually sure if this is possible since it is a logical partition)?

If No to both of the above--I'm I good to go on rebooting the system?

Thanks for getting back so fast.



D
I ran the same command ,, can u do one thing for me again!!

do like this
root (hd0,4)
setup (hd0) (no 4)

and can u shw me the screen again,,
i ran the same command on my machine thts why

ta
 
Old 03-09-2007, 08:29 AM   #25
Gethyn
Member
 
Registered: Aug 2003
Location: UK
Distribution: (X)Ubuntu 10.04/10.10, Debian 5, CentOS 5
Posts: 900

Rep: Reputation: 32
I'm getting a little lost in what you're trying to do here. The bootable flag should be set on your Windows system partition. The Linux boot partition should not be set bootable. Only one partition on a drive should be set bootable according to the DOS boot specification. Linux does not require it, only Windows.

As Quakeboy02 says, reinstalling grub is not too important at this point. Have you tried these commands?
Code:
root@host # grub-install --recheck /dev/hda
root@host # grub-install /dev/hda
If grub is not correctly installed you'll still be able to boot using another method. Making sure the partition table is fixed is the important thing. It's worth making a grub floppy, if you have a floppy drive, which can help you in future situations like these.
 
Old 03-09-2007, 08:33 AM   #26
justsimran
Member
 
Registered: Mar 2007
Location: Aus
Distribution: RHEL-4,5,UBUNTU,SUSE,FEDORA-6,7
Posts: 109

Rep: Reputation: 15
Quote:
Originally Posted by Gethyn
I'm getting a little lost in what you're trying to do here. The bootable flag should be set on your Windows system partition. The Linux boot partition should not be set bootable. Only one partition on a drive should be set bootable according to the DOS boot specification. Linux does not require it, only Windows.

As Quakeboy02 says, reinstalling grub is not too important at this point. Have you tried these commands?
Code:
root@host # grub-install --recheck /dev/hda
root@host # grub-install /dev/hda
If grub is not correctly installed you'll still be able to boot using another method. Making sure the partition table is fixed is the important thing. It's worth making a grub floppy, if you have a floppy drive, which can help you in future situations like these.
well sometimes grub-install do not work,, its always gud to use setup(hd0) so tht it recoganises it
well it happened to me today when i was installing grub ,, grub-install didnt work
so the other option was to use setup (hd0),, no harm using it

he can use grub-install later on,, using rescue disk,,
 
Old 03-09-2007, 09:22 AM   #27
jiml8
Senior Member
 
Registered: Sep 2003
Posts: 3,171

Rep: Reputation: 116Reputation: 116
You are making excellent progress for a beginner.

To find your system and boot partitions, given that you can't sort it out from the information you have, you might just want to take the time to mount each partition (even if it is already mounted) then browse into it and see what is there.

To do this, create a directory tstmnt someplace convenient, then as root issue the mount command something like this:

mount /dev/hda2 tstmnt

Then just cd into tstmnt and see what is there. If this isn't it, just cd out, unmount it, and try again on the next partition.
 
Old 03-09-2007, 09:59 AM   #28
abibibo
LQ Newbie
 
Registered: Feb 2007
Location: Ontario, CA
Distribution: Ubuntu 8.04, FC9
Posts: 25

Original Poster
Rep: Reputation: 15
Changed active partition to the NTFS.

So I was hoping everything was good to reboot, but running grub recheck as Gethyn suggested tells me /boot/grub/stage1 not read correctly. Trying to install grub using the grub-install method gives me the same error. A little web searching shows this is usually that grub.conf is pointing to the wrong location, however, I don't even have grub.conf in /boot/grub.

Jiml8, I tried to test mount the devices, but I think it is still using my old partition table since I haven't yet rebooted. Specifically,
Code:
[root@link driedlin]# mount -t ext2 /dev/hda5 tstmnt
mount: /dev/hda5 already mounted or tstmnt busy
mount: according to mtab, /dev/hda5 is mounted on /share
/share was the name of my old FAT32 partition shared between OS's.

So, maybe all I need to do is reboot? Just a little nervous as i won't have an internet from the live CD.

So, should I go for it? Of course I'm certainly not going to blame anyone if I have to go to a school computer to get more help.

Thanks,
D

Last edited by abibibo; 03-09-2007 at 10:00 AM.
 
Old 03-09-2007, 10:03 AM   #29
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,128

Rep: Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121
I hope you took those backups.
That partition table you wrote doesn't appear to correspond to the /proc/partitions you posted earlier.
I'm guessing that it should look something like
Code:
/dev/hda1   *           1        7832    62910508+   7  HPFS/NTFS
/dev/hda2            7833       38913   249401092+   f  W95 Ext'd (LBA)
/dev/hda5            7833       31046   186466423+   b  W95 FAT32
/dev/hda6           31047       31078      257008+  83  Linux
/dev/hda7           31079       38912    62926573+  8e  Linux LVM
(the fat32 might be 'c' instead of 'b').
The important thing is the cylinder addresses - the sector count can vary (a few) depending on alignment (hence the + sign) - you don't enter those.
Writing the partition table wrongly is, of itself, no big deal - you can always re-write it to correct it. Updating data in one of the "bad" partitions is a no-no.
Fortunately it sounds like you failed on the first update to the primary Linux (which shouldn't be there).
I'd say you could probably boot, but there will be issues.

Personally I'd try my version of the partition table - but I'm not doing the updates, you have to make that call.
And of course, I always have (at least) *2* good backups of everything before I screw around with partition tables.

All of us are here just trying to help each other.
Post count is no indicator of the merit of the poster - accept anything offered, but decide for yourself what is useful, and what may not be.

Edit: Partition numbers were wrong.
Also noticed our posts crossed in flight - more to come.

Last edited by syg00; 03-09-2007 at 10:07 AM.
 
Old 03-09-2007, 10:03 AM   #30
abibibo
LQ Newbie
 
Registered: Feb 2007
Location: Ontario, CA
Distribution: Ubuntu 8.04, FC9
Posts: 25

Original Poster
Rep: Reputation: 15
Also, realized grub.conf is in /etc , but it is only a broken link
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
MBR deleted,how to rewrite GRUB in it? jasdeep_js Red Hat 1 08-03-2006 12:38 AM
MBR deleted now what? greythorne SUSE / openSUSE 2 05-11-2005 08:48 AM
MBR deleted - I need to reinstall LILO without reinstalling Debian chaca1983 Linux - Software 12 03-26-2005 10:06 AM
deleted linux partition adn the boot loader was deleted also,now i have only gnu grub boris199 Linux - Laptop and Netbook 2 01-29-2005 04:53 PM
What if your MBR (grep) is deleted by xp during install and no boot disk available? FocusedWolf Linux - Newbie 8 05-05-2004 10:12 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 06:32 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration