Recovering from 'rm *' in the root directory.

Joe Smith jms at tardis.tymnet.com
Fri May 24 04:47:00 AEST 1991


After a recent disaster, we have added a new page to our "Disaster
Recovery Manual".  I thought I'd post this in case it is of use to anyone
else.

		------------------------------------

How to recover from an accidental "rm *" while cd'd to root.

On two of our servers a command was executed that ended up doing "rm *" as
root.  This immediately wiped out all symbolic links and regular files in
the root directory, but left all the dot files and directories.  This
error is a lot easier to recover from than "rm -r /".

The first indication of problems was that no new users can login; the file
/bin/login could not be found because the symbolic links "bin -> usr/bin"
and "lib -> usr/lib" were missing.  Daemons and user programs running at
the time continued to run.

Attempts to reboot the system failed for two reasons.  The file /vmunix
could not be found, and the PROM monitor could not load 'boot' because
/boot was deleted and its blocks were overwritten by some other file.

To return the system to operation, the following steps were performed:

Boot the mini-root from the SunOS-4.0 or SunOS-4.0.3 Installation tape.
	>b xt(0,0,0)
	Boot: xt(0,0,2)
	From: xt(0,0,3)
	To: xd(0,0,1)
	Boot: xd(0,0,1)vmunix -asw
	root device: xd0b
	root type: 4.2
	swap device: xd0b
	swap type: spec
	swap on root: y
	#

Run 'fsck' on the root and usr partition.  (Failure to do so will cause
the system to panic when copying files to the root partition.)

	# fsck /dev/xd0a
	# fsck /dev/xd0g
	(each question fsck asked was answered with 'y' in this case)

Mount the xd0a root partition and 'cd' into it.  Mount the /usr partition.

	# mkdir /mnt
	# mount /dev/xd0a /mnt
	# mount /dev/xd0g /mnt/usr
	# cd /mnt

Create the missing symbolic links.

	# ln -s usr/bin .
	# ln -s usr/lib .
	# ln -s usr/share/sys .

Copy the three boot-related files from /usr back to root.

	# cp usr/kvm/stand/boot.sun3 boot
	# cp usr/kvm/boot/kadb .
	# cp usr/kvm/boot/vmunix .

Use the customized kernel if it is still on disk.

	# cp usr/share/sys/sun3/XDXT260_X25/vmunix .

Set up the boot block.

	# cd /usr/kvm/mdec
	# sync
	# installboot -v /mnt/boot bootxd /dev/xd0a
	# sync

Dismount the partitions.

	# umount /dev/xd0g
	# umount /dev/xd0a

Press the BREAK key, and boot up as normal.

Joe Smith (408)922-6220 | SMTP: jms at tardis.tymnet.com or jms at gemini.tymnet.com
BT Tymnet Tech Services | UUCP: ...!{ames,pyramid}!oliveb!tymix!tardis!jms
PO Box 49019, MS-C51    | BIX: smithjoe | CA license plate: "POPJ P," (PDP-10)
San Jose, CA 95161-9019 | humorous dislaimer: "My Amiga 3000 speaks for me."




More information about the Comp.sys.sun mailing list