Page 1 of 2 12 LastLast
Results 1 to 10 of 18

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

  1. #1
    Join Date
    Jan 2009
    Location
    Romania, Bucharest
    Posts
    800

    Default 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.
    openSUSE Tumbleweed x64, KDE Framework 5

  2. #2
    Join Date
    Jun 2008
    Location
    Groningen, Netherlands
    Posts
    20,199
    Blog Entries
    14

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

    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.
    ° Appreciate my reply? Click the star and let me know why.

    ° Perfection is not gonna happen. No way.

    https://en.opensuse.org/openSUSE:Board#Members
    http://en.opensuse.org/User:Knurpht
    http://nl.opensuse.org/Gebruiker:Knurpht

  3. #3
    Join Date
    Jan 2009
    Location
    Romania, Bucharest
    Posts
    800

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

    Quote Originally Posted by Knurpht View Post
    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.
    openSUSE Tumbleweed x64, KDE Framework 5

  4. #4
    Join Date
    Nov 2009
    Location
    West Virginia Sector 13
    Posts
    15,789

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

    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.

  5. #5
    Join Date
    Jan 2009
    Location
    Romania, Bucharest
    Posts
    800

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

    Quote Originally Posted by gogalthorp View Post
    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?
    openSUSE Tumbleweed x64, KDE Framework 5

  6. #6
    Join Date
    Aug 2010
    Location
    Chicago suburbs
    Posts
    13,054
    Blog Entries
    3

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

    Quote Originally Posted by MirceaKitsune View Post
    But will the installer give the new user the same UID as the one it detects in my home directory?
    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
    Code:
    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.
    openSUSE Leap 15.1; KDE Plasma 5;
    testing Leap 15.2Alpha

  7. #7
    Join Date
    Jun 2008
    Location
    Groningen, Netherlands
    Posts
    20,199
    Blog Entries
    14

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

    Quote Originally Posted by MirceaKitsune View Post
    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?
    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 !!
    ° Appreciate my reply? Click the star and let me know why.

    ° Perfection is not gonna happen. No way.

    https://en.opensuse.org/openSUSE:Board#Members
    http://en.opensuse.org/User:Knurpht
    http://nl.opensuse.org/Gebruiker:Knurpht

  8. #8
    Join Date
    Jan 2009
    Location
    Romania, Bucharest
    Posts
    800

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

    Quote Originally Posted by Knurpht View Post
    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.
    openSUSE Tumbleweed x64, KDE Framework 5

  9. #9
    Join Date
    Jun 2008
    Location
    Groningen, Netherlands
    Posts
    20,199
    Blog Entries
    14

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

    Quote Originally Posted by MirceaKitsune View Post
    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.
    ° Appreciate my reply? Click the star and let me know why.

    ° Perfection is not gonna happen. No way.

    https://en.opensuse.org/openSUSE:Board#Members
    http://en.opensuse.org/User:Knurpht
    http://nl.opensuse.org/Gebruiker:Knurpht

  10. #10
    Join Date
    Nov 2009
    Location
    West Virginia Sector 13
    Posts
    15,789

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

    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

Page 1 of 2 12 LastLast

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •