[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Return a Debian system to a pristine state

On Mon 01 Jun 2020 at 12:15:02 (+0200), Marco Möller wrote:
> On 01.06.20 04:41, emetib wrote:
> > this has been an interesting topic, so what the hell, here's my two cents.
> > 
> > for my vm's, i have a list off packages that i install as soon as the minimum/base install and reboot is done.  4 vm's, testing, stable, centos7, opensuse.  i have no gui's on these only cli, just need to know how to configure things for other os's than debian and it becomes a simple cut and paste to get a system to be at what i need.

I keep such a list as a sequence of   apt-get -y install …
commands, but this is preceded by an update/upgrade,
installation of etckeeper, git and git-man (and commit),
and one or two chmod/chgrp commands in my favour. Those
few install commands omit the -y.

I keep the script up-to-date when I add significant packages,
and it saves a lot of time because I presently run five systems
with near identical configurations. If I were to rerun it, it
would just chunder away, adding anything that's new.

The last packages in the script are apt-listbugs and needrestart;
last because they would keep interrupting the process with their
demands for a response. Finally, I purge the american dictionaries,
and rerun update to fill the cache for apt-file.

> > have a home partition, not just a home dir, and back it up often with a timestamp on it, and do a --get-selections and dump it to a file that you back up also. also doing that is an easy way to compare what was installed and what is now installed.

I consider a /home partition vital, and it's encrypted. along with
swap (random key). I prefer to work with "top-level" packages rather
than --[gs]et-selections, as the latter involves >2000 packages,
many of them entirely uninteresting/unrecognisable.

> > keep sensitive config files in a spot that you know is going to be backed up or on your home partition so they aren't overwritten with a new install.

I keep copies of any files I have changed in directories called
where the filenames are mangled thus: ¬etc¬default¬console-setup
Having a flat directory makes it easy to update, check, and compare
systems with one-line commands.

> > there was a suggestion about using a live distro to make a back up right away, never done it before, yet this is a great idea.

Because I always have two root filesystems on the disk, I just use the
other system. But I don't make a habit of backing up the whole system,
only my configuration of it, plus a selection of log files.

> > i believe that someone (smarter than me) could write a simple script to put all user installed programs into a file and then reinstall them after a full-reinstall.

Just put the commands that you type into a file like the above,
and bash it. Go from there.

> > i.e.
> > bash_install_script.sh
> > check if su
> > add package to list
> > continue with the install
> This is almost exactly what I am also doing.
> The problem remains to simply remove a couple of packages without
> having to go for a full blown system reinstall and all the necessary
> requirements for organizing it well.

This is a false dichotomy. There's no problem with removing a couple
of packages; you just misunderstood the meaning of --no-install-recommends
and the way packages interact, and then expected apt to automatically
bend to your will and fix the mistake for you.

> As there is a package manager, it
> is obviously a straight forward logic to expect it to do this job,
> because this is exactly what a package manager is expected to manage.
> All other suggestions which have been brought up in the thread are
> workarounds for filling the gap where the package manager is not full
> featured.

That's how computer systems work. People write software that does what
is considered sensible, and others build upon this by writing scripts,
rather than posting that the software has a severe bug and they can't
believe that it doesn't do what they want it to do in the way they want it.

> The short answer to this thread is that unfortunately Debian is not
> prepared with a simple solution for this simple task, but
> sophisticated workarounds are needed.

As has been explained, it's not so simple, because *your* focus is
solely on the last apt command that you typed, whereas the package
management system is concerned with the whole system. Apt deals with
the system as a current state, and not as a chance sequence of
commands in reaching that state which must be reversible and replayable,
back and forth.

When you install some packages and change your mind, just copy and
paste the line from /var/log/apt/history.log, replacing install with
remove (or purge). Sophisticated?


Reply to: