[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: a quick fstab questions



notoneofmyseeds wrote:
> Reco wrote:
> > > Any other ideas please, this is driving me nuts!!!!!!!!!!!!!!!!!!!!!!!
> >
> > This is something to be expected. You're using ext4 filesystem, which
> > carefully preserves files (directries, etc) permissions.
> > So you can mount the filesystem as a user, but it's not enough by itself.
> > It's the filesystem's permissions that prevent you from viewing its
> > contents.
> >
> > Recommended solution to the problem includes chown(1) and chmod(1).
>
> Thanks a lot, at the risk of loosing data, I ask; how can I safely chown or
> chmod?

You haven't really included enough information in the thread yet.  You
are mounting an ext4 file system over a USB disk.  What, in general,
is on the disk?  Is only your own data?  Is it the root of an
operating system?  This is rather important.  If I suggest a recursive
chmod it will destroy an operating system.  But if it is only your own
data files, an external $HOME backup for example, then that is fine.

Since ext4 is a full Unix-like file system all files are owned by
users and groups.  The file system never stores names.  Everything is
stored by number.  The first user on a Debian system is usually 1000
by number.  You can tell this by looking at the output of the 'id'
command and by listing files in your home with 'ls -l -n'.

If you are the second user then your uid is usually 1001 and the next
1002 and so forth.  Transporting files on the file system drive from
one system to another the other system might have different uid
numbers.  Let's say you were 1001 on one system but 1000 on a
different system.  The numbers would not match.  You as uid=1000 would
not have permission to modify uid=1001 files.

Of course root on the system mounting that disk would have
permissions.  I tend to never modify backup files.  I tend to always
mount backup copies read-only to prevent accidents to the backup.  If
the backups had uid=1002 and I needed to recover them to 1001 then I
would copy the files off backup without modifying them.  Then in the
recovery area I would modify the new copies to be the right user.

Tools such as cp simply copy files and permissions from the source to
the destination.  Tools such as rsync are fancy and try to map uids.
Both tools have options to control this behavior.

  $ cp --help | less
       --preserve[=ATTR_LIST]
              preserve the specified attributes (default: mode,ownership,time-
              stamps), if  possible  additional  attributes:  context, links,
              xattr, all
      --no-preserve=ATTR_LIST  don't preserve the specified attributes

  $ man rsync
      --numeric-ids           don't map uid/gid values by user/group name

Additionally rsync has many options for controlling this and various
behavior.  See --usermap=STRING, --groupmap=STRING for example.

Let's say I ignore those options for the moment.  Let's say I copy
those files from backup to recover them.

  # rsync -av /mnt/path/to/backup /home/foo/restore/

That will probably leave the uids:gids owning the files incorrect.
They will be as on the source mapped through the local /etc/passwd
file mapping.  After restoring them they will need to be corrected.

  # chown -R user1:user1 /home/foo/restore

That will recurse (-R) down the /home/foo/restore directory tree and
change the ownership and group of everything to user1:user1.

Since I don't know what is on your usb disk it is hard to give
specific advice.  I can only say the above in general terms.  Modify
as needed for your situation.

> This is sad and frustrating. I'm sweating.

Don't sweat it!  :-)

Bob

Attachment: signature.asc
Description: Digital signature


Reply to: