Score:-2

Best way to proceed after loss of HDD with /home and /var?

cn flag

I hope this is not a complicated question to answer.

I had a laptop with primary SSD and secondary HDD. It came with Ubuntu 20.04 pre-installed on the SSD, and I mounted /home and /var on the HDD, and used the laptop for several months without issue. Then the hard drive failed catastrophically.

I thought I had an adequate backup strategy (via regular background rsyncs to a NAS) but when the HDD failed (>25% bad sectors on efsck) I checked the NAS and found that the job has been silently failing for weeks. I suppose this could be due to the defective disk, there's no way to tell now.

SO: I have an undamaged 500GB SSD which contains:

  • a tiny EFi partition
  • a 495GB primary Ubuntu partition (20.04)
  • a 4.3GB swap partition
  • 1.1MB unallocated

and a trashed 1TB HDD which was partitioned into:

  • 500GB ext4 /dev/sda1, mounted as /home
  • 300GB ext4 /dev/sda2, mounted as /var
  • 200GB unallocated

I have a replacement HDD supplied under warranty but I'm not sure if there's a way to retain the existing software installed on the primary partition and somehow catch my home directory up with it (the software manager in Ubuntu croaks because my home directory is rubbish).

(To clarify: Booting from the primary partition, it walks me through several "brand new user" dialogs and then the software manager reports "structure needs cleaning" and halts. Booting from a portable Ubuntu 22 on a USB drive, I can't mount the HDD partitions at all.)

Is my best option just to do a brand new install of everything over the top?

If I do go down the complete re-install route, is there a tool which can analyse my primary partition and identify exactly what packages were installed on it? Because so far as I can tell the normal way to access that information needs access to some files that are no longer accessible.

Thanks for any advice you can offer (besides REGULARLY TEST YOUR BACKUPS, that is)

Cheers, T

user10489 avatar
in flag
What is the exact error you are getting? "Software manager croaks" isn't very descriptive. Is it booting or is it failing when it can't find the missing partitions?
Levente avatar
cn flag
"Booting from a portable Ubuntu 22 on a USB drive, I can't mount the HDD partitions at all." - that's important. Why not? What does it say?
user10489 avatar
in flag
If you replaced the bad disk, you will need to recreate /home on it and mount it (replace the entry in fstab to find it), and then possibly restore what you do have from your backup to /home.
TrevorN avatar
cn flag
OK, I booted off USB, "Try Ubuntu", and in a terminal I ran"sudo mount /dev/sda1 /mnt/mnt_home". That actually worked, but when I cd into mnt_home and ls there is nothing there except lost+found. That's the old (bad) disk, of course.
oldfred avatar
cn flag
My /home is 1.4GB, mostly Firefox and /var less than a GB. I keep those on SSD. But I then had all data on HDD. Now with new larger SSD, data is also on SSD, and HDD is one of the backup locations and test installs. Can you restore old backup to SSD's /home & /var folders and remove mount of those partitions from fstab? Then system should boot?
user10489 avatar
in flag
Not sure how much of /var is worth restoring. You need to recreate your home either by restoring it or by making a new fresh ones with the files in /etc/skel/ ; yes, after you fix fstab it should be fine. If you are merging /home (and /var?) into / you can just comment out the entries in fstab.
Score:1
in flag

After a catastrophic disk crash like what you describe, the default graphical tools will be unable to repair your missing home directory.

After replacing the disk and creating the necessary missing partitions and directories (like /home and /var ) you will need to edit /etc/fstab so it can find the new devices at boot, or remove or comment out the fstab entries if you merged them into the root partition.

Some directories in /var will be automatically recreated, but others you may need to restore from backup or alternately do something to manually trigger their recreation.

You will also have to create your home directory, either by restoring it from backup or copying the default config files from /etc/skel/. In either case, afterwards you may need to change ownership and permissions on your home directory to make sure they are correct.

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.