Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm in a bit of an odd situation. I've recently been working on switching from debian to arch, and I've got my home partition for both pointing to the same partition (different usernames, so that's not an issue).

What I want to do is one of two things, either:

  1. Set up user on arch with same username and group as debian, and have everything just sort of work! OR
  2. Move files I'd like to share between home folders to their own partition, and mount it with fstab.

For the second one, I have around 150gb of files that would need moved to their own partition, and i've got about 15gb of free space on my home partition. So what I'd want to do is somehow make a 10gb ext4 partition, move 10gb-ish of files, expand the partition again, move files again, etc until all the files are moved to their own partition.

I can do it manually, but it'd be easier if I could say "Move 10GB-ish of files from here to there, and then resize it and repeat until I'm out of files".

Is that even possible?

share|improve this question
up vote 3 down vote accepted

The data and configuration files in the /home/ directories should be distribution agnostic, as it is related to applications rather than the OS. Some distributions might tweak their version of applications to use different folder names in /home/rob for example, but you shouldn't need to do much more than a rename of the folder or a symlink to get it to match what the application expects.

So creating a user on arch that has ready access to the files and directories already present in the debian home directories should not be much of a problem.

The first thing you need to do is work out the UID of the debian user, and make sure this is the same on arch. The UID is the "real" user id, the one you login with is just a human representation of the uid. Lets say that your arch user is 'rob', and rob's home director is /home/rob:

 $ ls -alnd /home/rob
 drwxr-xr-x 94 1000 1000 12288 Jul  3 21:36 /home/rob

The uid and gid (group id) are the third and forth columns. So this folder is owned by uid 1000 and gid 1000. On the debian side, this would correspond to the username and groupname you are familiar with in the passwd:

$ grep 1000 /etc/passwd
$ grep 1000 /etc/group

So you can see the group name is also 'rob' in this case. This is a distribution choice - some will by default create users with a primary group of the same name, and some will create a users group (often gid 100) and make this the primary. In terms of sorting this out, it doesn't matter too much, particularly if you are the sole user.

I can't remember what arch does, but I am going to assume it creates a users group with gid 100.

So we just need to create a new user rob, and point it at the folder, and make sure it is set up with the correct uid:

$ adduser --home /home/rob --uid 1000 --no-create-home --gid 100 rob

Or if you want to create a group for rob first, do this:

$ adduser --group --gid 1000 rob


$ adduser --home /home/rob --uid 1000 --no-create-home --gid 1000 rob

Now set the password for the rob account

$ passwd rob

And login, and it should have access just as it did on arch.

share|improve this answer
ls -alnd is great. Debian sure does use the username as group name, and has it as gid 1000, and arch does use a generic "users" group at 100. Just make the uid and gid match and it should be okay is alright with me! Will be trying it out later when I boot into arch to set things up. – Rob Jul 5 '12 at 23:16
Pretty much worked fine. man usermod and man groupmod were big helps. I changed the uid of the original account to 1001, made a new one with the right settings, and logged in and it didn't work! Oh no! But I forgot that it was pointing to the original user's home folder for some things on boot, and once I changed that everything was better – Rob Jul 6 '12 at 15:48

Option #1 has a good chance of working. You just need to make the uid and gid match. Use groupadd -g and useradd -u to add them to the user database with manually selected uid and gid matching the ones you find on Debian with id -a

find /home -printf 'user %u %U\ngroup %g %G\n' | sort -u

Hopefully the list just contains the uids and gids for your non-privileged user accounts, and the ones from the other system are reported either with the corrent names or as numbers with no name. If the same uid or gid shows up twice in the list with two different names, things are more complicated.

For the ones that are reported without names, use groupadd -g gid group and useradd -u uid -g gid username to create user database entries giving them their names. Then run passwd username to set a password for the user you created.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .