LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Debian
User Name
Password
Debian This forum is for the discussion of Debian Linux.

Notices


Reply
  Search this Thread
Old 04-21-2007, 07:25 PM   #1
zoidburg016
LQ Newbie
 
Registered: Feb 2007
Distribution: Debian
Posts: 17

Rep: Reputation: 0
deleted /boot partition Need to reinstall kernel


I got a virus or something on my linux partition, so I had to reinstall windows, so I did. Then I realized that I had to reinstall grub, so I booted into knoppix and tried to run grub-install /dev/hda3. It didn't work, so I formated my /boot partition not thinking about the fact that my kernel is there. now I need to reinstall it, but i don't know how. I don't have a /usr/src/linux folder.

btw, I'm using a debian based knoppix hd install.
 
Old 04-21-2007, 07:33 PM   #2
Dutch Master
Senior Member
 
Registered: Dec 2005
Posts: 1,686

Rep: Reputation: 124Reputation: 124
A virus on your Linux system? Highly unlikely, but there's always the proverbial exception...

Anyway, did you try installing grub as root? (or with the sudo command, provided Knoppix has that. Don't know about that). If all fails, re-installation isn't that difficult, just save your data on the Knoppix system before re-installing.
 
Old 04-21-2007, 07:39 PM   #3
zoidburg016
LQ Newbie
 
Registered: Feb 2007
Distribution: Debian
Posts: 17

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by Dutch Master
A virus on your Linux system? Highly unlikely, but there's always the proverbial exception...

Anyway, did you try installing grub as root? (or with the sudo command, provided Knoppix has that. Don't know about that). If all fails, re-installation isn't that difficult, just save your data on the Knoppix system before re-installing.
Sorry, I meant I got a virus on my windows partition.
 
Old 04-21-2007, 08:40 PM   #4
zoidburg016
LQ Newbie
 
Registered: Feb 2007
Distribution: Debian
Posts: 17

Original Poster
Rep: Reputation: 0
I don't want to have to reinstall. Grub isn't really the big problem, the problem is I deleted my kernel. Does anyone know how to re install it?
 
Old 04-21-2007, 08:51 PM   #5
zoidburg016
LQ Newbie
 
Registered: Feb 2007
Distribution: Debian
Posts: 17

Original Poster
Rep: Reputation: 0
Is there any package that I can install that has the kernel?
 
Old 04-21-2007, 09:20 PM   #6
Daws
Member
 
Registered: May 2006
Location: UK
Distribution: Debian
Posts: 448

Rep: Reputation: 37
OK. This might work or might not. Boot up knoppix on Live cd.

Download the kernel image and the grub package (grub stores a lot of its files on /boot so you need to reinstall that too), assuming you have etch 4.0 you want linux-image-2.6.18-4-zzz and grub

As root:

Code:
mount -v /dev/hdax /mnt/tmp
chroot PATH=/bin:/sbin:/usr/bin:/usr/sbin /mnt/tmp
Where hdax is your Debian root (/) partition

From inside the chroot, mount all of your other partitions /boot,/var,/usr,/tmp etc. Make sure you have mounted them all.

apt will work if you want to set up an internet connection inside chroot, but we already have the debs. So install them with
Code:
dpkg -i package1 package2
Once that is done:

Code:
grub-install (hd0)
Then you can exit chroot and everything should be working nicely. (We need a fingers crossed smiley)
 
Old 04-21-2007, 09:25 PM   #7
Dutch Master
Senior Member
 
Registered: Dec 2005
Posts: 1,686

Rep: Reputation: 124Reputation: 124
Yes, open Synaptic and search for kernel or linux as keywords. Either one will give you a suitable kernel. But, that's not all! You also need the tools for making an initrd image and you'll need to make the /boot dir again. I think, given your inexperience, that re-installing Knoppix would be wiser and less time-consuming. It might not be the answer you're looking for because you don't learn anything from that, but for something complicated as this you lack the skills to do it properly. Over time you'll acquire those skills, but for now you're better of as a regular user IMHO.

<edit>@Daws: he's using Knoppix on his harddrive, so no Etch.</edit>

Last edited by Dutch Master; 04-21-2007 at 09:26 PM.
 
Old 04-21-2007, 09:27 PM   #8
zoidburg016
LQ Newbie
 
Registered: Feb 2007
Distribution: Debian
Posts: 17

Original Poster
Rep: Reputation: 0
where do I download the kernel?
 
Old 04-21-2007, 09:30 PM   #9
Daws
Member
 
Registered: May 2006
Location: UK
Distribution: Debian
Posts: 448

Rep: Reputation: 37
Quote:
Daws: he's using Knoppix on his harddrive, so no Etch.
Oh yeah, well same procedure just different packages to download. Or he could just reinstall... (boooring)

EDIT:
Quote:
You also need the tools for making an initrd image
I didn't mention that because dpkg should automatically handle that. If its just /boot that was wiped then the rest of the system is still intact, initramfs/yaird/? included.

Last edited by Daws; 04-21-2007 at 09:36 PM.
 
Old 04-21-2007, 09:43 PM   #10
Quakeboy02
Senior Member
 
Registered: Nov 2006
Distribution: Debian Squeeze 2.6.32.9 SMP AMD64
Posts: 3,333

Rep: Reputation: 126Reputation: 126
Oh come on Dutch Master, he'll learn a lot and maybe have a bit of fun fixing this!

Here are a few things that you may have to do get all the way there if there's not enough in Daws' post.

From a knoppix terminal:
Code:
su
mount /dev/hda1 /mnt   (or hda2 or whatever)
mount --bind /dev /mnt/dev
mount -t proc proc /mnt/proc
mount -t sysfs sysfs /mnt/sys
chroot /mnt
mkdir /boot
cd /var/cache/apt/archives
Install the linux-image you want with dpkg -i as per Daws post.
Install grub and run grub-install (hd0) as per Daws.
You may also need to install initramfs-tools and run "update-initramfs -u -k all".

And let us know on either success or failure. I haven't had to do quite what you're doing, but I've done stuff kinda close, so let us know what works!
 
Old 04-21-2007, 10:00 PM   #11
zoidburg016
LQ Newbie
 
Registered: Feb 2007
Distribution: Debian
Posts: 17

Original Poster
Rep: Reputation: 0
okay, I'm not sure if this has worked yet, but what I did was
mount /dev/hda2 /mnt/root
mount /dev/hda4 /mnt/root/boot
mount -t proc none /mnt/root/proc
chroot /mnt/root
apt-get install linux-image-2.6.18-4-386
apt-get install grub

right now it says it's generating menu.lst, but it's been doing it for a while.

Last edited by zoidburg016; 04-21-2007 at 10:01 PM.
 
Old 04-22-2007, 02:50 AM   #12
BillyGalbreath
Member
 
Registered: Nov 2005
Location: Houston Texas
Distribution: Debian Sid
Posts: 379

Rep: Reputation: 31
This has an easy easy solution. If the only thing you lost was your /boot partition then you are perfectly safe. The /boot partition actually does not hold your kernel, just some vital information about the kernel needed to boot. Your actual kernel is located in /lib/modules/2.6.x - And you should have a .deb package containing your custom kernel in the /usr/src dir. If not, you can download a stock kernel from http://packages.debian.org

1) bootup using the knoppix livecd

2) As Daws said:
Quote:
Originally Posted by Daws
Code:
mount -v /dev/hdax /mnt/tmp
chroot PATH=/bin:/sbin:/usr/bin:/usr/sbin /mnt/tmp
Where hdax is your Debian root (/) partition

From inside the chroot, mount all of your other partitions /boot,/var,/usr,/tmp etc. Make sure you have mounted them all.
What this does is put you in your real installation (as if you never booted from the livecd). Make sure /mnt/tmp exists (mkdir /mnt/tmp).

3) Run grub-install
Code:
grub-install (hd0)
This will build your default grub again inside /boot and it will install the grub image to MBR of hd0 overwriting the Windows mbr.

4) Install your kernel again from the .deb (either the custom one you built in the past, or a new stock from http://packages.debian.org). This step will fill up the /boot partition again with your kernel information and automagically update grub for you.

5) Reboot and take out the livecd to boot to your real system.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Kernel Deleted due to Upgrade, Cannot Reinstall Kernel due to Dependency Issues Kenji Miyamoto Debian 2 02-17-2007 10:44 AM
Deleted linux partition, how to boot Windows partition? mysak Linux - General 3 12-14-2005 05:22 PM
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 05:53 PM
accidently deleted /boot partition :( aditya_ic Linux - General 7 07-29-2004 03:37 AM
Deleted XP partition - Can't boot linux mansonmuni Linux - Hardware 6 12-26-2003 12:18 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Debian

All times are GMT -5. The time now is 10:14 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration