1

I have a dual boot Windows Ubuntu laptop, and Ubuntu is split across multiple partitions (p4 and p5) so that my home folder is not on the main Ubuntu partition.

Then I must have accidentally uninstalled Python or otherwise destroyed my Ubuntu 22.04.01 (or 22.04.02?) installation, and I couldn't boot into Ubuntu at all.

So I formatted p4 and installed Ubuntu (desktop 22.04.03 LTS, a slight upgrade) fresh there, mounting as /.

Now, when I go to my ~/ home folder, I don't see my old files.

I found them in /media/myname/home/myname.

During installation, I didn't see an obvious option about how to set my existing p5 home partition as home (keeping my files, not formatting that partition).

If I messed up the installation, what settings should I choose on my next attempt so that my home files are back where they belong?

Or how can I fix it without reinstalling?

(I don't understand https://askubuntu.com/a/926856/48214, and I did use the same username, so apparently that's not sufficient. As answers at How to reinstall Ubuntu in the easiest way? and Keep /home directory when installing Ubuntu 14.04 suggested, I formatted / but left /home unformatted, hoping it would use /home as my new home folder too, but it didn't.)

Ryan
  • 401
  • 2
  • You weren't specific as to what Ubuntu product you're trying to install; as you maybe asking about re-installing using a ubiquity, subiquity or ubuntu-desktop-installer ISO (with calamares used by some flavors too) as you didn't provide product or release details (only mentioning Ubuntu which is available with many ISOs giving choice as to installer). – guiverc Dec 15 '23 at 04:21
  • Did you edit /etc/fstab? – user535733 Dec 15 '23 at 04:57
  • @guiverc Ubuntu Desktop 22.04.3 LTS, downloaded from Ubuntu.com and put onto a USB and installed from there. – Ryan Dec 15 '23 at 13:39
  • @user535733 If I did, it was years ago rather than yesterday (unless the installation did that for me automatically yesterday). – Ryan Dec 15 '23 at 13:40
  • @guiverc Please see my last sentence in my updated question. Should I try installing again, this time recording a video to show that I think I'm already doing what people suggest? Or do you have other ideas about what might be going on? Thanks! – Ryan Dec 15 '23 at 13:57
  • @user68186 I appreciate the link, but it's the same recommendation as I've already seen everywhere else and is what I did. I don't know what went wrong, which is what my question is about. Thanks! – Ryan Dec 15 '23 at 14:02
  • @guiverc Given that I found my old home files at /media/myname/home/myname, where my username occurs twice in that path, I feel nearly 100% confident that I used the original username, as intended. What I am not sure about is what version of Ubuntu I originally had installed. There is a significant chance that it was less than Ubuntu Desktop 22.04.3 LTS. Would that cause the /home to not get set how I want? – Ryan Dec 15 '23 at 14:04
  • The /home/$USER/home/myname would imply to me you didn't specify that location at all, or didn't specify that location correctly, meaning it was mounted as a media or subsequent mount. The release of Ubuntu (as long as 8.04 or later, but only as I'm not familiar with earlier having never used them) would not make any difference; though file-system may but again that's unlikely. – guiverc Dec 15 '23 at 14:09
  • @user68186 I think I already saw it as /home, which is how I knew not to format it. But I guess I could try another reinstall. I wonder if my attempt at using the Boot Repair tool beforehand messed with it. – Ryan Dec 15 '23 at 14:09
  • @guiverc Ok, I think I need to try another reinstall tonight after work (and record a video of my steps so we can see if I'm missing anything). Thanks so much for your help! – Ryan Dec 15 '23 at 14:11
  • 1
    FYI: If you don't specifically specify where /home is, that directory is created within the / which would cause your prior /home/$USER directory to mount on either /media/$USER or /mnt depending on how you mounted it. The re-install without specifying the location for /home is I believe your error. – guiverc Dec 15 '23 at 14:12
  • 1
    FYI: I agree with @user68186 in that you can fix it via edit of the file system table for your system, ie /etc/fstab which will allow you to specify your wanted home directory (on any disk/partition you like) which will shadow the /home/$USER your install created. It's not perfect (in that you'll have two user directories if you boot a live system) but it's what I'd likely do too (if the second directory annoys you, you can fix it using a live session anyway; though be very careful to delete the correct one) – guiverc Dec 15 '23 at 14:16
  • Please check my answer to Keep /home directory when installing Ubuntu 14.04 again. I have updated the answer with more pictures. – user68186 Dec 15 '23 at 16:50

2 Answers2

4

A Quick GUI Fix

Open the app Disks and click on the drive that has the old /home partition. It may look something like this:

enter image description here

Yours will probably say /dev/nvme0n1p5 and the mounted at: will be /media/myname/home/ or something similar.

  1. Click on the black square icon ■ that says "Unmount selected partition" when you hover the mouse pointer over it..
  2. Click on the Gear icon ⚙ that says "additional partition option" when you hover the mouse pointer over it.
  3. select "Edit Mount Options..." from the context menu

enter image description here

You will see a new window open: enter image description here

Make it look the the image above. Particularly, in this order:

  1. Identify As: Select from the drop-down menu: UUID=Abunchofnumbersandletters
  2. Mount Point: /home

Note defaults is the only option you need for the "home" partition. The current options, "nosuid, nodev, nofail" are for partitions (and drives) that are to be temporarily mounted, for example, a partition in an external USB drive.

In general the mount point /media/$USERNAME/something is for temporarily mounting a partition that may or may not exist in the future. These temporary partitions are mounted for only the current user. /home should be mounted so that all the users can access and use their own "Home" folders such as /home/myname/, home/myspouse/, /home/mychild/ etc.

Click OK to save the changes.

Alternately you may edit the file /etc/fstab using sudo and add the line:

# /home was on /dev/nvme0n1p4 during installation
UUID=Abunchofnumbersandletters /home           ext4    defaults        0       2

Note, the first line (starts with #) is a comment for your future reference. You can change it to suite your needs. Change Abunchofnumbersandletters to the correct UUID of your partition.

Then reboot your computer. If all goes well you will see your old files in your home folders.

Clean Up

Once you are satisfied that everything is working as expected, you may want to delete the folders created inside the mount point /home during the installation process. You will have to boot from the Live Ubuntu installation USB to do that.

Use the Try Ubuntu option when you boot from the Live USB.

Look for the Ubuntu installation partition (what you call "P4") in the Dock:

enter image description here

Do not select the P5 partition! If you do, you will lose all your files and folders!! I am showing the content of the equivalent of both P4 and P5 below:

enter image description here

Navigate to the folder /media/ubuntu/blablabla/home, where blablabla is the UUID of your / partition (P4).

First make sure your important files are not in /media/ubuntu/blablabla/home/Your_USERNAME/Documents/ etc. If you are satisfied, delete the folder /media/ubuntu/blablabla/home/Your_USERNAME/.

enter image description here

Do not delete the /media/ubuntu/blablabla/myname/ folder. This is your mount point for the home partition. If you delete it, your computer won't boot.

Hope this helps

user68186
  • 33,360
  • Thank you!! Super helpful. For future folks, to make this answer even better, I'd change the screenshot where Format Partition looks accidentally selected, and put a big arrow pointing to Edit Mount Options instead. Then for the next step, choose UUID=Abunchofnumbersandletters from the "Identify as" dropdown first, since your change to Mount Point would get overwritten by that if you do the reverse order. Also, my Filesystem Type says "auto". "Show in user interface" was checked (which sound reasonable, but I unchecked it because your screenshot has unchecked). I will try reboot now. – Ryan Dec 15 '23 at 19:33
  • Also, my unlabeled field above Mount Point says "nosuid,nodev,nofail". Hopefully that's ok. – Ryan Dec 15 '23 at 19:33
  • Reboot seems successful. My desktop and task bar are familiar. Interestingly, cd /media && ls shows only a single folder: myname. cd /media/myname && ls shows nothing. So I feel like there is no cleanup step necessary. ‍♂️ – Ryan Dec 15 '23 at 19:52
  • Thanks! I'm in Try Ubuntu now, trying to follow the cleanup step. I don't think the unused folders are causing me any distress, but I figured I'd try your steps since you were kind enough to write them. I'm not sure Files is the right place to be. In Try Ubuntu > Files, I just see Home and don't see any way to see /media/ubuntu/{p4_UUID}/home. And in Terminal, ls /media shows only "cdrom". As for replacing "nosuid, nodev, nofail" with "default", I haven't tried that yet but probably will try later. Thanks again! – Ryan Dec 16 '23 at 18:05
  • @Ryan I have updated the "Clean Up" section of the answer with more pictures and the clearer instructions. I hope this will help. – user68186 Dec 17 '23 at 17:56
2

This could be done by permanently and automatically mounting your second partition on /home, i.e., adding a single line in /etc/fstab. Alternatively, the utility "Disks" could be used.

If you want to achieve this using the installer, then you need to select "Something else". That allows you to manually assign partitions, i.e. your first partition should be mounted on /, your second that contains your home directories on /home. It is important to make sure the checkbox "format" is turned off.

vanadium
  • 88,010