Linux - GeneralThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
My uncle was trying to clean up his Ubuntu installation by removing some old kernels using the synaptic package manager. But he removed them all and now the grub loader only shows a mem test and the windows options.
We used a live cd and we can see his file system still intact.
Is there anyway to recover the kernel or just put it back into the grub options?
i should probably add that when we boot with a live cd the boot directory is empty all but the grub folder. missing vmz, init files etc
You should be able to chroot into the disk system, then maybe use dpkg.
I got into a bind during testing the beta for Hardy, but I still had cache/status entries that wouldn't allow Synaptic to pull down a kernel it thougt was still there.
Bit of hacking got it working - should be some doco on the Debian site(s) I would think.
Is there anyway to recover the kernel or just put it back into the grub options?
You might be able to use chroot and aptitude to reinstall the kernel after booting from the Live CD. After booting from the Live CD, you would open a terminal window and run
Code:
# chroot /media/whatever bash
# aptitude
where "/media/whatever" is wherever your "/boot" partition got mounted. It may be under "/mnt" or somewhere similar.
Hahahahaha! That's almost as good as removing "libc".
Since it's a stock Ubuntu, that makes things very easy:
1. Boot the live CD, but add the "root=/dev/sda1" (or whatever the Linux partition is) option. The machine
should still boot - you just can't load any more drivers when you have the final filesystem because there will be none in the /lib/modules/$(uname -r) directory.
2. If you didn't delete the package files, they will be in /var/cache/apt/archives - find a kernel and install it:
ls -l linux-image*
dpkg -i your_linux_image.deb
And that should be it.
I assume you won't have network access because it may be impossible to load the driver until you've fixed the kernel problem. If the package files were removed ('cleaned') you should still be able to install from a CD repository - worst case is you mount the CD and go to the 'pool' directory then:
find . -name "linux-image-*"
and cd to the directory and install using dpkg -i
Just one note - you will often see packages like these:
linux-image-2.6-686
linux-image-2.6.18-5-686
The first package is a "metapackage" - it depends on the latest 2.6.*-686 kernel and forces a kernel update when one is available. In general this is a nuisance (you should choose when you want to upgrade a kernel - but you should also watch for news of kernel exploits). So if a metapackage was installed, you may want to 'uninstall' it - this will not remove your current kernel, it will just prevent automatic updates.
# chroot /media/disk/root bash
# mount /boot
# aptitude
where "/media/disk/root" is wherever your root file system gets mounted by the Live CD. "mount /boot" will mount your "/boot" partition in the place pointed to by "/etc/fstab".
Boot the live CD, but add the "root=/dev/sda1" (or whatever the Linux partition is) option. The machine
should still boot - you just can't load any more drivers when you have the final filesystem because there will be none in the /lib/modules/$(uname -r) directory.
i can not get it to boot into his file system doing this it just unrecognized device string.
Quote:
2. If you didn't delete the package files, they will be in /var/cache/apt/archives - find a kernel and install it:
ls -l linux-image*
dpkg -i your_linux_image.deb
nope he did not delete teh package files i can see them if i boot using the live cd. i ran these commands and it worked but i got an error saying
update-initramfs is disabled since running on a live cd
the link /initrd.img is a dangling linkto /boot/initrd.img-2.6.24-19-generic
You should be able to boot using the LiveCD, find out what device/partition has linux, and set the correct "root=" parameter. The /sys/block virtual directory has a list of 'block devices' on the system; my laptop has an 'hda', 'sda', and numerous 'ram*' devices. A hard disk will be 'hd*' or 'sd*' - since my laptop only has 'hda' and 'sda':
fdisk -l /dev/sda
Device Boot Start End Blocks Id System
/dev/sda1 267 12921 95671800 83 Linux
/dev/sda2 1 266 2010928+ 82 Linux swap / Solaris
I can see that I have Linux installed on /dev/sda1 (well, it just says the filesystem is for Linux but I know that I installed Linux there)
fdisk -l /dev/hda
-- No response - this is because 'hda' is my CD drive.
Once you've identified the Linux root partition, you can reboot the CD, choose "boot CD" but add the correct "root=" line and continue as described previously.
Another option is not to reboot - you can do the "chroot" trick (a little more work):
1. find out where the root filesystem was automounted by Ubuntu:
mount
2. Let's pretend it was '/mnt/hda1' (substitute your real partition here) - if you do 'ls /mnt/hda1' you should see directories like 'etc', 'var', 'dev', 'proc' and so on
3. Remount essential system virtual directories:
mount --bind /dev /mnt/hda1/dev
mount --bind /proc /mnt/hda1/proc
mount --bind /sys /mnt/hda1/sys
Note: if the 'busybox' version of 'mount' is used, then instead of "mount --bind" you need to use "mount -o bind"
4. Do a chroot:
chroot /mnt/hda1 /bin/sh
5. Fix up the system as previously described
I forgot to mention: Ubuntu has an extremely annoying 'feature' - you can't log in as root or use 'su'. The solution is to do "sudo -i" which should act as if you were logged in as root; just use 'exit' when you're finished with your root tricks.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.