LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 02-25-2006, 02:38 PM   #1
Tiggs
LQ Newbie
 
Registered: Sep 2004
Posts: 6

Rep: Reputation: 0
I nuked my /boot partition and I'd like it back please


Running Fedora Core 4 on a P4 box. I needed to back up the contents of one server (bsdboxer) to another (johnny5), so I decided to send a tar of a folder across SSH. I however, am a complete idiot, and dumped from the man pages of tar, I did this:

Code:
tar cvfb - 20 stuff/ | ssh johnny5 dd of=/dev/hda1 obs=20b
Hells yeah, I over wrote my boot parititon! ...

So, there's nothing in /boot now. I tried the advertised "Fedora rescue disk", typed in "linux rescue", was dumped to a terminal, and attempted to see if the drives were still there. An fdisk -l shows that the partitions are still intact, and the /mnt/sysimage still shows the contents of my drive which is great. However, if I try to "chroot /mnt/sysimage", the drives disappear, and I can't even begin to attempt to reinstall the GRUB loader.

Rebooting and praying that Knoppix could fix the the day, I wind up at in the face of a terminal and some very mean results.

1. I can see the devices when I do an fdisk -l. The parititions are there and happy, with the /dev/hda1 still being a boot partition, and /dev/hda2 still with the rest of the file system on it.
2. I can't mount either /dev/hda1 or /dev/hda2 to /mnt/hda1 or /mnt/hda2. Something about a wonky magic number error.
3. gpart /dev/hda1 doesn't quite work either. It hangs for a few minutes and I just smash my head on the coffee table a couple of times for the amount of stupidity I've done.
4. I can't do a reinstall of GRUB, well, because GRUB or any other program other than fdisk can't see the partitions.

Basically, what I'm asking is if there's anyway for me to fix the MBR and the partition table without having to kill the entire drive. Thanks.
 
Old 02-25-2006, 02:56 PM   #2
Tiggs
LQ Newbie
 
Registered: Sep 2004
Posts: 6

Original Poster
Rep: Reputation: 0
Breaking news: I tried an fdisk /dev/hda1 (where the boot partition was)
Code:
root@0[/]# fdisk /dev/hda1
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that, of course, the previous
content won't be recoverable.

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

Command (m for help):
Should I write the changes? I'm really lost here.
 
Old 02-25-2006, 03:08 PM   #3
jomen
Senior Member
 
Registered: May 2004
Location: Leipzig/Germany
Distribution: Arch
Posts: 1,687

Rep: Reputation: 55
you need to do:
fdisk /dev/hda
not fdisk /dev/hda1 - this will and can not work!
 
Old 02-25-2006, 03:10 PM   #4
jomen
Senior Member
 
Registered: May 2004
Location: Leipzig/Germany
Distribution: Arch
Posts: 1,687

Rep: Reputation: 55
...but probably everything is ok. - just grub needs to be reinstalled (make a filesystem first...) and your kernel-image copied to /boot
 
Old 02-25-2006, 03:25 PM   #5
Tiggs
LQ Newbie
 
Registered: Sep 2004
Posts: 6

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by jomen
you need to do: fdisk /dev/hda not fdisk /dev/hda1 - this will and can not work!
Code:
root@0[knoppix]# fdisk /dev/hda

The number of cylinders for this disk is set to 9729.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
   (e.g., DOS FDISK, OS/2 FDISK)

Command (m for help): p

Disk /dev/hda: 80.0 GB, 80026361856 bytes
255 heads, 63 sectors/track, 9729 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/hda1   *           1          13      104391   83  Linux
/dev/hda2              14        9729    78043770   8e  Linux LVM

Command (m for help):
Okay, what do I do from here?

Last edited by Tiggs; 02-25-2006 at 03:27 PM.
 
Old 02-25-2006, 04:11 PM   #6
jomen
Senior Member
 
Registered: May 2004
Location: Leipzig/Germany
Distribution: Arch
Posts: 1,687

Rep: Reputation: 55
The partition is still there - as was to be expected by looking on what command you gave.
Don't do anything - apart from quitting fdisk without writing to the disk (hit "q").
You tried to mount your partitions from knoppix?
/dev/hda2 should be untouched - knoppix might not know how to mount the partition because it is a RAID
It is, right?
But I'm not sure here because I never have used RAID before.
But I think it is safe to assume that this did not get changed since you wrote to /dev/hda1.

/dev/hda1 will need a new filesystem on it - dd writes directly to the device without going through the filesystem - so that is messed up probably and its contents are deleted anyway.
Look into your /etc/fstab - if you can - for what it WAS when it existed...
mkfs.ext2 /dev/hda1 should do the trick - if there was ext2 on it before - which is likely as no journalling filesystem makes sense to have on a partition with just /boot on it

Last edited by jomen; 02-25-2006 at 04:15 PM.
 
Old 02-25-2006, 04:20 PM   #7
Tiggs
LQ Newbie
 
Registered: Sep 2004
Posts: 6

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by jomen
The partition is still there - as was to be expected by looking on what command you gave.
Don't do anything - apart from quitting fdisk without writing to the disk (hit "q").
You tried to mount your partitions from knoppix?
/dev/hda2 should be untouched - knoppix might not know how to mount the partition because it is a RAID
It is, right?
But I'm not sure here because I never have used RAID before.
But I think it is safe to assume that this did not get changed since you wrote to /dev/hda1.

/dev/hda1 will need a new filesystem on it - dd writes directly to the device without going through the filesystem - so that is messed up probably and its contents are deleted anyway.
Look into your /etc/fstab - if you can - for what it WAS when it existed...
mkfs.ext2 /dev/hda1 should do the trick - if there was ext2 on it before - which is likely as no journalling filesystem makes sense to have on a partition with just /boot on it
/dev/hda2 is actually the OS partition. There is a RAID on the box but its a logical drive and it's the only thing that shows up when I attempt to use the Fedora Rescue Disk. /dev/hda1 was the boot partition. I just wiped it with the mkfs.ext2 /dev/hda1 command, and I'm now trying to install GRUB on it, but I'm getting this:

root@1[/]# chroot /mnt/hda1
chroot: cannot run command `/bin/bash': No such file or director

?
 
Old 02-25-2006, 04:49 PM   #8
jomen
Senior Member
 
Registered: May 2004
Location: Leipzig/Germany
Distribution: Arch
Posts: 1,687

Rep: Reputation: 55
If you want (or need) to chroot you will need to find a way to get your system mounted.
(I mean / and everything under it - with the exeption of /boot - which is on /dev/hda1)
Then you mount /dev/hda1 to /boot
Then you can chroot...
You try to chroot to /dev/hda1 - but there is _nothing_ on it! The whole system is on /dev/hda2 - or on the RAID...you need to get that mounted and then /dev/hda1 to it - as I said...

If /dev/hda2 is your OS partition:
mount /dev/hda2 to /somewhere
mount /dev/hda1 to /somewhere/boot
then chroot /somewhere

Last edited by jomen; 02-25-2006 at 04:51 PM.
 
Old 02-25-2006, 05:18 PM   #9
Tiggs
LQ Newbie
 
Registered: Sep 2004
Posts: 6

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by jomen
If /dev/hda2 is your OS partition:
mount /dev/hda2 to /somewhere
I can't mount /dev/hda2. It's running into the same problem as I had with /dev/hda1, before I reformatted hda1.
 
Old 02-25-2006, 05:28 PM   #10
jomen
Senior Member
 
Registered: May 2004
Location: Leipzig/Germany
Distribution: Arch
Posts: 1,687

Rep: Reputation: 55
/dev/hda2 is not a RAID? And you can not mount it?
What command did you use? What error did you get? From where were you running the command?
 
Old 02-25-2006, 05:29 PM   #11
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,120

Rep: Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120
I don't know FC, but it should do the chroot - maybe it needs the initrd for the LVM support.

Me, I always use Knoppix - can you explain the errors better ???. It should put you in X, not a terminal/console - also remember it always mounts the disks R/O; just remount them.

And recreating /boot/grub is only half the job - you'll still need the kernel image, initrd, System.map ...
 
Old 02-25-2006, 05:39 PM   #12
jomen
Senior Member
 
Registered: May 2004
Location: Leipzig/Germany
Distribution: Arch
Posts: 1,687

Rep: Reputation: 55
Just the kernel-image will do and that should be still there - if he/she compiled a custom kernel - or does Fedora always use an initrd? System map not needed - as far as I know only in lilo.
 
  


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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Nuked HDD - Can I get the files back? Nige Linux - General 2 09-11-2005 10:43 PM
Debian NUKED my Slackware partition UltimaGuy Debian 8 12-05-2004 12:59 PM
Setting active partition back to /boot after XP reinstall fordsm Linux - General 3 04-28-2004 10:45 AM
I just nuked /etc cpeppler Linux - Software 28 03-18-2004 09:27 AM
how to remove dual boot and get back my partition ? netkepala Linux - Software 1 09-30-2003 11:20 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 08:09 AM.

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