I always thought that would not be a good idea. I have not deeply investigated this, but I have done parallel installs of 2 or 3 versions of Linux on (remote) machine that needed to go on running for as long as possible (which IMHO is close to your extra requirement).
Obviously there is a mechanism for installing packages to a different partition than the active distribution (e.g. `dpkg --root=/some/dir), but that is just the packaging. I have been wary that there are other things going on during install that version X might know of when installing itself from CD, that version X-1 (or older) does not know of. Therefore I don't think it is a good idea to install X with X-1 (but again, it might be lack of knowledge) and I always install version X with itself.
What I do to keep the downtime of the working X-1 system minimal is:
- download the install image for version X to a file
- boot up a virtual machine (nowadays VirtualBox but I used to use VMware for that) and install X from the image.
- install the extra stuff the machine needs (
openssh, etc.) that is not installed by default. - configure things like
postfix by copying the main.cf over from the working machine. - In general bring the VM up and running as close as possible to the working setup of version X-1, leaving out things like pickung up email that interact with the environment in a non-reversable manner.
Optionally (if your machine is performant) enough to get a good impression, play with version X.
At this point you have an installation of X (set up by version X) but it is on the virtual machine and not on the partition you want. The next steps are:
- copy all relevant files from the VM to the target partition (where used to be version X-2). For this you can probably shut down the VM and mount the VM disk on the host, but I have successfully done this by having a running VM client do the copy (using
find / -xdev -print0 | cpio -pdmv0 /target/partition/mounted/in/vm) - update the, just copied,
fstab of version X with appropriate UUIDs (or devices) and selecting the swap (probably can share the partition with X-1 as long as you don't hibernate to disk) - update other things that are going to be different (e.g. if you don't use DHCP to get your network address).
- make a copy of
/boot/grub/grub.cfg (on X-1) - run
grub-mkconfig -o /boot/grub/grub.cfg and diff with the copy you just made. The new kernel should be noticeable as the primary change.
Now you should have a dual boot system that no longer has version X-1 (default) and X-2 as boot options, but X-1 (default) and X. You can now reboot in version X by manual selection during boot-up. If you want to make that selection more permanent you can change GRUB_DEFAULT= in /etc/default/grub (or change the X-1 system to default reboot in the last selected boot option)
At some point, at the latest before going to version X+1 and thereby overwriting version X-1, you have to run grub-install from version X, and start using its grub and not the one from X-1.
If you have your /home on a separate partition, then you might be able to share your home directory between versions, but sometimes that doesn't work as programs make irreversible conversions of configuration data.
aptwithdist-upgrade?