LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Red Hat
User Name
Password
Red Hat This forum is for the discussion of Red Hat Linux.

Notices


Reply
  Search this Thread
Old 01-22-2015, 01:12 AM   #1
prakash_kumar
LQ Newbie
 
Registered: Jan 2015
Posts: 24

Rep: Reputation: Disabled
How to Recover /dev and /boot directory in RedHat Linux 5.3


Hi

I am using Redhat Linux5.3. Accidentlly I fired rm -rfv / command from putty and deleted /dev and /boot directorty. The file system is ext3. The deleted directory was mounted on /dev/sdb1. Can any one Please help on this how to restore these directories. Thanks in Advance

In addition to that when I am trying to connect through putty it gives me error "Server refused to allocate pty" . I have only one putty connection open which is connected before the delete was done. After deletion of /dev and /boot directory I am not able to connect through putty. Please help me on this.

Last edited by unSpawn; 01-22-2015 at 02:54 AM. Reason: //Merged posts
 
Old 01-22-2015, 03:03 AM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Since you have no /dev there are no (pseudo) devices for any process to connect to. Hence starting any process, let alone login process, will fail, epically. of If you have access to any Out of Band connection methods like IPMI, DRAC, ILO or other form of console server (or through your virtualization layer if applicable) try those, attach a Live or installer CD and re-populate /dev. If you have no such way then you're SOL. In that case (contact Data Centre personnel to either set aside this "victim" machine as a copy and) reload from backup. If you have no backups then you're SOL twice but at least now you've learned why you should make them regularly and test restores work.
 
1 members found this post helpful.
Old 01-22-2015, 03:25 AM   #3
prakash_kumar
LQ Newbie
 
Registered: Jan 2015
Posts: 24

Original Poster
Rep: Reputation: Disabled
Can you please tell me the steps for re-populating /dev directory?
 
Old 01-22-2015, 03:30 AM   #4
veerain
Senior Member
 
Registered: Mar 2005
Location: Earth bound to Helios
Distribution: Custom
Posts: 2,524

Rep: Reputation: 319Reputation: 319Reputation: 319Reputation: 319
In most distro rebooting would repopulate the /dev. But /boot holds the linux kernels and initramfs images. For that you have to copy from a backup.
 
1 members found this post helpful.
Old 01-22-2015, 03:37 AM   #5
prakash_kumar
LQ Newbie
 
Registered: Jan 2015
Posts: 24

Original Poster
Rep: Reputation: Disabled
Below are the list of files which have been deleted from /boot directory. Can you Please tell me which all files should require to reboot the system?
removed `//boot/grub/stage2'
removed `//boot/grub/ufs2_stage1_5'
removed `//boot/grub/menu.lst'
removed `//boot/grub/reiserfs_stage1_5'
removed `//boot/grub/fat_stage1_5'
removed `//boot/grub/grub.conf'
removed `//boot/grub/minix_stage1_5'
removed `//boot/grub/iso9660_stage1_5'
removed `//boot/grub/vstafs_stage1_5'
removed `//boot/grub/stage1'
removed `//boot/grub/xfs_stage1_5'
removed `//boot/grub/jfs_stage1_5'
removed `//boot/grub/splash.xpm.gz'
removed `//boot/grub/device.map'
removed `//boot/grub/e2fs_stage1_5'
removed `//boot/grub/ffs_stage1_5'
removed directory: `//boot/grub'
removed `//boot/symvers-2.6.18-164.el5PAE.gz'
removed `//boot/config-2.6.18-164.el5PAE'
removed `//boot/initrd-2.6.18-164.el5PAE.img'
removed `//boot/.vmlinuz-2.6.18-164.el5PAE.hmac'
removed `//boot/System.map-2.6.18-164.el5PAE'
removed `//boot/vmlinuz-2.6.18-164.el5PAE'
removed directory: `//boot/lost+found'
 
Old 01-22-2015, 07:36 AM   #6
veerain
Senior Member
 
Registered: Mar 2005
Location: Earth bound to Helios
Distribution: Custom
Posts: 2,524

Rep: Reputation: 319Reputation: 319Reputation: 319Reputation: 319
The files required are:

/boot/initrd-2.6.18-164.el5PAE.img This is initrd/initramfs image
/boot/vmlinuz-2.6.18-164.el5PAE This is kernel image

Plus you would need a boot loader to boot linux; means all under /boot/grub directory.
 
Old 01-22-2015, 07:57 AM   #7
prakash_kumar
LQ Newbie
 
Registered: Jan 2015
Posts: 24

Original Poster
Rep: Reputation: Disabled
Can I use initrd-2.6.18-128.el5PAE.img in the place of initrd-2.6.18-164.el5PAE.img (Diffrent version). I have back up of all files but the version is slight change I have 2.6.18-128. Is this work?
 
Old 01-22-2015, 11:07 AM   #8
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,780

Rep: Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212
Quote:
Originally Posted by prakash_kumar View Post
Can I use initrd-2.6.18-128.el5PAE.img in the place of initrd-2.6.18-164.el5PAE.img (Diffrent version). I have back up of all files but the version is slight change I have 2.6.18-128. Is this work?
No, it won't work. The kernel modules needed for booting are in that initrd under a directory named for that specific kernel version. A kernel with a different version, however minor, won't find them. You need to restore a matching kernel and initrd.
 
Old 01-22-2015, 11:40 PM   #9
prakash_kumar
LQ Newbie
 
Registered: Jan 2015
Posts: 24

Original Poster
Rep: Reputation: Disabled
Can I get this two files from internet since i dont have backup of the same version.
 
Old 01-23-2015, 01:56 AM   #10
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,780

Rep: Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212
No. The initrd was built to support your hardware. I'm a bit rusty on CentOS 5, but if it has the /sbin/new-kernel-pkg script you could use that to build a new initrd. You would probably have to play some games to prevent that script from trying to update the GRUB config file -- probably best to save a copy of that file and restore it afterward. Take a look at that script, but the invocation should be something like
Code:
new-kernel-pkg --mkinitrd --install 2.6.18-164
 
Old 02-08-2015, 11:38 PM   #11
prakash_kumar
LQ Newbie
 
Registered: Jan 2015
Posts: 24

Original Poster
Rep: Reputation: Disabled
Hi

I copied the boot folder from another server which has same hardware. Now I have reboot the machine but its not restarting. At the time of starting it showing following error code.

GNU GRUB version 0.97(625k lower / 2047616k upper memory)
[Minimal BASH-like line editing is supporetd. For the first word, TAB lists possible command completions. Anywhere else TAB lists the possible completions of a device/filename.]
grub>_


Please help me on this.

Last edited by prakash_kumar; 02-09-2015 at 12:03 AM. Reason: Mentining error code.
 
Old 02-09-2015, 02:44 AM   #12
prakash_kumar
LQ Newbie
 
Registered: Jan 2015
Posts: 24

Original Poster
Rep: Reputation: Disabled
Can anyone please help me on this?
 
Old 02-09-2015, 04:33 AM   #13
veerain
Senior Member
 
Registered: Mar 2005
Location: Earth bound to Helios
Distribution: Custom
Posts: 2,524

Rep: Reputation: 319Reputation: 319Reputation: 319Reputation: 319
The above grub message means it doesn't have the required modules and grub.conf it needs. So a minimal mode is started.

See you have to reinstall grub2 to the boot folder. I don't use rhel, but do you have a livecd/ rescue cd of RHEL 5.3. If so boot it up and reinstall grub.
You can manually install with command 'grub-install'. Please read about the command thoroughly.

You can copy the kernel and initrd/initramfs image from another system to boot. But if the systems are different then some modules or perhaps necessary scripts won't allow to boot.

So you may have to manually edit initrd/initramfs file appropriately.

Some posts in LQ discussed about mounting all the filesystem appropriately and then chroot to it and install kernel and other packages through a rescue/live cd.

Let others with more know how about rhel help.
 
Old 02-09-2015, 05:04 AM   #14
prakash_kumar
LQ Newbie
 
Registered: Jan 2015
Posts: 24

Original Poster
Rep: Reputation: Disabled
Thanks for reply. Can anyone tell me how to install GRUB mannually in RHEL5.3 ? what will be the exact command? My /boot folder was mounted on /dev/sda1 directory.

Last edited by prakash_kumar; 02-09-2015 at 05:06 AM.
 
Old 02-09-2015, 09:18 AM   #15
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,637

Rep: Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965
Quote:
Originally Posted by prakash_kumar View Post
Thanks for reply. Can anyone tell me how to install GRUB mannually in RHEL5.3 ? what will be the exact command? My /boot folder was mounted on /dev/sda1 directory.
You don't. You restore these things from your backups, and if you don't have them, you won't be able to get things working, period. rknichols gave you a command to generate one, but also noted that this WILL NOT WORK between different machines, even if the changes are VERY minor. This hasn't changed. If you had tried to look this up, you'd have found a possible solution on Red Hat's website:
https://access.redhat.com/documentat...nstalling.html

...which tells you how to install grub manually. Also, you are using old, unsupported RHEL 5.3...are you PAYING FOR RHEL??? If not, you need to stop where you are, and load CentOS instead. It's almost identical to RHEL, but FREE, and upgrade your server while you're at it. The current version is 7.x.
 
  


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
How to recover /dev/zero or /dev/null? CrAzYoNi Linux - Server 1 03-21-2012 11:15 AM
Fails to boot - rcS /dev/tty1: No such file or directory Spearhawk Debian 1 03-29-2007 09:05 AM
Linux Redhat recover Bootloader saeed144 Linux - Newbie 1 10-12-2005 12:48 PM
recover root filesystem redhat linux mohsinjq Linux - Newbie 4 11-10-2004 09:30 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Red Hat

All times are GMT -5. The time now is 09:51 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