LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Debian (https://www.linuxquestions.org/questions/debian-26/)
-   -   Reinstall everything (https://www.linuxquestions.org/questions/debian-26/reinstall-everything-4175432832/)

Weapon S 10-18-2012 01:32 AM

Reinstall everything
 
This might be more of a technical exercise than really a necessity.
The problem: I had defective memory and that almost certainly has led to file corruptions. Also I (still) have random program crashes. I can't trust my system files (my personal files is another problem...).
Could I issue some command to apt or aptitude that redownloads and installs all packages, including kernel? If so: how? And can I trust that to work (with possibly corrupted system)?
Or can I get a list of all installed packages and then provide that to a clean new installation? I want some backports too... I just thought of this solution; I will start investigating.
I had finally got the set-up how I liked it :( I'd prefer to reinstall as unobtrusive as possible... I'd like to hear from people who have experience or have looked into the matter. Thanks for reading.

Dutch Master 10-18-2012 02:42 AM

On the current system, do
Code:

dpkg --get-selections > selections.txt
Copy the resulting text file to your /home/<user> along with a copy of /etc/apt/sources.list and back up your data. Re-install Debian, but only a base system. Copy the backed-up sources.list back in place, then do:
Code:

aptitude update && aptitude install dselect && dpkg --set-selections < selections.txt && dselect install
You'll probably get a warning about untrusted sources if you use any non-free repo, authorize their use if you're sure these are safe. Depending on the number of packages and your connection, you'd make yourself a cuppa now ;)

rizzy 10-18-2012 02:54 AM

you could get list of all packages you have and reinstall those
Code:

dpkg --list
aptitude --reinstall package

Although there is no guarantee for anything with faulty memory. A better option would be back up, reformat and clean debian install. With dpkg --list it won't take too long to bring the system back to original state, probably quicker than trying to fix.

Weapon S 11-05-2012 02:38 AM

Dutch Master, it worked! Thanks.

widget 11-08-2012 05:48 PM

This is real interesting and could be a big time saver for me.

I have one problem though.

When running;
Code:

dpkg --get-selections > selections.txt
I indeed get a selections.txt. It is in my /home/<user name> directory.

This is in a Wheezy install and am pretty sure for this to work it would be elsewhere.

So, where does this need to be to work in the;
Code:

aptitude update && aptitude install dselect && dpkg --set-selections < selections.txt && dselect install
command?

Dutch Master 11-08-2012 07:25 PM

Ok, you've created the selections.txt file. Now make a copy of the file /etc/apt/sources.list to your home dir:
Code:

cp /etc/apt/sources.list ~/sources.list
Once done, back up all data safely and once you've done that, your old system can be re-installed. Install a bare (minimum) Debian install. Log in and copy the sources.list and selections.txt files from the backup to your new system. As root, copy sources.list back to /etc/apt:
Code:

cp /home/<user-name>/sources.list /etc/apt/sources.list
Assuming you stay with the Debian version you had, now enter the one-liner I've posted and let it do its magic :) If you change versions, edit the sources.list file accordingly.

Mind that if you stick with standard Debian packages (no multi-media or other 3rd party repo's) copying the sources.list file isn't really necessary. And if you change versions, it might actually be a bad idea to do too!

widget 11-09-2012 01:58 AM

Quote:

Originally Posted by Dutch Master (Post 4825405)
Ok, you've created the selections.txt file. Now make a copy of the file /etc/apt/sources.list to your home dir:
Code:

cp /etc/apt/sources.list ~/sources.list
Once done, back up all data safely and once you've done that, your old system can be re-installed. Install a bare (minimum) Debian install. Log in and copy the sources.list and selections.txt files from the backup to your new system. As root, copy sources.list back to /etc/apt:
Code:

cp /home/<user-name>/sources.list /etc/apt/sources.list
Assuming you stay with the Debian version you had, now enter the one-liner I've posted and let it do its magic :) If you change versions, edit the sources.list file accordingly.

Mind that if you stick with standard Debian packages (no multi-media or other 3rd party repo's) copying the sources.list file isn't really necessary. And if you change versions, it might actually be a bad idea to do too!

Thanks for the reply.

I don't think I made myself clear though.

The only list I got from that command was /home/walt/selections.list.

Walt by the way is a generic user name for generic installs of Wheezy where I go to play with new ideas or commands. I am not there right now but mounted the / partition for it and there is no copy of this file anywhere there.

My impression was that this file would be in the root partition somewhere or would need to be there to use it to reinstall. Seeing how there doesn't seem to be where should I put it or do I just leave it where is is in the /home/walt directory?

I actually think this would be a great way to install a copy on another box of an OS that I worked on here for someone else. There are several people I have run into that are very willing, indeed enthusiastic, about using Linux ir they don't have to install or set it up in the first place.

If they are at a remote ranch somewhere it is not easy to get to them very often. Most would be quite willing to do the install if this was all that was needed to bet it up and running.

I have a UPS unit but most folks don't. Power outages are not frequent but do happen. Had big fires here this year and you couldn't trust the power to be on from one minute to the next. I was shocked by the fact, in 08, that when the power died and the box did not shut down correctly my Linux install would actually work.

MS never did that for me.

Folks around here kind of like that idea along with the cost of the system. I could Mail them a correct disk and email everything else. May have to supply some install disks for sources as many remote ranches are still on dial up. Heck, the USPS only delivers 2 or 3 days a week to a lot of folks. If they can afford it some do have satalite connection but most don't.

This would work great.

Also be nice for me as I experiment with other installs to find things I want to change and this would be great. After the base install I could go to where ever my production OS is, run boinc and do my other things while a chroot environment took care of the new install.

Just really need to know where that file needs to go. Looked at the man page for dpkg and it didn't give me an answer although it was pretty clear on the command and also "--set-selections".

May just need to give it a whack with the thing in the /home/<user name> directory. May be where it looks for that.

The sources.list is not a problem with me. I have one that I use for all installs of Debian. Just change the version name. Has some handy commented out things in it like the commands for getting gpg keys.

Some folks like to play games on their box. I like to play games with Linux, particularly Debian and its relatives.

Right now I actually need a new install of testing on my main drive. Perfect time to try this after I get it to work somewhere else first.

Dutch Master 11-09-2012 07:58 AM

The file selections.txt is created in the directory where you are when giving the dpkg command to create it. I assumed you'd be in the /home/<user name> directory, but it can be anywhere in the tree. Mind that if you use the tilde (~) Linux assumes you want it in the users home dir. That user is root, so look for it in /root :) For dpgk it doesn't matter where the file is, as long as you specify the correct (full) path to it when you import the file in its "database" (it's not really a database, it's a flat file, but some people understand it better when using this analogy)

HTH!

widget 11-09-2012 12:51 PM

Quote:

Originally Posted by Dutch Master (Post 4825763)
The file selections.txt is created in the directory where you are when giving the dpkg command to create it. I assumed you'd be in the /home/<user name> directory, but it can be anywhere in the tree. Mind that if you use the tilde (~) Linux assumes you want it in the users home dir. That user is root, so look for it in /root :) For dpgk it doesn't matter where the file is, as long as you specify the correct (full) path to it when you import the file in its "database" (it's not really a database, it's a flat file, but some people understand it better when using this analogy)

HTH!

Got it. Thanks a bunch.

Will be playing with this very soon as both my favorite testing and Sid installs are a bit shaky right now but my newer installs of them are in great shape.

That is all tied up with my really poor video card and the end of fglrx support for such out of date cards.

Haven't tried the legacy fglrx driver because the FOSS driver is doing better than fglrx was anyway. Wasn't that way 2 years ago when those two were first installed.

I have been running testing with Xfce as my production OS with Sid as my backup. Right now I am running Sid as the production OS because it runs boinc better for me. The tasks page even redraws without having to keep the cursor moving with the mouse or holding down the down arrow key.

Thanks again. This looks like Fun.

Weapon S 11-12-2012 04:00 AM

One side note on the topic: the described way does not automatically install backports.
For distribution on a disc, look into making a repository. You should be able to only supply the packages you actually want to install on a disc. (Hopefully only as little as 2 DVD's, because otherwise, you'd have to set up named repositories Disk 1,2,3 etc.) I'm not very knowledgeable on that topic, but I wish you good luck ;)

Dutch Master 11-12-2012 08:54 AM

If you add the backports repo in your sources.list prior to making a copy, it gets added automatically. But it doesn't automatically install packages from that, for that you'd need apt-pinning. Is also copy-able as in Linux everything is a file (and thus copy-able :p), just copy the file from your old system to the backup medium and copy it back in place on the new one before upgrading. It's just another step in preparation, but beyond the scope of this question...


All times are GMT -5. The time now is 08:09 PM.