Score:1

Point /var to another SSD during installation and keep data

tr flag

I have Ubuntu 20.04.6 installed on two SSD drives:

  • ssd1 holds all in / and boot partition.
  • ssd2 points to /var and stores data

Now I would like to install fresh 22.04.2 distro, but I would like to point /var of the newly installed system to ssd2 as well. During this process I need to keep all the data in /var as it contains important data files.

How do I do so during installation?

cn flag
Please don't. You will in the future have a crash during boot where the 2nd disk was too slow to boot up. Make a backup of /var and extract the needed files into the new /var. And change your working method: this time around: do NOT put personal data on a system dir. If this is mysql/mariab/apache/nginx or any other server software put the personal files onto a different partition that is also a different disk. Is far better for backups and for future re-install of your system.
cn flag
In case you want to continue: if you want the safest method then physically remove the 2nd ssd and install Ubuntu on the 1st ssd. Re-insert the 2nd disk and copy your personal files over to /var on ssd1 You can then format ssd2 and make a mountpoint. I myself then would copy the personal files in /var over to this mountpoint and either point the config of that server software to this location (both apache/nginx and mysql/mariab/postgress/mssql can do that) or use symlinks.
Denis Kulagin avatar
tr flag
@Rinzwind Thanks for a thorough comment and valuable thoughts. I decided to backup the whole filesystem on ssd2 to a separate drive and then proceed with a clean installation. I have a large amount of mysql data, which I wish to keep. Will think of a more smart organization of my data so I won't have so much trouble reinstalling a system in the future.
cn flag
do take out the disk ;) you would not be the 1st to format the wrong disk :) and see https://stackoverflow.com/a/10209282/2920227 on mysql. This WILL save you a lot of trouble in the long term.
Denis Kulagin avatar
tr flag
Thanks for the *apparmor* link, it was quite a problem I have already encountered as my database files are scattered across multiple drives. I will make precautions as you advised, it won't be superfluous.
raj avatar
cn flag
raj
For mysql (and other databases), the safest approach is always to make a full textual dump of the database to a SQL file, and then restore database from that dump after reinstallation. You shouldn't count on binary database files from different mysql releases being compatible.
Denis Kulagin avatar
tr flag
@raj That's truly the safest way, but it would take awfully long to complete. I always do backups and remember the exact version of distro it worked on, and also shutdown properly before upgrades. It keeps me safe in case something goes wrong, and saves my time working with dump files.
waltinator avatar
it flag
See the Filesystem Hierarcy Standard at `https://refspecs.linuxfoundation.org/fhs.shtml`, or read `man hier`. It explains where things go.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.