How to create user account for existing home directory on a fresh install?

Last night I ordered my first SSD drive. I’m going to use this opportunity to do a clean reinstall of openSUSE, something I haven’t done in nearly 8 years now. I’ll be installing Leap 15 and from there upgrading back to Tumbleweed, after which I’ll import my old package list which should make everything the way that it was. There is one little question I wish to ask regarding the re-installation process, as it’s not something I’ve had to do before thus I wish to be extra careful.

My home partition with my user directory sits on a different hard drive. As I install a clean copy of openSUSE on the new SSD, I of course want to mount it back and keep the same data from it. I remember the installer prompts me to mount the partition as /home so that shouldn’t be complicated. What I’m curious about is what I must tell the installer in order to re-generate the same system user, in such a way as to link to the existing user data and have it recognize the old user permissions. I’m a little nervous that the installer might try to erase and override the old user directory or something unexpected, so I wanted to ask what exactly I must do to be extra safe.

I already asked this briefly on IRC last night. Someone told me that when prompted by the installer to define a user, simply adding an user with the same name as my old one should automatically link to the existing user directory from the home partition and adapt its file permissions. Can anyone confirm that this is correct and what I should be doing? Does the wiki have a walkthrough (ideally with installer screenshots) on the exact process? Thanks.

Mount the partition on /home, as it was before. Set it not to be formatted.
Next, create the user(s), the system will warn you that the user’s homedir is already there and propose to change it’s ownership etc. Done this dozens of times, works fine. You cannot import the users from the previous install, since those files are no longer there.

Thank you. I assume that if the installer wanted to format /home I’d see a clear warning, especially since IIRC it lists all installation steps before it begins and also pops up a warning about partitions that will be erased. The installer detecting the old directory and offering to integrate it with the new user is what I was hoping. Obviously there’s no point in importing the old user registry, I only need to retype my name and password… was worried if it recognizes the old ownership on its own which I understand it will.

Ownership is based on UID not user name but the directories are on user name as long as UID and user name is the same it will work.

But will the installer give the new user the same UID as the one it detects in my home directory? If somehow it has to modify all files inside /home/username that’s not going to be pretty: I have tons of stuff and the process will likely take ages to finish. I also keep many of those files on an external drive to which I backup my data, this may render the content on that drive inaccessible! Is this the case, and if so is there no way to ensure the new user will get the same UID as the old one?

That worked for me in the past, though it was a few years ago. I haven’t tried it recently.

I don’t remember whether it used the UID of the existing user, or it used the home directory and did a

chown -R username

on that directory.

My current practice is to always do new installs with user “support” as the initial user. And then, after install, I add the other users with desired UIDs.

Changing the username has a much bigger impact: think about the entries in /tmp ( which don’t change ). When done during install, of even afterwards, this doesn’t take hours/ages. Talking about ~400,000 files, ~120 GB . At the time I did this I initially picked a new username ( merged two accounts so to say ), and this did cause trouble, since some of the config files did actually contain paths instead of system vars like $HOME.
My advice: let YaST handle this, that road has always worked perfectly for me. And backup !!

The username will stay the same, no plans to change that… I’m giving the new user the exact same name as my existing directory upon installation. If worst comes to worst, I’ll run a chown command as suggested by nrickert to reset the permissions on my external drives separately… but if the installer could simply use the existing user ID that would make things a lot easier. Guess I’ll have to see what it does when the new drive gets here and I begin the installation.

If you use the same username, accept that the installer will ‘change’ the user’s homedir’s permissions ( in my case nothing was changed, but it did not discover that or mention it ), and you should be fine. In fact, my educated guess is that you’ll be surprised how easy this works.

UID for first user is always 1000. Unless you changed stuff the old UID should be 1000. It is just something you need to be aware of UID is important

Cheers! I just looked under YaST - User and Group Management… my UID is indeed 1000. If that’s a default then nothing should change and the new account should the same one. This is my personal computer so I’m the only user (apart from root of course).

Yes. As gogalthorp says, if you have done nothing unusual with your user in the past, only left the defaults, and if you do not make any conscious changes to the User ID on your new install, the User will be the same, uid=1000, gid=100, so you really should not see any issues.


You can even skip the creation of new user during the installation if you choose not to. Just mount the HOME partition to /home and continue with the installation.
Once you’re done with the installation, you can either login without the X server (GUI) and invoke the yast2 ncurses by running the command (as root)

yast2 users

or login with the X server (GUI) running as root (not recommended but doable) and create the user using the yast.

Both UID and GID are important. IIRC the installer will allow you the set the UID and GID of the new user. The default for the first user is 1000, I don’t remember what the default GID is, I believe it’s 100… The “old school” way of determining your user and group IDs is

$ grep <username> /etc/passwd

. That will give you a colon-delimited line of that user’s entry in /etc/passwd. See

$ man passwd.5

The third and fourth fields are your UID & GID, respectively.

If you use the same username, UID & GID in your new installation you’ll have no problems at all.

Have fun,


That solution might be true to other Unix-like system but since SUSE/openSUSE is Linux and has the GNU core-utils installed by default then the command


should do the same thing, also

id --help
man id

for more info.

Reinstall done. What worked for me: During installation I chose to skip creating the user, it didn’t prompt me on what to do with the existing user directory and I wasn’t sure what it might decide. After install I logged in as root, and from the YaST2 interface I chose to create a new account with the exact same data. This time it told me that the directory already exists… it also prompted me to modify the permissions, which I chose not to as I set the same UID. I then just logged in with the username and everything worked as before :slight_smile:

Yes, that is the way I expected it to work. Thanks for reporting back.


Glad that worked out for you. That’s how I do an upgrade with my vms and my external usb-hdd install, from previous version to the latest.