Possible to re-install Debian 8.7 without destroying data?

Help with issues regarding installation of Debian

Possible to re-install Debian 8.7 without destroying data?

Postby RagnarRainMaker » 2017-03-24 09:36

Hi all,

I was pulling my 5th all nighter in an 8 day period last week. Either I was feeling slappy, careless or just sleepy, but I ran 'sudo apt-get remove -y <some important packages>' and well... I'm sure you can see where this is going ;-) More than a few "important" packages like python and a few others were removed.

After putting on my dunce cap, and sitting in the corner for 30 minutes, I was able to re-install many of them, but I keep getting errors regarding a missing python package named 'lsb-release' and 'apt-pkg' (or something like them at any rate).

As far as options go, it seems I've reached the end of the rope. So I created a bootable USB drive with Debian 8.7 (Jessie) and ran the installer. I was hoping I could re-install the base Debian system without overwriting or destroying my root partition, because that's where I keep all my data, and well... I kind of like my data. In the Debian installer screen where I select the root partition to install to, the command to advance to the next stage in the installer was something like "write changes to the partition table", which seem just a bit destructive to me.

So after that long, and hopefully good for a laugh, pre-amble here's my question. Is it possible to re-install the Debian base system while keeping the existing partition, and data in /home/username, in tact without destroying it?

I realize I can always backup my data and then re-partition the disk. I'm just hoping that isn't necessary. Mainly because I have a lot of data and it'll take a long time to copy to my trusty USB drive.

Anyone have any ideas?
Posts: 1
Joined: 2017-03-24 09:21

Re: Possible to re-install Debian 8.7 without destroying dat

Postby wizard10000 » 2017-03-24 10:15

Does it still network? You can chroot into it and reinstall those packages if you can get network going.

apt logs its actions in /var/log/apt and if you can chroot into it and get it networked you can reinstall the missing packages, which would probably be less painful than installing to bare metal.

My tool of choice for an adventure like this is a Super Grub 2 disk - only about 10MB but has an option to boot an existing Linux installation. If you can get networked on the target machine you can read the logfiles and reinstall the packages using apt or hopefully synaptic.

You can install without formatting partitions; I've thought about it once but have never done it as once I chose that route the Debian installer asked if I really, really wanted to do that and messages like that stop me in my tracks :)
we see things not as they are, but as we are.
-- anais nin
User avatar
Posts: 1279
Joined: 2011-05-09 20:02
Location: everywhere i go, there i am!

Re: Possible to re-install Debian 8.7 without destroying dat

Postby Thorny » 2017-03-24 11:07

RagnarRainMaker wrote:I realize I can always backup my data and then re-partition the disk. I'm just hoping that isn't necessary. Mainly because I have a lot of data and it'll take a long time to copy to my trusty USB drive.

Backing up is always necessary if you have data that you want to keep. It may take some time but once you have it backed up you only have to keep the backup current and likely most of your data doesn't change often. When you have data that is only on running hardware it is always at risk. If not from mistakes such as you have explained here then from hardware that might fail at any time.

This has been the best practice advice for as long as I can remember and it would have been easier and faster to get your system up and working. It would still be a safety factor while you try the chroot.

You wouldn't even have had to ask the question in this post if you had a valid backup that you could restore easily. Do yourself a favour over the long run and figure out a backup strategy that works for your use case.
User avatar
Posts: 542
Joined: 2011-02-27 13:40

Re: Possible to re-install Debian 8.7 without destroying dat

Postby peer » 2017-03-26 10:57

you can reinstall debian without destroying your data
During the install proces you can choose to manual select the partitions for installing debian.
Choose for manual install. For each partition you can then choose to format it (or not format it).

But this will keep your normal data but also the hidden files. (you can delete these hidden files with a rescue disk before reinstalling if you want).
I think this will work but is not a solid solution. You are better of when you make a backup of your data and perform a clean install.
Posts: 34
Joined: 2017-03-26 10:14

Re: Possible to re-install Debian 8.7 without destroying dat

Postby dasein » 2017-03-26 15:08

At the risk of seeming to "pile on," I'm going to echo and amplify what Thorny has already mentioned.

"It is possible to reinstall without backing up" is simply the wrong question. It's like asking "Is it possible to drive around with no spare tire?"

The answer to both questions is the same: Even if it were "possible," there's no earthly reason to want to do it in the first place. Failures happen, sometimes in critical systems, and you have two choices: be prepared for them when (not if) they occur or suffer the consequences.

Putting critical data (think: /home) on its own partition is a well-known and well-documented way to make backup and recovery easier. If you'd taken that simple precaution in the first place, you'd be "home free" right now, able to restore or reinstall the OS without affecting your personal data. But you chose not to do that. Ooops.

Regular and redundant backups is the only way to preserve data against all sort of problems--not just PEBKAC, but lightning strikes, flooding, mechanical failure, etc. But you chose not to do that, either.

And now you're asking for help in perpetuating your mistakes. Really? :roll:

In other words, this backup you're trying so hard to avoid is actually the only sane and sensible path available to you. And you're complaining that it will take time?? Pardon me, but WFW

The true "take away":

Step 1: Back up your data. If you're frustrated by the time it takes, remind yourself of how long it would take to recreate all your data; you'll realize in an instant that, temporally speaking, backups are the best bargain of all time.

Step 2: Reinstall, but this time, put /home on a separate partition. That way, the next time you type sudo do-something-really-stupid, you can restore/reinstall the OS without risking data you care about. Added bonus: you won't have to spend 2 paragraphs tap-dancing around about how you were tired, or distracted, or sexually frustrated, or whatever.

- Step 3: Repeat step 1 on a regular basis. Use multiple media, and rotate your backups. It's what the pros do, and there's a reason they do it that way.

tl;dr: Your problem isn't a lack of sleep, it's a chronic lack of insight and forethought.
User avatar
Posts: 7775
Joined: 2011-03-04 01:06
Location: Terra Incantationum

Re: Possible to re-install Debian 8.7 without destroying dat

Postby stevepusser » 2017-03-26 17:54

The installers for certain Debian derivative distros will allow one to save the contents of /home, even if it's on the same partition as root, but then you won't be running "True Debian". But backup anyway.
The MX Linux repositories: Backports galore! If we don't have something, just ask and we'll try--we like challenges. New packages: GIMP 2.10.2, Pale Moon 27.9.3, wine-staging 3.10, QuiteRSS 0.18.11, Linux kernel 4.17, Krita 4.0.4
User avatar
Posts: 9637
Joined: 2009-10-06 05:53

Re: Possible to re-install Debian 8.7 without destroying dat

Postby steve_v » 2017-03-28 04:38

Of course it's possible, assuming the data you want to keep is intact.
Just reinstall and restore your backup. You do back up your important data, right?

If you don't have a backup...
* Boot the livecd / install media, mount your existing partition and back up your stuff to another disk.
* Reinstall. Consider putting /home on a separate partition so you can avoid step 1 in future.
* Set up a proper backup, to another machine and / or external device. Ideally back up critical data to an off-site location. There are a plethora of options, I use good old rsync.

You got off pretty light this time, sooner or later you will have a disk die suddenly, or fat-finger rm -rf. Make regular backups, and test them.
Not so long ago, I had a 10TB RAID array fail (3 disks died in ~8hrs). Restoring from backups was a pain. But if i had no backup it would have been a total loss.
Posts: 695
Joined: 2012-10-06 05:31
Location: New Zealand

Return to Installation

Who is online

Users browsing this forum: No registered users and 3 guests