Posts: 347
Silent Observer
Joined: 08 Aug 2013
#16
fatmac wrote:If you run 'apt-cache pkgnames', you will get a list of all installed packages. That will let you do a 'diff' against a fresh install. to see what you installed since the original installation. I know its probably too late for you just now, but might be something to think about for the future.
Synaptic can do the same thing, and then import the list from the resulting text file; however, if you have a partially corrupted install and you're having to reinstall, Synaptic (or even apt utilities) may not be working. In that case, the installer may also be unable to get the list, but it's at least possible the list itself is intact though programs may not run due to corrupted libraries etc. or the system may not even fully boot. Mainly, as with my other suggestions, this is likely to be a help to those of us where are using Linux/antiX because we're moving away from Microsoft (whether due to old hardware Windows no longer supports or due to philosophical or monetary differences) and are very far from being experts, hence likely to make mistakes (especially when they're offered by the installer).
anticapitalista wrote:This is what the installer does to the root partition.

From the installer code

Code: Select all

/bin/dd if=/dev/zero of=%1 bs=512 count=100"
But obviously, not when /home is inside / (i.e. not in a separate partition) and we've told the installer to preserve data in /home. This is the situation I'm suggesting doesn't work as it should. Based on my results, it appears in this case that the installer is failing to fully overwrite or remove the existing files outside /home. I don't know enough about Linux to know how to reliably remove folders that aren't empty, never mind detect if something prevents that method from working, but I presume there's a less wholesale method than simply wiping the entire partition.
Posts: 850
fatmac
Joined: 26 Jul 2012
#17
(Sorry, I/we diverted a little bit regarding pendrives.)

I think the only way to preserve data in a home folder on a / partition would be to copy it out somewhere & have it copied back after installing the new system as the home folder could be anywhere on the / partition, it doesn't get created at any one particular point in the system.
The other thing about home in the / partition is size, how would the installer know it has enough available space to copy it out somewhere, another disk would quite likely be needed. I can't see this being a practical option.
anticapitalista
Posts: 5,955
Site Admin
Joined: 11 Sep 2007
#18
"But obviously, not when /home is inside / (i.e. not in a separate partition) and we've told the installer to preserve data in /home."

But you shouldn't ask the installer to preserve home since it says it is for an 'upgrade'. You are doing a 'downgrade'
In the same way, user should not use this preserve /home option if installing antiX (or MX) over a different OS eg MEPIS.

Now, we should probably make this clearer to users so thanks for highlighting this issue.
Posts: 1,308
BitJam
Joined: 31 Aug 2009
#19
fatmac wrote:The other thing about home in the / partition is size, how would the installer know it has enough available space to copy it out somewhere, another disk would quite likely be needed. I can't see this being a practical option.
This is easy to solve. If we first erase everything by /home then the output of the"df" command gives us the info we need. If we don't want to erase first (which is probably a good idea) then"du /home" gives us the amount of room used by /home. We already use estimates like this in the remaster-live program.

An easy way to save the data under /home without causing conflicts is to rename. Either home --> old-home or /home/demo --> home/old-demo, etc.
Posts: 347
Silent Observer
Joined: 08 Aug 2013
#20
BitJam wrote:An easy way to save the data under /home without causing conflicts is to rename. Either home --> old-home or /home/demo --> home/old-demo, etc.
That will do nothing to preserve /home against wiping / by overwriting the first few megabytes of the partition with zeroes (i.e. destroying the directory information and marking the partition as empty).

There has to be a way to delete the old files without just recreating the partition from scratch; alternately, perhaps the installer could prompt the user for media to copy the old /home onto, and use rsync to do that job (then rsync again to copy the data back after destroying the partition). The point being, upgrade or downgrade, it should be possible to successfully and cleanly reinstall the OS without erasing everything in the partition willy-nilly -- doing it the way the installer does when"format and destroy" is permitted is just a shortcut, a time saver, in place of correctly downgrading (assuming reinstall of the"same" version originally used, before ongoing updates or the repo upgrade) by removing files rather than"attempting" to overwrite them or using some copy method that may or may not replace existing files.

If I have a computer I'm using for creative work like photography, music, or writing, there's every likelihood I'm not a Linux guru (and might be using Linux more due to paranoia about the progression of EULAs toward transferring ownership of any material stored or manipulated to the publisher of the software -- don't laugh, have you read the Yahoo! Groups EULA lately?) and would far rather get a warning that the reinstall process is likely to take a long time, and get good progress information and a good estimate of remaining time, than get an unbootable system because I tried to preserve data I might not have backed up. Linux in general is in a position to capture a lot of users who can't afford to replace their fully functional computer just because MS is dropping support for XP and most XP machines can't run Win8 -- but will do nicely with Linux, especially the light and medium-weight distros like antiX and MX. There's no reason to preserve the"you're too stupid to use Linux" attitude I've encountered more than a couple times (not from anyone here, that I recall) by making the system intentionally abstruse.

As a bonus, a system that's easier to use correctly (especially one that does a better job of preventing errors caused by"clear" instructions that mean something different to a naive user) will reduce the support load on those volunteers who actually understand the system.
Posts: 850
fatmac
Joined: 26 Jul 2012
#21
Hello bitjam, I know how to get the sizes OK, but we are talking about reinstalling the system, where Silent Obserer is trying to install into a single partition containing his original /home directory without obliterating his data, I don't think it can be done, because the home directory could be anywhere on the disk. That was why I was saying it would need to be written out somewhere & written back after installation.

This is my main reason for using separate root & home paritions on all my machines.
Posts: 1,308
BitJam
Joined: 31 Aug 2009
#22
@fatmac, perhaps I have the wrong idea of what the situation is.

I thought the problem was reinstalling on a root partition where we want to save data that is under /home on the root partition. ISTM we are doing this *now* because we don't erase the root partition before we do an install.

The first suggestion (from SO) was to remove all files on the root file system before installing. This is trivial with"rm -rf $MOUNT_POINT/*" before we copy. This can also be done by using rsync with the delete option to do the copy. This will automatically delete files and will handle hidden files in the top directory correctly (which the rm command does not). The rsync command is probably a better choice, at least technically.

The next problem was how to preserve information under /home on the root partition. For this I suggested still using rsync with delete but we exclude /home. This will prevent rsync from deleting files under /home while it still deletes files outside of /home.

The final problem (so far) was how to save the /home data without causing conflicts with the new system. IMO copying to some other partition would be a problem as well as being massively inefficient. What if there are no other partitions and there is not enough room on the Live filesystem to hold the old /home? ISTM the simple solution is to simply rename /home to old-home on the root partition. Then we use rsync to copy files to the root partition, now excluding /old-home so the files under it are not deleted.

Whether we want to offer this feature or not is a totally different question. I was just looking at the technical challenge. Here is the recipe:
Use rsync with the delete option to copy files into the new root partition. This will automatically take care of deleting/modifying existing files.

*If* we want to let the user preserve data under /home on the existing root partition then we simply move $MOUNT_POINT/home to $MOUNT_POINT/old-home and add an argument to the rsync command line to exclude /old-home so we don't erase files under it.
If old-home already exists then look at old-home-2, old-home-3, etc until you find one that does not exist. This is just a few lines of shell script. I can give you working examples.

If you want to use"rm" instead of rsync to delete the files then do something like:

Code: Select all

for dir in $(ls -a $MOUNT_POINT); do
    ["$dir" ="$OLD_HOME_DIR" ] && continue
    [ -e"$dir" ] || continue
    rm -rf $MOUNT_POINT/$dir
done
This will have to be modified if you want to exclude all /old-home directories from deletion. I'm not trying to give you a finished product, I'm just trying to convey the idea.
Posts: 347
Silent Observer
Joined: 08 Aug 2013
#23
Linux doesn't have an equivalent of the DOS deltree command? That could be used, efficiently and fairly quickly, to remove the folders in / without touching /home; then it's only necessary to delete files that may be loose in the root without deleting the remaining folder. I don't think it would be necessary to rename /home; there's already an option to rename the user folder if the same user name is selected but the user elects not to reuse the same directory, all that's necessary would be to force that outcome (i.e. don't ask, just tell the user that's being done;"A folder for that user name already exists; it will be renamed to hidden folder .username"). The extensive deletion would take more time then just blanking the patition by destroying its directory structure, but the end result would be a partition containing only /home -- and no, we don't know where it is, but why do we care? Unless we're using something like dd to copy the system onto the partition, it doesn't matter where the /home folder (or any of its contents) resides.
Posts: 850
fatmac
Joined: 26 Jul 2012
#24
Hmmm, didn't know rsync was able to be used in that situation, that sounds like a good place to start for SO to get his system reinstalled.
I must admit to being an 'obliterator' when it comes to reinstalling as I have met some problems with hidden files before now.
So, this sounds like a good idea to develop for future releases.
(My apologies if I led this topic off course.)
anticapitalista
Posts: 5,955
Site Admin
Joined: 11 Sep 2007
#25
I would also like to point out that users should be encouraged to back up regularly..
Although the snapshot application is not a backup utility, it can be used to make an installable live iso of your running system. So if the system goes belly up, then you can 'reinstall' using either your latest backup or your latest snapshot.iso.