Ubuntu – How to automount NTFS partitions

automountdual-bootmountntfs

I have two NTFS partitions, and I don't want to mount them manually every-time I start Ubuntu.

  • How can I do this?
  • Is there a tool or a code to use?
  • If so, is it safe to automount? specially when they are being used by another OS?

Best Answer

  • The most straightforward way that will work on most Linux systems is to add them to your fstab. But there are others. Each has their own headline in this answer.

    Note:

    If you get an error massage saying something about "root" or "permissions" it is because for most mounting options you will need root privileges. In Unity you can achieve that by prepending gksudo (graphical applications) or sudo to the usual command and typing your password. So, e.g. in case of ntfs-config you press Alt+F2 and type gksudo ntfs-config.


    Gigolo

    Gigolo Install gigolo

    Gigolo works hand in hand with Nautilus' remote file system and mounting capabilities. You need to add the partitions to your Nautilus bookmarks (Nautilus is Ubuntu's default file manager). After that you will find them in Gigolo. The rest is said in another answer of mine.


    Fstab

    Edit: Since guessing from your comments you are not that acquainted with linux I will explain the procedure in more detail:

    The fstab-method is cleaner and more basic than gui-tools or Gigolo. It will also work on other systems even those that are text-mode only. In principle you don't need to install anything. For each ntfs-partition you will have to add one line to the file called /etc/fstab. For me the line I added looks like this:

    #Windows-Partition
    UUID=<xxxxx> /media/win ntfs rw,auto,users,exec,nls=utf8,umask=003,gid=46,uid=1000    0   0
    

    The part that says UUID=<xxxxx> tells your system which partition to mount. If you follow this procedure and have duplicate devices showing up, replace UUID=<xxxx> with /dev/disk/by-uuid/<xxxxx>. Each partition has it's own unique UUID. Spaces are important, so best copy&paste the line. Replace auto by noauto to manually mount. Users should be in the group plugdev.

    Note that if this line is at the very end of your file there should be a newline after it. Mount will complain if you don't have it.

    Finding the UUID:

    Disk Utility and blkid

    Open Disk Utility and identify the proper partitions by their size (e.g. 120 GB), file system (e.g. ntfs) and name. Note their "Device:" file (e.g. /dev/sdb1). Instead you can run the following command in a Terminal such as gnome-terminal:

    sudo fdisk -l
    

    You can find out the UUID of your partitions by running sudo blkid in shell. The output looks somewhat like this:

    confus@confusion:~$ sudo blkid
    [sudo] password for confus: 
    /dev/sda1: LABEL="boot" UUID="cc425c68-704f-4836-9123-bbb3aea64471" TYPE="ext2" 
    /dev/sda2: UUID="1c8b1489-e111-481c-89f2-743203c3ee7d" TYPE="crypto_LUKS" 
    /dev/sda3: UUID="7258CB9858CB598D" TYPE="ntfs" 
    /dev/sda4: LABEL="HP_TOOLS" UUID="1405-0A4C" TYPE="vfat" 
    /dev/mapper/lukslvm: UUID="xZSNtR-MocS-dLMk-vOWa-Ay65-wS9b-GqaNhV" TYPE="LVM2_member" 
    /dev/mapper/vgubuntu-swap: UUID="f415f3b9-4e4d-48b1-99c2-605e16532f9e" TYPE="swap" 
    /dev/mapper/vgubuntu-root: UUID="62a862b4-e6c8-4efd-90b5-55eab8e83e39" TYPE="ext4"
    

    The correct UUID will have the proper device file in front of it and TYPE="ntfs" after. So for me the UUID is "7258CB9858CB598D". For you this number will be different. Also I have only one NTFS partition. Subitute my UUID in the lines you add to fstab by the one you found this way.

    Setting the mount point

    Now the mount point. For each partition this will be different. I chose /media/win. You can choose whatever you like. It just has to be an existing empty directory. You could just as well create the directory /home/yourusername/windows1 and then put it in your fstab.

    The other parameters in my line

    ntfs tells the fstab that it is an ntfs-type partition.

    rw,auto,user,exec,nls=utf8,umask=003,gid=46,uid=1000 0 0 is beyond the scope of this answer. Just use those values as they are. They should be fine. It you're interested, you can read an explanation of these parameters in the link I provided earlier.

    When you added the lines and did all of the stuff I described, save the file and run sudo mount -a in shell. If you can access your partitions through their mount points and no errors are printed out, then all went well. If not check for typos and obvious errors. Don't reboot if sudo mount -a displays errors! With errors a reboot might fail.

    Finding your user and group id

    You can find out your user and group id with the id command.

    confus@confusion:~$ id
    uid=1000(confus) gid=1000(confus) groups=1000(confus),4(adm),7(lp),20(dialout),24(cdrom),46(plugdev),112(lpadmin),120(admin),122(sambashare)
    

    ntfs-config

    A graphical tool ntfs-config Install ntfs-config is also available but not necessary (and its current version doesn't work in Natty Narwhal - suppose that will be fixed soon). Besides you might lose old settings in your fstab with this tool (e.g. mounting the cache in the memory), because it overwrites the /etc/fstab file instead of appending things.