Remember "sync; sync; sync; halt"?

An article all about rebooting Unix:

My recollection of the “sync; sync; sync” story as I heard it is that the first one flushes buffers but may cause filesystem updates which the second one clears up. But the article tells a different story (and makes some sense too.)

2 Likes

I first remember learning that you ran sync twice at the command line, not with semicolons (as the author mentions) and then powered down the machine. I don’t know where I learned it, but almost certainly from a computing book I got at the local library. The explanation given there was exactly the same as this article, that it gave the disks time to actually sync before the machine was powered down. There was no mention of a halt command. The instructions were also very clear that this must be done on an idle machine, and that you needed to kick all of the interactive users off their TTYs before shutting down.

This is the practice I follow on my v6 Unix install for PDP-11, and so far I haven’t corrupted a disk. I do understand that it’s only a matter of time, though!

4 Likes

Up until maybe 5 to 10 years ago, if I was sitting at a console thinking about an issue my hands would still randomly type in "sync " exactly because of this. Some habits die really hard.

1 Like

You should only need 2 sync, not three… the first one starts the sync process in the background, the second one blocks until the first one is completed, so when the second one terminates “halt” can be issued immediately. sync; sync;halt
(and indeed that’s how I did it back then. And it’s a difficult habit to quit…)

1 Like