0

I am trying to:

  • mount my 2TB external USB hard drive as my home directory at /home/peter
  • ensure that the home directory is owned by me (not root)
  • do all this automatically at bootup

Currently:

  • my drive is formatted to ext4
  • my drive is empty
  • I am running debian 7

I can reformat to another filesystem type if necessary, but I want to use the full 2TB on the drive.

The following fstab line mounts the drive incorrectly owned by root:

UUID=xxxx /home/peter ext4 nodev,nosuid 0 2

How can I mount the drive so that it is owned by peter (that's my login user on the PC)?

  • i'm trying to mount the external disk at /home/peter. i don't understand what you are saying. – mulllhausen Sep 24 '13 at 14:08
  • 2
    The output of ls -ld /home /home/peter once mounted would help clarify this question. – msw Sep 24 '13 at 14:42
  • 1
    No idea if this will work but you could try chowning /dev/sdX to your user – strugee Sep 24 '13 at 17:23
3

Try this as an /etc/fstab entry:

/path/to/device /mount/point/for/two2tbHDD ext4 umask=permissions,gid=peters_group_id,uid=peters_id 0 0

Once mounted, change ownership:

chown peter: /mount/point/for/two2tbHDD

Then change peter's home directory using

usermod -m -d /mount/point/for/two2tbHDD
  • Why not mounting to /home/peter? – peterph Sep 24 '13 at 22:12
  • @peterph yes.. /mount/point/for/two2tbHDD can be /home/peter too.. – Pravin Sonawane Sep 25 '13 at 2:28
1

the solution was simply to chown the home directory after the mount took place:

$ chown peter:peter /home/peter

while using the following fstab settings:

UUID=xxxx /home/peter ext4 defaults 0 2

this hadn't worked before with other fstab settings, but now /home/peter remains owned by peter each time i restart (previously root kept taking ownership of this directory on restart).

  • The "root taking ownership" is rather obvious - when the filesystem is not mounted, any changes to the directory pertain to the mount point itself (and not to the filesystem that might get mounted there one fine day). That's why answer by @Pravin states Once mounted, change ownership. – peterph Sep 25 '13 at 10:49
  • it was not obvious to me - i did chown peter:peter /path before mounting but then after the mount it was back to root root. this may have been because the ownership of the directories on the drive default to root unless otherwise set? – mulllhausen Sep 25 '13 at 11:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.