Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Restoring and upgrading a corrupt system System
Recently my OS X 10.2.8 began malfunctioning (all Carbon and Classic apps would not launch). After exhausting attempts to fix it, I got out the install disks and re-installed my system. It's not a perfectly simple process, but I have some hints on how to do this and not lose (much) of your exisiting configuration, and do it all without having copy stuff to another computer (of course, it would be smart to have a backup made before doing anything like this).

[robg adds: With the newly-announced Panther ship date (what, you haven't visited apple.com yet today?), this information may be particularly useful in the near future for upgrades, not just corruption recovery. Read the rest of the articles for the details, and feel free to comment with the tips and tricks that you use when upgrading a machine...]

Get the software you need.

  1. First you need to find a 10.2 Install disk, not a 10.2 upgrade disk. The difference is that starting with 10.2, the install disk has an option called "archive and install."
  2. Since this is going to backtrack your system to 10.2.0, you want have handy a copy of the combined 10.2.0 to 10.2.6 updater
  3. Optionally if you use the Developer tools, I recommend getting a fresh copy of the Developer Tools install.
  4. Optionally if you use X11, I recommend getting a fresh installer

The Re-install.

  1. First to avoid hang-ups, be on the safe side and boot from the install CD and run Disk Utility's Restore Priviledges program. After the system boots from the disk, you can find this located in the menu.
  2. Run the install program. When you get to the screen asking for the destination disk, it should warn you that you cannot do a normal install. Whether it does or does not warn you, choose the install options button and select the "archive and install" mode. Now you can do the install normally. This mode preserves all user folders in their current places (except for the shared folder, which is saved but moved to a holding place). The system, usr, bin, private, var, logs, and Library folders will be moved to a holding place and replaced with virgin ones from the install disk.
  3. Notably you do not need to write down any special information like your IP address, as will not be asked for you network settings and the usual first time install questions; these are all preserved.
  4. After the install has run (during which you will have to reboot once from the hard disk during the install process and insert the second install disk), you should now run the Combined Updater you downloaded earlier.
  5. Optionally, you can now install the Developer Tools and X11.
  6. Now run Software Update (in the System Prefs). Run this, reboot as needed, and then re-run it again. Repeat this until no more software updates appear to be available.
  7. After the updater has run, and you have rebooted, once again run Disk Utiltiy and restore your privledges; this time you want to do it booted from the hard disk and not the CD.
WAIT! your're not done yet.

Actually now we get to the tricky part. Your old configuration has now been saved in a top level folder called "Previous Systems" and inside this you should see "Previous System 1" (assuming this is the first time you did this). This contains some things you need to keep by dragging them back to their original locations, then you can delete the rest. I can only give you some guidelines here, as I don't know what special things you may have installed.

  1. iTunes! Your "Shared" foder has been moved to the Previous Systems 1 folder. Notably, this could contain all of your iTunes music libraries. So drag these back to the new Shared folder.
  2. Since you just re-installed the Developer Tools, you can now delete the Previous Systems 1 -> Developer folder. By the way, the reason for re-installing the Developer Tools is because the installation process also places some files in your /bin directories, such as make, and also sets up some aliased file names. The same is true for X11. I feel it's easier to just re-install than to go hunting for these and possibly goof up.
  3. The Library and the usr -> local folders are where you should now focus your attention. These folders will contain mostly things you don't want to move, but there will be lots of application-specific data, fonts, and system configurations in the Library that you will want to keep. If you have installed custom unix packages (other than those from fink), or possibly some hand-installed perl packages, it's likely they and their man pages will be in usr/local.
  4. Note that you should be examining these in a UNIX terminal window and not the Finder, since the some of these like private and usr are hidden from the Finder.
Here's how I figured out what I needed to keep.

As a safety precaution, delete any soft links in the /Previous Systems -> Previous Systems 1 directory (e.g. the private directory is one). This will keep you from making some easy mistakes when the time comes to delete files. At first I tried using a recursive diff, like this,

diff -r --brief /Library  /Previous\ Systems/Previous\ System\ 1/Library/  
to view the differences (you may wish to run this as sudo). However, this produces a tedious amount of information -- somewhat useful for getting the big picture, but too much to find those key files. Instead, what I did was to write a little perl script to delete any files that appear to be identical to the current ones:

cat > compare.pl
#!/usr/bin/perl -wn
# note the -wn above!
chomp;
next unless -f;  # skip if not a file
$y = quotemeta($_);  #meta quote the spaces

#  Note the following assumes the name of the
#  Previous System is in fact numbered 1
$x = '/Previous\ Systems/Previous\ System\ 1/';
$z =  '/Previous Systems/Previous System 1/';
# the difference between these lines arises
# from the different ways perl and the system
# parse meta characters in file system commands.

$g = $z.$_;  # path to prev system file in perl syntax

if (-f $g) {  # skip unless this file exists
  # compare md5 checksums of old and new files  
  $k= `/sbin/md5 $x$y`;  # path to prev system file in unix syntax
  $j= `/sbin/md5 $y`;

  @k1 = split /=/, $k;  # get the part after the "=" sign
  $kk = $k1[-1];
  chomp($kk);
  
  @k1 = split /=/, $j;
  $jj = $k1[-1];
  chomp($jj);
  
  if  ($kk eq $jj ) {print `rm $x$y`};
    
}
To use this, I select a folder like the Library and run sudo find /Library | sudo ./compare.pl. Warning: executing that line of code will delete files on your computer and cannot be undone. It does what you want but just be aware of this.

Do this in turn on /usr and /bin and /var and so on. Do not run it on symbolic links like /private. After doing this, none of the directories are removed, but any contents identical to the current contents are deleted from the previous systems folder. Thus you can find the fonts you added and the application files. However, there will be lots of junk still there such as all the receipts for the various packages you installed, log files, caches, etc. You just have to wade through this, but now it's a lot easier.

After doing this I was able to get all of my applications running again except for Keynote, which I could never figure out what library files were inconsistent.

Personally, taking advantage of this fresh start, I decided to scap my old usr -> local folder and re-install any custom unix packages. The reason was that I had lots of things that were obsolete and did not want too keep, but found it too hard to reliably unistall from the man pages and so forth.

After completing this, I found that I had freed up gigabytes of disk space that had been chewed up by logs, and obsolete data from various applications I no longer used. Also, my computer booted a lot faster than it used to -- not sure why, but no doubt my system had more cruft than I realized.

References: Useful sources of information:

    •    
  • Currently 1.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (4 votes cast)
 
[20,706 views]  

Restoring and upgrading a corrupt system | 5 comments | Create New Account
Click here to return to the 'Restoring and upgrading a corrupt system' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
addenda
Authored by: SOX on Oct 08, '03 12:16:04PM

A few comments.
1) be sure to download the combo update before you revert your system. On my computer Safari would not function after I reverted to 10.2.0. Apparently the version I had installed required some pathes to be installedby software update to run. (And it did run after I completed the update).

2) the line cat > ./compare.pl is not part of the perl script. its the line used to create the perl script.

3)Some people might not regard the receipts as "junk" and want to keep them for their non-system-installed packages.

After you run the compare.pl on all your previous folders they will occupy much less space and so you may want to keep them around for a week or so to make sure you did not miss anything important.

The thing I did not expect was how much better my computer runs now. it boots quickly and is much more responsive. and I seem to be getting less unexpected quits. I suspect that OS X is just getting to be old enough now that we will start seeing creeping system degeneration and that we may in deed need to do fresh re-installs periodically to blow out the bit rot. Really there's no reason to exepct we wont be getting bit rot it seems to happen to all computers over time.



[ Reply to This | # ]
How much space does Archive & Install take?
Authored by: the_webmaestro on Oct 08, '03 12:36:39PM

Does Archive & Install merely archive the /Users folder, /Users/Library (and then install a "clean" system)? What can I expect as far as disk space required? I've got a 30GB HD, with 5GB available. Is this going to be enough to do an Archive and Install? It looks like my /Users folder is 15.95GB (Get Info from Finder running under a User w/o Admin access). Looks like I've got some housecleaning to do! ;-p

---
Father of Jeremy Logan Leeds



[ Reply to This | # ]
How much space does Archive & Install take?
Authored by: SOX on Oct 08, '03 01:55:50PM

its likely to fit in 5gb. but you can get a pretty clos estimate by typing:

sudo du -sk /bin /sbin /usr /var /Library /Shared /Developer /System



[ Reply to This | # ]
heres the right number
Authored by: SOX on Oct 08, '03 01:59:19PM

oops my mistake. it moves the Developer and shared folders so these dont take up any (new) room. the additional space is simply the space required for the install.
the following should be upper bounds:

745168 /usr
8632 /etc/
8 /var
7848 /bin
3680 /sbin
1466368 /Library



[ Reply to This | # ]
It does not touch the /Users folder except for shared
Authored by: SOX on Oct 08, '03 02:11:24PM

Your /Users/<home>
folders will not be moved, so dont count this in your total.
the /Users/Shared folder will be archived, but since the one that replaces it has zero byte contents it does not require free space on the disk.



[ Reply to This | # ]