Page 1 of 3 123 LastLast
Results 1 to 10 of 23

Thread: Automounting EXT4 partition

  1. #1
    Join Date
    Sep 2009
    Beans
    93
    Distro
    Ubuntu

    Automounting EXT4 partition

    I have a separate ext4 partition in my hard disk which I want to automount at login. So I added the following line in /etc/fstab:

    /dev/sda4 /media/sda4 ext4 defaults 0 0

    But now the device mounts in read-only mode. Need root access to change its contents. How can I mount the drive so that it does not need root privileges?

  2. #2
    Join Date
    Jun 2006
    Location
    UK
    Beans
    Hidden!
    Distro
    Ubuntu 16.04 Xenial Xerus

    Re: Automounting EXT4 partition

    It's not actually being mounted read only, but owned by root, which is why you can't write to it.

    Let it be mounted to /media/sda4, and then from a terminal:

    Code:
    sudo chown yourusername: /media/sda4
    Substitute your login name for yourusername and don't forget the trailing colon.This has the interesting effect of changing the ownership of the ext4 filesystem rather than the mountpoint. You will now be able to write to it.

    If you want other accounts to be able to write to it, you can also:

    Code:
    sudo chmod 777 /media/sda4
    Ubuntu 16.04 Desktop Guide - Ubuntu 17.10 Desktop Guide - Forum Guide to BBCode - Using BBCode code tags - IRC #ubuntuforums

    Member: Not Canonical Team

    Please do not PM me about your forum account unless you have been asked to. The correct place to contact an admin about your account is here.

  3. #3
    Join Date
    Dec 2009
    Beans
    5,918

    Re: Automounting EXT4 partition

    2 options:

    (1) Take possession of the mount point:
    Code:
    sudo chown thameera /media/sda4
    (2) Change permissions so everyone can access it:
    Code:
    sudo chmod 0777 /media/sda4
    There are many variations of the two depending on your requirements.

  4. #4
    Join Date
    Dec 2009
    Beans
    5,918

    Re: Automounting EXT4 partition

    coffeecat, You'll have to admit that was just plain spooky

  5. #5
    Join Date
    Sep 2009
    Beans
    93
    Distro
    Ubuntu

    Re: Automounting EXT4 partition

    @Morbius1, @coffeecat
    Thanks a lot for the quick answers. I entered both commands in a terminal but still the contents are read-only :S
    Any idea? Do I have to restart the system or something?

  6. #6
    Join Date
    Jun 2006
    Location
    UK
    Beans
    Hidden!
    Distro
    Ubuntu 16.04 Xenial Xerus

    Re: Automounting EXT4 partition

    Quote Originally Posted by thameera View Post
    Thanks a lot for the quick answers. I entered both commands in a terminal but still the contents are read-only :S
    Was sda4 mounted to /media/sda4? It won't work if the partition wasn't mounted. If the partition wasn't mounted you only modify the mountpoint and then those modifications get overridden when you mount it.

    If you've already included that line in your /etc/fstab, then either reboot, or run:

    Code:
    sudo mount -a
    Then run the chown and chmod commands again.

    If you haven't yet edited your fstab with that line then:

    Code:
    sudo mount /dev/sda4 /media/sda4
    ... and run the chown and chmod commands.
    Ubuntu 16.04 Desktop Guide - Ubuntu 17.10 Desktop Guide - Forum Guide to BBCode - Using BBCode code tags - IRC #ubuntuforums

    Member: Not Canonical Team

    Please do not PM me about your forum account unless you have been asked to. The correct place to contact an admin about your account is here.

  7. #7
    Join Date
    Sep 2009
    Beans
    93
    Distro
    Ubuntu

    Re: Automounting EXT4 partition

    No, I have already mounted the partition. Doesn't work though :S

  8. #8
    Join Date
    Jun 2006
    Location
    UK
    Beans
    Hidden!
    Distro
    Ubuntu 16.04 Xenial Xerus

    Re: Automounting EXT4 partition

    Quote Originally Posted by Morbius1 View Post
    coffeecat, You'll have to admit that was just plain spooky
    No. Just great minds thinking alike.

    To pick up your "take possession of the mount point", the interesting thing is that if the partition is mounted you actually take possession of the root of the filesystem, not the mountpoint (which I think is where the OP is going wrong atm). Which can be demonstrated if you do a 'ls -l' on /media before mounting the partition, after chown-ing it, and then again after unmounting it. It's a subtle but little-appreciated distinction. See my posts #7 and #12 in this thread for a little more:

    http://ubuntuforums.org/showthread.php?t=1658937

    Would you be so kind as to pass the word around on this? It deserves to be better known and understood.
    Ubuntu 16.04 Desktop Guide - Ubuntu 17.10 Desktop Guide - Forum Guide to BBCode - Using BBCode code tags - IRC #ubuntuforums

    Member: Not Canonical Team

    Please do not PM me about your forum account unless you have been asked to. The correct place to contact an admin about your account is here.

  9. #9
    Join Date
    Jun 2006
    Location
    UK
    Beans
    Hidden!
    Distro
    Ubuntu 16.04 Xenial Xerus

    Re: Automounting EXT4 partition

    Quote Originally Posted by thameera View Post
    No, I have already mounted the partition. Doesn't work though :S
    OK. It should work. Let's get some more information. Post the contents of your whole /etc/fstab and the output of these commands:

    Code:
    sudo fdisk -lu
    sudo blkid
    ls -l /media
    mount
    Ubuntu 16.04 Desktop Guide - Ubuntu 17.10 Desktop Guide - Forum Guide to BBCode - Using BBCode code tags - IRC #ubuntuforums

    Member: Not Canonical Team

    Please do not PM me about your forum account unless you have been asked to. The correct place to contact an admin about your account is here.

  10. #10
    Join Date
    Sep 2009
    Beans
    93
    Distro
    Ubuntu

    Re: Automounting EXT4 partition

    Here are the results of the commands:


    thameera@thameera-laptop:~$ sudo fdisk -lu

    Disk /dev/sda: 160.0 GB, 160041885696 bytes
    255 heads, 63 sectors/track, 19457 cylinders, total 312581808 sectors
    Units = sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk identifier: 0x80028002

    Device Boot Start End Blocks Id System
    /dev/sda1 * 2048 41015295 20506624 83 Linux
    /dev/sda2 41017342 44920831 1951745 5 Extended
    /dev/sda3 44920832 240232447 97655808 83 Linux
    /dev/sda4 240232448 312580095 36173824 83 Linux
    /dev/sda5 41017344 44920831 1951744 82 Linux swap / Solaris
    thameera@thameera-laptop:~$ sudo blkid
    /dev/sda5: UUID="0cad0cfe-d05f-401a-a101-802eff380e8b" TYPE="swap"
    /dev/sda1: UUID="4f9d9f0f-aabd-4e4e-bb2b-bab26341fcae" TYPE="ext4"
    /dev/sda3: UUID="cdfdf285-d3df-4978-b783-b908544fb41e" TYPE="ext4"
    /dev/sda4: UUID="3b41917c-7475-46c1-9942-ba28a706bcd5" TYPE="ext4"
    thameera@thameera-laptop:~$ ls -l /media
    total 4
    thameera@thameera-laptop:~$

    Any ideas?

Page 1 of 3 123 LastLast

Bookmarks

Posting Permissions

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