TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

When Unix Learned to reboot(2)

22 点作者 aquabeagle将近 5 年前

1 comment

wahern将近 5 年前
&gt; Linux&#x27;s sync call is synchronous. You get the same guarantees as you do from fsync. This behavior was introduced in 1.3.20, released in 1995. Prior to that the same sync dance advice was useful since early versions of Linux were more aggressively asynchronous in their handling of disk writes than other contemporary systems. While this helped it compete in benchmarks, it caused data integrity problems when Linux machines started to be put into production (which was one of the reasons motivating the change). Modern Linux systems flush out all the dirty buffers as part of the shutdown sequence and wait for the flush to complete before proceeding to reboot, turning the system off or halting.<p>I developed a habit (more a tick, really) of invoking sync on Linux. Not just because of shutdown behavior, but because of crash behavior. The Linux filesystem didn&#x27;t recover very gracefully on a crash, so many times I found myself having to reinstall Linux.<p>3.5&quot; floppy disks, the media I had to use to install Linux, had a penchant for corrupting themselves while sitting in my desk drawer. A Slackware disk set required something like 8 or 10 or more disks, invariably one of which would have gone bad. I only had a 2400 baud modem, so downloading a replacement disk took forever, and that&#x27;s <i>after</i> I was lucky enough to find a free BBC (or later SLIP&#x2F;PPP) line. And because you would only discover a corrupted disk during installation, the process of reinstalling Linux could easily take 1 or 2 sleepless nights given it might happen midway through an install, requiring a reboot back into Windows for downloading and then restarting the process from scratch. (I had high school during the day, and part-time work many week nights.)<p>So, yeah, a handful of bad experiences and to this day I sync almost religiously. Until recently I would sync three times in a row, manually, presumably because I had picked up the mythic BSD advice somewhere.<p>I was also fortunate to have had my first accidental `rm -fr &#x2F;` experience back then, which makes me far more cautious in interactive shell sessions than many others, sometimes to their impatience. Because I had already learned my lesson and became reflexively cautious, I absolutely hated Red Hat Linux, which aliased common commands to request confirmation before destructive operations.