LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Red Hat (https://www.linuxquestions.org/questions/red-hat-31/)
-   -   How to Recover /dev and /boot directory in RedHat Linux 5.3 (https://www.linuxquestions.org/questions/red-hat-31/how-to-recover-dev-and-boot-directory-in-redhat-linux-5-3-a-4175531803/)

prakash_kumar 01-22-2015 01:12 AM

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.

unSpawn 01-22-2015 03:03 AM

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.

prakash_kumar 01-22-2015 03:25 AM

Can you please tell me the steps for re-populating /dev directory?

veerain 01-22-2015 03:30 AM

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.

prakash_kumar 01-22-2015 03:37 AM

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'

veerain 01-22-2015 07:36 AM

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.

prakash_kumar 01-22-2015 07:57 AM

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?

rknichols 01-22-2015 11:07 AM

Quote:

Originally Posted by prakash_kumar (Post 5305007)
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.

prakash_kumar 01-22-2015 11:40 PM

Can I get this two files from internet since i dont have backup of the same version.

rknichols 01-23-2015 01:56 AM

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

prakash_kumar 02-08-2015 11:38 PM

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.

prakash_kumar 02-09-2015 02:44 AM

Can anyone please help me on this?

veerain 02-09-2015 04:33 AM

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.

prakash_kumar 02-09-2015 05:04 AM

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.

TB0ne 02-09-2015 09:18 AM

Quote:

Originally Posted by prakash_kumar (Post 5314329)
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.


All times are GMT -5. The time now is 12:33 AM.