LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   repair linux (https://www.linuxquestions.org/questions/linux-newbie-8/repair-linux-887104/)

elishac 06-18-2011 05:30 PM

repair linux
 
hello,

while I was using a live cd, I accidentally deleted some files on the hard drive, including apparently the init file. The fact is that linux doesn't start anymore (kernel panic).
Can you help me to repair the system please ?

Thanks

sycamorex 06-18-2011 05:38 PM

Quote:

I accidentally deleted some files on the hard drive, including apparently the init file.
I don't think it'll be possible to restore it as you don't actually know which files you deleted.

Which distro are you using? Can you post the exact error you get when booting up (write it down or take a photo of it)?

On a separate note, you really should make regular backups of your system.

qrange 06-18-2011 05:42 PM

if its debian(ish), I think you can just install kernel again from livecd with chroot+apt.

elishac 06-19-2011 10:30 AM

It's ubuntu 10.04.
Can you describe in more details how to chroot+apt please ?

Thanks

Bapun007 06-19-2011 04:42 PM

Quote:

Originally Posted by elishac (Post 4389962)
It's ubuntu 10.04.
Can you describe in more details how to chroot+apt please ?

Thanks

from your live environment do this
Code:

sudo mkdir /mnt/ubuntu
now mount your /proc and /dev by these commands
Code:

sudo mount -t proc none /mnt/ubuntu/proc
Code:

sudo mount mount --rbind /dev /mnt/ubuntu/dev
copy your DNS info of live system
Code:

sudo cp -L /etc/resolv.conf /mnt/ubuntu/etc/
above command copy your DNS info of live system to your ubuntu partision .
now chroot
Code:

sudo chroot /mnt/ubuntu /bin/bash
now you are inside your ubuntu system you can now use apt-get to install kernel .

tailinlinux 06-19-2011 07:29 PM

Quote:

Originally Posted by elishac (Post 4389621)
hello,

while I was using a live cd, I accidentally deleted some files on the hard drive, including apparently the init file. The fact is that linux doesn't start anymore (kernel panic).
Can you help me to repair the system please ?

Thanks

Maybe this one help.
Maybe you need to reinstall your distribution.

Try this one.
Insert a live cd.
Click live installation.
select Custom partitioning or use the existing partition.
Select sda1 to be formatted and not the home partition.

then finish the installation.

TB0ne 06-19-2011 08:40 PM

Quote:

Originally Posted by tailinlinux (Post 4390260)
Maybe this one help.
Maybe you need to reinstall your distribution.

Try this one.
Insert a live cd.
Click live installation.
select Custom partitioning or use the existing partition.
Select sda1 to be formatted and not the home partition.

then finish the installation.

tailinlinux, did you bother to read the OP's question??
Quote:

Originally Posted by elishac
Can you help me to repair the system please ?

The OP knows how to do an installation, and they're trying to AVOID a format/reinstall...they want to REPAIR the system. Bapun007 posted the soltuion.

Also, you're posting information that may not apply to the OP, namely the fact that their home partition may NOT be separate from their root...they never mentioned their disk name, ID, or partition structure. You may be telling them to format their home partition, since you don't know how their drive is laid out. Please try to avoid posting information based on pure assumption, and address the OP's question.

elishac 06-20-2011 12:55 PM

Thanks a lot TB0ne it feels really reassuring to know that some people are here to check whether others mislead you into taking the wrong measures.
Thanks to tailinlinux too though, I'm sure you meant well.

This doesn't work though: sudo mount -t proc none /mnt/ubuntu/proc
mount: mount point /mnt/ubuntu/proc does not exist

And anyway, assuming I manage to chroot like you said, how can I "use apt-get to install kernel" ?

elishac 06-20-2011 02:53 PM

I also have a recovery mode a other kernel versions in the grub window, does that help ?

markush 06-20-2011 03:48 PM

Quote:

Originally Posted by elishac (Post 4390956)
...
This doesn't work though: sudo mount -t proc none /mnt/ubuntu/proc
mount: mount point /mnt/ubuntu/proc does not exist

There is a step missing in Bapun007's post, before mounting proc you'll have to mount Ubuntu
Code:

sudo mount /dev/sda? /mnt/ubuntu
where sda? is the partition where your Ubuntu resides.

Markus

elishac 06-20-2011 03:51 PM

I see... So when I get there, how to use apt-get to repair the kernel ?

And this doesn't work either:
sudo chroot /mnt/ubuntu /bin/bash
chroot: cannot run command `/bin/bash': No such file or directory

markush 06-20-2011 04:04 PM

referring to an Ubuntu-Wiki in german language the command
Code:

dpkg --get-selections | grep "\binstall" | awk '{print $1}' > /tmp/dpkg.log
should look which packages are/were installed and then
Code:

sudo xargs -n1 apt-get --reinstall install -y < /tmp/dpkg.log
reinstalls them. But I'm not sure, I have no experience with Ubuntu.

good luck

Markus

EDIT: I'll append the link: http://wiki.ubuntuusers.de/apt-get

markush 06-20-2011 04:10 PM

Quote:

Originally Posted by elishac (Post 4391104)
I see... So when I get there, how to use apt-get to repair the kernel ?

And this doesn't work either:
sudo chroot /mnt/ubuntu /bin/bash
chroot: cannot run command `/bin/bash': No such file or directory

could you please in this situation post the output of
Code:

ls /mnt/ubuntu
ls /mnt/ubuntu/bin

Possibly this are the files which you've deleted by accident.

Markus

Bapun007 06-20-2011 04:15 PM

Quote:

Originally Posted by elishac (Post 4391104)
I see... So when I get there, how to use apt-get to repair the kernel ?

And this doesn't work either:
sudo chroot /mnt/ubuntu /bin/bash
chroot: cannot run command `/bin/bash': No such file or directory

sorry for that , i dont have much experience in ubuntu , but that works for debian 6 for me .

markush 06-20-2011 04:21 PM

the chroot command is correct. This should work with every Linux, I've done it often with Slackware. But I suppose the OP has accidentally deleted files in /bin which may cause his problems.

But if this is the case he will indeed have to perform a complete reinstall.

Markus


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