基于 bin456789/reinstall 加了自定义分区功能:重装时可以指定根分区、独立 /boot 和数据分区大小,支持把剩余空间挂载到 /data,BIOS/UEFI 自动识别。
自定义分区目前仅支持 Linux → Ubuntu 24.04 x86_64;不加自定义分区参数时,沿用原作者脚本的默认安装逻辑和功能。
项目:https://github.com/imagehubcc/reinstall https://www.nodeseek.com/jump?to=https%3A%2F%2Fgithub.com%2Fimagehubcc%2Freinstall
例如,根分区 64GiB、boot 2GiB,剩余空间给 /data:
git clone https://github.com/imagehubcc/reinstall.git
cd reinstall
sudo bash reinstall.sh ubuntu 24.04
--username root
--password 'YOUR_ROOT_PASSWORD'
--root-size 64GiB
--boot-size 2GiB
--data-size rest
--hold 2
将 YOUR_ROOT_PASSWORD 换成自己的 root 密码;也可省略 --password,按提示输入,避免密码留在命令历史中。
分区大小按需修改,不需要独立 boot 就去掉 --boot-size;rest 也能换成固定大小,如 200GiB。
准备完成后重启开始安装。--hold 2 会在安装结束后暂停,检查后再执行 reboot;不需要暂停可以去掉。
注意:会清空目标磁盘,包括已有的 /data,务必先备份。 多盘机器请用 --target-disk 明确指定目标,建议准备好控制台或 IPMI。
感谢原作者 bin456789 和上游贡献者,主要重装能力均来自原项目,本 fork 保留 GPL-3.0 许可。
原作:https://github.com/bin456789/reinstall https://www.nodeseek.com/jump?to=https%3A%2F%2Fgithub.com%2Fbin456789%2Freinstall

