Getting back / no overwriting users /home after re-install

Sorry, finding a clear topic description is … difficult.

I reinstalled tumbleweed , which offered to recreate 3 pre-existing users during the process of re-installation. Then the re-installation crashed due to corrupted rpms. After downloading a new instance of tumbleweed only one (my) user was copied.

As I understand it, the /home/lost_users are not part of the new setup. How then do I re-create the old users without wiping their original /home/directories?

Ups sorry, I did not realize this is the German forum. Admins, could you please move this thread to the English site? Thanks.

Moved to Install/Boot/Login

useradd -u lost_user_UID -g lost_user_GID -G lost_user_supplementary_GIDs -d /home/lost_user lost_user

Thanks for moving the thread.

How then do I find out lost_user_UID and lost_user_GID?

Well, I understood you still have their home directories. There you will find at least their UID and primary GID.

ls -l /home

will show all of the home directories with the owners. That is user-name and group-name, but when the user isn’t configured, the UID and GID will be shown instead.

You must of course your self reconstruct which user-name belongs to which UID. Back-ups are a crucial item in system management, also of files in /etc.

# ls -ld /home/fox/
drwx------ 15 fox users 1024 Jun  2  2019 /home/fox/
# ls -nd /home/fox/
drwx------ 15 1060 100 1024 Jun  2  2019 /home/fox/
#
1 Like

Yes, the name is already shown by the name of the home directory itself. Thus:

  • Where there is an owner by name, the user is configured and the name should be the same as the directory name.
  • When there is an owner by GUID, the user is not configured and the username was the name of the home directory.

Umm, well, yes, the setup is like this: I did a fresh install in a partition with all directories needed on btrfs, i.e. including home. The original / true /home/users is on a different drive on ext4. I plan to mount it over the btrfs /home and will then try your suggestions. I’ll be back with the results afterwards (currently my daughter is visiting, in a few days I should have more leisure … ;-))

I do not understand much of this.

But, when you have home directories somewhere and you want to use them on your fresh installed system, my advice would be to copy those home directories (with their contents) one by one to the /home on your fresh system.

Maybe your idea is the same, but you using the word "mount’ makes it gibberish.

I think mounting a home-folder from a different drive to /home is not so uncommon. :wink:
The “gibberish” part here would be that btrfs “thinks” /home is part of its native structure. Right? I assume in case of any relevant actions like a rollback or maintenance of the btrfs filesystem this may cause trouble.
I’d rather properly remove /home from the btrfs partition and properly mount the ext4 drive to /home. (I’m not sure how to do the first part, the second can be done during the fresh install, BTW.) Or - copy the files as suggested, if the separate drive is not required for the daily operation.

No, it isn’t. Many people have a separate file system for /home (if that is what you meant to say). But as far as I understand what you posted earlier, it is not what you want. And thus is of no significance here.

No.

Again, you do not “remove /home from the root file system” (whatever it’s file system type).
And one does not have an “ext4 drive”, one has an ext4 file system.
But it seems you changed your goal and now want a separate file sytem for /home.

And, as you are going to install a new openSUSE, you better direct on installation configure that you have a separate file system for /home. And when you have that already somewhere, then you point to it to be mounted on /homeand do not let it become overwritten. What is the problem?

But you are going more and more off-topic. We are now discussing the file systems and their locations for a fresh installation. What has it to do with your question “Getting back / no overwriting users /home after re-install” (which is in fact an not understandable at all).

When you want any advice on how to configure your file systems and their locations and when this has anything to do with existing file systems which you want to keep, then at least post what you have (present situation) and explain what you want to achieve (new situation). So start with things like

lsblk -f

and, as root

fdisk -l

No. I didn’t change my goal!
The point was just to warn the OP that simply mounting over the existing /home -partition, subvolume, -folder, -whatnot might cause trouble. Whatever, I’m back out.
Ah, BTW, I’m not the OP.

Sorry to be back so late, but during login I had several times only a page with a big “500” in the center and a little sign saying “gitea”(?) in the upper left corner.

Explanation of my situation: Originally I installed the system on btrfs on a SSD. I don’t remember if I created /home on ext4 on a different hard drive during install or mounted it from pre-existing directories / files. I believe(!) it was the former scenario. Then the system was shot down during a failure of electricity. So I re-installed on the SSD. That creates automatically a /home in the btrfs structure of the new installation. Now I want to edit /etc/fstab with the goal to mount the old ext4 /home over the btrfs /home. I also have to recreate three users, the owners of their respective /home/“users” directories.

Please, this is nothing to fight over, I just want to understand what I do to prevent mishaps in my system. Thanks for your efforts, everyone.

This is of course outside your problem.
We found out that when that happens, you can start a new browser (or tab) on the forums and again hit the login button. You will probably see then that you are logged in (and you can close the first page/tab). Some misbehaviour of the log in mechanism :frowning:

I think I now understand what you did and want.

Normally there is no problem in using the /home directory as a mount point for a file system (that then is called the /home file system).
(Hint: do not forget to empty all in the original /home before you do the mount, else it will be there for “always”.)

But, as you say it may be that /home is defined in your Btrfs / file system as a sub-volume. I do not know because I do not use Btrfs. But I guess it is easy to see in your present fstab. When it is, I assume you must do something with the configuration of the Btrfs file system. But I have no idea what.

Sorry to be back so late, several times attempting login I only got a page with a big “500” in the center and a sing printing “gitea”(?) in the upper left corner.

@hcvv I didn’t realize that one can select an old /home during install without overwriting it. Good idea, if I get unsure during the procedure I’ll try another re-install, thanks.

I’ll attempt to clarify what I did and what I want to achieve: My old installation of tumbleweed broke during a failure of the electricity system in the house. So I re-installed the system on a SSD with btrfs. That creates automatically a /home in the btrfs file system structure. So I planned to edit /etc/fstab to get the system to mount on boot the original /home which is on a different hard drive with ext4. There are 3 original users below that ext4 /home. I need to re-create these users without deleting the original contents of their /home/“users”.

This is nothing to fight over, I’m no that much of an expert, I just want to understand what I do and needed some help how to do it. Thanks everyone for your input.

The openSUSE installer’s partitioner is powerful, able to do anything sensible, and much that would not be. The “partitioner” is also a mount point selector, and a formatter. For each previously existing filesystem, you have the option to mount it somewhere on the new / filesystem. For every previously existing filesystem you choose to mount, it gives you an option to format, should you wish to do so. A filesystem previously used as a /home/ is probably the most common use of these features.

The same “partitioner” is available post-installation. You could use it to mount your old separate filesystem used as /home/ on the current home. You would have to do this logged in as root, while logged out of your normal user. And, you’d need to relocate and/or remove the content from the existing /home/. Once that’s done, group and userids may need to be adjusted. On filesystems, owner and group are numeric. It’s the /etc/group, /etc/passwd and /etc/shadow files that take care of relating those numbers to individual users and their groups that you normally see in long file listings, and who has rights to do what. You can check at any time numerical permissions with ls -n. YaST is available as root to make whatever adjustments that may be required, in addition to various commands for these configurations such as useradd, groupadd and passwd. Odds are pretty good that for your #1 user, nothing would need to be done. By default the first user created in openSUSE is user 1000 in group 100.

Okay, I checked the new /home/ it is practically empty except for trash and desktop files. No problem with abandoning these. So I took the plunge and edited /etc/fstab and lo and behold the files of the three users are back again.

I did not dare touching the /etc/* files you pointed out, since I don’t understand their working (and syntax). During install I used the same name for the primary user (me) as during the original (destroyed) installation, so my setup is living again. The other two directories (of my children) are back, but not their users. I have names, UID and GID of both as directed previously. But when I use YAST to create the users will it not also create their /home directories anew thus deleting the originals?

I could of course umount /home and do it then, would that work or am I overlooking something?

No, as it had already been done. YaST’s purpose is not to destroy unnecessarily.

I don’t use YaST for this purpose. Instead, as root, I have a script to do it. For you just typing the following is probably close to what you need:

# sudo useradd -g 100 -u 1002 user2
# sudo useradd -g 100 -u 1003 user3
#

Instead of user2 and user3, use your appropriate old user names. For both, use the appropriate existing group and user IDs. Until these have been created, you’ll see ls -l produce the same results as ls -n.

useradd worked like a charm, both kids’ accounts are back and their directories whole. But the accounts seem to have set passwords – are that the old passwords or is useradd working some magic here?