工具与资源github.com
Takeover.sh:无需重启,通过 SSH 抹掉并重装运行中的 Linux 系统
Takeover.sh – Wipe and reinstall a running Linux system via SSH without reboot
2017 — 2019,它一次次回到首页
黑点是上首页(≥ 50 分)的那次投稿,空心点是没冲上去的投稿,点越大分数越高。
导读
takeover.sh 是一个可在不重启的情况下,通过 SSH 在正在运行的 Linux 系统上完成擦除并重装系统的脚本。它通过将运行中的系统切换到内存中的根文件系统来腾出磁盘完成重装,风险较高,作者也明确说明一旦出错系统可能无法启动。
为什么经久不衰:它展示了“在飞行中换引擎”式的 Linux 系统管理技巧,围绕 chroot、内存根文件系统、btrfs 快照等思路至今仍是远程服务器运维的实用知识。
HN 评论精选
chroot 进救援模式是更常用也更稳妥的系统修复手段
很酷,虽然我确定自己不会用这种东西。真正多次救过我的是把远程服务器启动到救援模式再 chroot 进损坏的系统:挂载各分区后用 chroot 把救援镜像的 /proc /sys /dev 换成真实系统的,一切诊断工具和包管理器就都能用了。很多人觉得这不是什么高深技术,但当你启动救援镜像发现什么都做不了时,记得去搜 chroot。
gizmo查看英文原文
Pretty cool, although I'm pretty sure I would never use something like this. What has saved my skin on a number of occasions is the ability to boot remote servers into rescue mode and chroot into the broken system. That way you can use package managers, all your diagnostic tools, and everything else the boot image doesn't provide. Basically you just mount the different partitions and then chroot just swaps /proc /sys /dev of the rescue image with the real ones, and BAM you're back in business. For details see threads like: http://superuser.com/questions/111152/whats-the-proper-way-to-prepare-chroot-to-recover-a-broken-linux-installation I know that for many of you this isn't rocket surgery, but for those who don't know you have to google for "chroot" when you boot into a rescue image and discover you can't do anything, you might just remember this post.
推荐配套的 StackOverflow 教程:不重启切换到内存根文件系统
如果想把这类技术加入工具箱,建议读这篇 StackOverflow 回答:它讲了如何在不重启的情况下把运行中的系统切换到纯内存根文件系统,从而安装新系统、调整磁盘分区等。操作有风险,但该回答覆盖了许多坑——我最近就用它缩小了远程服务器的根分区。
predakanga查看英文原文
For anyone interested in adding this to their toolkit, I would suggest reading this StackOverflow answer: http://unix.stackexchange.com/a/227318/189858 In short, the answer details how to switch your running system to use an in-memory only root filesystem, without restarting. This allows installing a new OS, resizing the OS disks, etc. It's a risky operation, but the linked answer covers many pitfalls that you might run into - I recently used it to shrink the root partition on a remote server, very much appreciated the detail.
btrfs 快照提供了更安全的实验与回滚方案
同类的另一个技巧是巧妙使用 btrfs:把根文件系统做成 btrfs 子卷,做危险操作(比如装一大堆可能想回退的软件包)前先创建快照,之后可以用 set-default 在新旧根之间切换或删除快照。得益于写时复制,这些操作几乎瞬间完成,两个子卷也都能直接启动。
rdslw查看英文原文
Another nice trick of this family (with reboots, or without with using systemd-nspawn) lies with clever btrfs usage. Long story short: * use btrfs, and create your main root filesystem as a btrfs partition subvolume and another btrfs subvolume for snapshots (also a sub of master btrfs partition) * to start any experiment (e.g. installing whole gnome and 500 different packages you MIGHT WANT TO REVERT in the future) create before the risky operation snapshot (btrfs subvolume snapshot / /.snapshots/yournameofsnap) of current filesystem * experiment in any way :) * switch between old root (snapshot you created) or the new one with (btrfs subvoulme set-default) * delete any of them (btrfs subvolume delete) btrfs copy-on-write allows all of these commands to happen instantly without (almost) any actual copying. Also booting from both volumes is possible without any additional steps as long as master btrfs partition is the one to be booted from UEFI. https://wiki.archlinux.org/index.php/Btrfs
质疑“无需重启”的说法,并指出常规 SSH 重装方法已很成熟
README 说这个脚本没有任何退出新环境回到正常状态的机制,完成后必须重启,搞错了机器就起不来。那标题里的“无需重启”是不是不准确?另外通过 SSH 重装运行中的 Linux 系统其实很常见,比如用 debian-installer 的网络控制台,我偶尔就这样重装带 LUKS 的远程服务器,失败了大不了用控制面板重启再来一次。
mirimir查看英文原文
> This script does not have any provisions for exiting out of the new environment back into something sane. You will have to reboot when you're done. If you get anything wrong, your machine won't boot. Tough luck. So then "without rebooting" in the title is inaccurate, no? I haven't studied TFA carefully. But reinstalling running Linux systems via SSH is pretty routine, no? Using debian-installer with network-console, I mean. I occasionally reinstall remote servers with LUKS via SSH. I just login, build the installer, and reboot into it. Then I SSH to the installer, and almost complete it. Just before rebooting, I go to single-user mode, and setup dropbear in initramfs. Then I reboot. So OK, that's two reboots, not one. And if it fails, I just reboot using the control panel. If I've really fucked up, I reinstall and try again.
历次讨论
同类还值得读
直接在浏览器中启动 Linux 内核
Boot a linux kernel right inside your browser.
Fabrice Bellard 的 JSLinux 页面,用 JavaScript 在浏览器里启动一个 Linux 内核,并提供一个可交互的终端环境。
工具与资源上首页 5 次 · 2011–2025bellard.orgHacker News 未公开功能与行为清单(2018)
A List of Hacker News's Undocumented Features and Behaviors (2018)
数据科学家 Max Woolf 整理的 Hacker News 未公开功能与行为清单,涵盖投票机制、排名算法、账号惩罚等社区运作细节。
工具与资源上首页 5 次 · 2019–2025github.comMapSCII:在终端中用盲文和 ASCII 渲染地图
MapSCII – Braille and ASCII map renderer for the console
MapSCII 是一个在命令行终端里渲染地图的开源工具,用盲文字符和 ASCII 字符把地理数据画成可交互浏览的字符地图。
工具与资源上首页 5 次 · 2017–2025github.com顶尖大学的免费在线课程
Free Online Courses from Top Universities
Open Culture 整理的一份免费在线课程合集,汇集了全球顶尖大学(如 MIT、斯坦福、耶鲁等)向公众开放的网络课程资源,涵盖音频、视频等多种形式。
工具与资源上首页 5 次 · 2010–2022openculture.com淘气字符串:容易引发用户输入问题的字符串清单
Naughty Strings: A list of strings likely to cause issues as user-input data
一个 GitHub 仓库,收录了大量容易让程序出问题的用户输入字符串,如特殊字符、emoji、SQL 注入片段、系统命令等,供开发者用于测试输入处理逻辑。
工具与资源上首页 4 次 · 2015–2020github.com