10

Because I played around too much with the proposed repository (on 14.04), I want to go back to step 1: remove every package on the system except those I've manually installed and reinstall the base system, without going through the hassle of reinstalling.

Basically, is there anyway to safely and remotely over ssh:

  • remove all packages except manually installed ones
  • reinstall everything from the kernel to ubuntu-desktop (preferably automagically without any further packages getting marked as manually installed)
  • install dependencies of the manually installed packages

N.B. I've intentionally left out in hopes of getting answers unspecific to any particular version(s).


It seems I haven't described what I want simply enough, I think these two points would take care of the above:

  • purge all auto-installed packages (@kos answered that on @Fabby's answer)
  • install the packages that makes up a fresh Ubuntu install

And I'm guessing if the dependencies of manually installed packages do get uninstalled, apt-get -f will help me with them.

  • 1. are all the files you need to save in /home? 2. is the network stable? If you were to move your userfiles or whatever you need to save, could you over write everything, and move user-files back easily? Also. is PXE enabled? and are there Virtualization support tools in the BIOS? – j0h Oct 29 '15 at 4:03
  • @j0h 1. Nothing important in /home, but there are important configuration in manually installed packages, 2. Yes, but as I said user files are not the worry, 3. Yes, it's enabled, 4. And yes, there's virtualization support as well. – Oxwivi Oct 30 '15 at 2:35
  • This is a bit over my level of expertise, but wouldn't it be easier to get a packages list from a fresh install, diff it against your current install to get a list of everything added. Then do a fresh install and automagically add back in all the custom stuff - possibly with a restore of some or all of the config files in $HOME? You get the lists by running dpkg -l. This will probably mark a lot of the additional stuff as manually installed - rather than as dependencies which could go away if the package that needed them is deleted later. – Joe Oct 30 '15 at 8:02
5
+250

For the future:

If you have a remote server in a Data centre 1000 miles away you'd better have an IPKVM switch installed so you don't have to rely solely on ssh to reach it.

If the server is on Mount Everest: add an Iridium phone and a modem as well...

Then you can have a bootable 512MB FAT CloneZilla partition on that machine (I use an SLC USB stick) and use the console to boot to that and back-up an image of your system partition(s) to your data drive and then copy the previous system image on the secondary partition of your USB stick before you start adding trusty-proposed to the server. (I keep most of my system back-ups on the data drive: they're only 6GB)

For now:

  • Take an apt-backup
  • Go through your /var/log/apt/history*
  • Make your own automagical script that does an apt-get purge of all the stuff you really don't want/need any more from the data in the previous step
  • Execute the script while praying to Linus of the Torvalds
  • 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.
  • No automagical command of delete everything except this that? :( Do IPKVM switch come with dynamic DNS function? Worthless otherwise in this case. – Oxwivi Oct 25 '15 at 16:53
  • The above is the most automagical you'll get. Fully automatic like a Windows restore point: nope, that's what system back-ups are for... IPKVM switches can use DHCP, so by using an external Dynamic DNS service: "yes, kinda"... – Fabby Oct 25 '15 at 19:02
  • Nah, I hate Windows restore point thingy. No idea what goes in there. (More like, I've come to hate the whole frickin' Windows product line) The only automagical part I want is figuring out all manual packages and the command to uninstall everything except those. – Oxwivi Oct 25 '15 at 19:21
  • I deleted Windows about 2 years ago... Have you even tried looking in history.log??? :P – Fabby Oct 25 '15 at 19:43
  • @Oxwivi You want apt-mark showauto, and to purge all the package in the output by feeding the list to apt-cache purge: apt-mark showauto | xargs sudo apt-get --dry-run purge. I voluntarily added the --dry-run switch in case you're tempetd to try it, so that you can actually see what's happening: doing something like that breaks your installation, because it removes every package dependent on any of the package removed by the command. Just take a look at the output of the dry run. – kos Oct 28 '15 at 22:15
1

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.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.