-   Linux - Software (
-   -   I just nuked /etc (

cpeppler 11-24-2003 05:14 PM

I just nuked /etc
OK, OK, I was doing something a little too quickly....

Do you ever get that feeling when the blood just drains out of your face? Yep. That one.

Here's what happened.

I'm working in a heterogeneous Windows/Linux networked environment. I've had a linux server with Samba loaded on it for quite a while, everything up and running fine, RH 8.0.

Today, I wanted to backup some critical directories onto one of the W2K boxes, the sysadmin gave me a spot, I got hooked up to the shares with smbmount,
setup on /mnt/halbackup.

I started working with cpio, to copy the major user directories over to the W2K box, which worked fine. Logged in as root, got everything over there OK.

Well, I figured I ought to copy /etc over there as well, issuing the following command:

find /etc | cpio --pass-through --make-directories -dereference --no-preserve-owner /mnt/halbackup
OK, it worked. I had everything backed up on the W2K box. I was setting up a script to handle this automatically, so I could do it all at one shot (user directories, and /etc).

So, I switched directories over to /mnt/halbackup/etc (I made sure I was in the backup location on the W2K box), and did and rm, a big one. I figured I would clear it out, and then re-run the script, recopying /etc back to the W2K box, and all the backups run over there would have my /etc nice and cozy on their global backup.

And then it happened. I tried to cd to /etc, and there was no such directory. I tried to su, and there was no root user.

I think that little -dereference flag to the cpio command somehow got me back to nuking the original /etc directory on my linux box!

:cry: :cry:

Can somebody help me? My machine is still alive, but I'm afraid to touch it, can't reboot it, can't!!!!!

Mara 11-24-2003 05:30 PM

Copy /etc from any other Linux machine you can find. The most important files are /etc/passwd and /etc/shadow.

cpeppler 11-24-2003 05:42 PM

Can I do this from the original system disks?
Thanks for your reply. I think I've got a bit of a chicken and egg problem. I don't have the permissions to copy into /etc (or create /etc), because there is no /etc/passwd.

Is it possible to boot from the system CD, recover a vanilla /etc, and setup a new root? I don't want to touch the rest of the disk, just get /etc back, with a root that will help me clean up the mess I've made.


cpeppler 11-24-2003 05:52 PM

I found a linux bootfloppy
Hi folks,

I found the boot floppy, and restarted linux

Mounting /proc filesystem
Creating block devices
Creating root device
Mounting root filesystem
kjournald starting. Commit interval 5 seconds
EXT3-fs: mounted filesystem with ordered data mode.
Freeing unused kernel memory: 212k freed
INIT: version 2.84 booting
INIT: No inittab file found
INIT: can't open (/etc/, O_WRONLY): No such file or director

Enter runlevel:
OK, what do I do?

dr_van_nostrand 11-24-2003 06:01 PM

I think you need to boot with a system that can work on it's own eg Knoppix, or any other live distribution. There are some for floppys to. Check if they have support for your filesystems otherwise there's no much use of 'em ;)

Mara 11-24-2003 06:02 PM

I agree, Knoppix should be very good. One of the reasons is that it has its own /etc.

cpeppler 11-24-2003 06:05 PM

Thanks, dr_van_nostrand,

Unfortunately, I don't have access to Knoppix. I was hoping to be able to boot off the linux boot floppy, get in with root, and be able to create and populate /etc from the boot floppy.

The problem is, I think it's looking for /etc on the hard drive in order to boot completely. Chickens and eggs chasing one another around....

Anybody know how I can get this to boot from the floppy, and recover /etc?
(RH 8.0). If not, is it possible to do the same thing if I had the system CDs?



netboy_541 11-24-2003 09:01 PM

welp, i don't know, but i think i'm takin a stab in the dark, but --

do you happen to have a linux cd that's bootable?
or the recovery floppy that you can make during install??

I actually have a recovery cd that i got somewhere that has helped me out before... but usually if i hose my installation, i just blow the thing away and start over.. then copy all my other junk on there.... lol

hmm.. the more i think about it tho, i think that both of those just "boot" the machine and then turn it over to the hard drive..

damn -- i'll check into that when i get to the house..

cpeppler 11-24-2003 09:20 PM

I'm home now too...
I would really appreciate any help. I brought the wounded machine home with me to my home network, where I have another working Linux machine (6.2), that I can hook it up to if that will help. I also have the boot CDs for 8.0 that the machine was originally built with.

I just don't know how I'm going to get at the drive when there's no passwd file to validate permissions, etc.

Any help would be greatly appreciated. I have a bunch of really important stuff on this drive, that at a minimum, I need to find some way to get off of there. If I have to rebuild the box after that, well, that's the price of blowing your foot off.

I need to get that other data off of there though.

Any help would be hugely appreciated.


netboy_541 11-24-2003 10:01 PM

I'll check it out when i go home in about 3 hours.

Don't feel bad, i've shot my own foot off many a time!
I have learned..



cpeppler 11-24-2003 10:03 PM

OK, I'm in with the rescue disk...
I booted into "linux rescue" mode from the RH 8.0 CD, and I'm in.

Of course, there's no /etc/fstab for the system to look at, so fsck complain that it's not there.

Soooo.....Is there some magic way of mounting the physical drive to a file system without /etc/fstab? The one where I need to create /etc?

Anybody have any ideas on what to do next?


slakmagik 11-24-2003 10:05 PM

AFAIK, when you log in as root from a recovery disk, you completely blow by Linux's security measures. You can do anything you want to the box. At least, I can mount my Debian partitions and do whatever the hell I want to them from Slack. And vice versa - I switched my entire /tmp and /var partitions around in Slack from Debian. Dealing with /etc or /home should be no more difficult.

netboy_541 11-24-2003 10:06 PM

well, at least you are one step closer... :P

I will have to check my notes, and i will post what I got here in about 3 hours...

I could have wrote a damn book by now with all my linux notes... :P

cpeppler 11-24-2003 10:58 PM

...I know, I'm a wimp, but it's been a long day, and I may be in bed in 3 hours (US EST).

But that doesn't mean I'm not interested! I will check in in the morning.

I realize this is time to tread very carefullly, and I'm not sure exactly which steps I should be taking. TIA for your help. I really appreciate it.


netboy_541 11-24-2003 11:01 PM

yeah i get outta here @ 12 -- takes me bout 45 mins to get to the hizzouse... I'm in eastern tooo

All times are GMT -5. The time now is 11:02 AM.