Reinstall base Ubuntu without formatting or removing manually installed packages

Reinstall base Ubuntu without formatting or removing manually installed packages

因为我对建议的存储库(在 14.04 上)进行了太多改动,所以我想回到步骤 1:删除系统上除我手动安装的软件包之外的所有软件包,然后重新安装基本系统,而无需重新安装的麻烦。

基本上,有没有办法通过 ssh 安全地进行远程控制:

  • 删除除手动安装的软件包之外的所有软件包
  • 重新安装内核中的所有内容ubuntu-desktop(最好是自动安装,而不需要将任何其他软件包标记为手动安装)
  • 安装手动安装的软件包的依赖项

注意:我故意省略了希望获得不针对任何特定版本的答案。


似乎我还没有足够简单地描述我想要的东西,我认为这两点可以解决上述问题:

  • 清除所有自动安装的软件包(@kos 在@Fabby 的回答中回答了这个问题)
  • 安装组成全新 Ubuntu 安装的软件包

而且我猜测如果手动安装的软件包的依赖项确实被卸载,apt-get -f将会对我有所帮助。

答案1

为将来:

如果你在 1000 英里外的数据中心有一台远程服务器,你最好有一个IPKVM切换器安装,因此您不必仅依靠它来ssh实现它。

如果服务器位于珠穆朗玛峰:添加铱星电话和调制解调器也……

然后你就有了一个可启动的 512MB FAT克隆Zilla该机器上的分区(我使用速尔USB 驱动器)并使用控制台启动,并将系统分区的映像备份到数据驱动器,然后将先前的系统映像复制到 USB 驱动器的辅助分区上在开始trusty-proposed向服务器添加内容之前。(我将大部分系统备份保存在数据驱动器上:它们只有 6GB)

目前:

  • 采取apt-备份
  • 通过你的/var/log/apt/history*
  • 自己动手自动魔法脚本会apt-get purge根据上一步中的数据,执行所有你不再需要或真正不想要的内容
  • 执行脚本时向 Linus 祈祷
  • Update your repositories like you want them to be (like removing trusty-proposed)
  • Reboot while praying to Richard of the Stallmans
  • If everything works out: implement the IPKVM switch solution above.

答案2

OK, My answer assumes you can, and have backed up your user directory, and everything you want to save. which reduces your question to how do I install Ubuntu on a remote server? To which there are many solutions.

For this, you could use DRBL, to remotely deploy an operating system, with a variety of options for booting. You can look into it here: http://drbl.org/installation/

There is Clobber: http://cobbler.github.io/manuals/quickstart/

There is cloneZilla, which can back up and restore over a network. The link is for windows, but the same methods apply for linux. Alternatively, you could make an ubuntu boot image locally, and install it using clonezilla. http://opensourceforu.efytimes.com/2013/12/restore-partitions-network-using-clonezilla/

Alternatively, you could try using dd_rescue, or netcat

A useful search term might be "Server Provisioning". There are more options then these.

There are bruteforce methods too.

$ ls /
bin  boot  cdrom  dev  etc  home  initrd.img  initrd.img.old  lib  lib64  lost+found  media  mnt  opt  proc  root  run  sbin  srv  sys  tmp  usr  var  vmlinuz  vmlinuz.old

and your PATH were like this:

echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games

if your root directory were something like this, if you over wrote /etc, and /usr with "clean" versions, you would be overwriting, pretty much every piece of installed software, and the config files for it. That would be hackerish to say the least, if not a completely horrible idea. Running apt-get purge would be much safer, Or perhaps you could fine tune the process a little bit. You might then also want to include a clone of your old ssh config file in /etc/ssh/ before trying to restart the services with new config files.

There is also a tool that lets you dump a running kernel and upgrade without rebooting. For that you could check out Kslpice, or kGraft

If all you are having trouble with is repos and package management, I'm not sure why you would want to dump the kernel, mbr, boot partition etc..

So any how, I hope Ive given you some ideas to look into. There are many ways to depoly a server remotely.

相关内容