Friday, August 23, 2013

[solved] removable media - gid and uid fix

I typically maintain uniform UID's and GID's across the different distros I try. It seems to contribute to less troublesome back-ups which come with distro-hopping.

For example, I recently caused myself a problem. During the latest install, I established my standard UID of 1500. But I overlooked the usual procedure of creating a new group for myself with a 1500 GID. Instead, I placed myself into the "users" group, which had a GID of 100. The files I thereafter created possessed a 1500:100 stamp.

A couple of weeks following the install I attempted to back-up a diff. I attached a USB HDD I've had for several months, and which was formatted, including its folders, with my typical 1500:1500 ownership. Of course it has been no problem to copy from the 1500:1500 USB to my system. But when I attempted to back-up 1500:100 files from my system to the 1500:1500 USB, "permission denied" write errors were generated. Writing to the USB HDD as root would have overcome this, but wasn't the solution I wanted: "chown"-ing any and all 0:0 files to 1500:1500 seemed to be overlooking a more efficient solution.

After some thought, it seemed best to permanently change the primary group attached to my username on the desktop system. I wanted this to happen in a way that automatically assigned the new GID to all existing files in my home directory. Note that username is "patriot".

solution

  1. exited X to command line
  2. logged off - "exit"
  3. logged in as root
  4. created group 1500 (# groupadd foo -g 1500)
  5. moved "patriot" from group 100 into group 1500 (# usermod -g 1500 patriot) Note: give this a few minutes to complete; many file GID's are being updated.
  6. # nano /etc/group - verified patriot was in desired groups
  7. rebooted and logged in as user "patriot", per usual.

result

All files changed to 1500:1500 and no permission problems noted when backing-up to a USB HDD.

No comments: