LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Help to understand how to automount a usb ntfs hard drive (https://www.linuxquestions.org/questions/linux-newbie-8/help-to-understand-how-to-automount-a-usb-ntfs-hard-drive-744174/)

gwagchunks 07-31-2009 10:56 AM

Help to understand how to automount a usb ntfs hard drive
 
Hi everyone

(Using ubuntu 9.04)
Sorry to post this one up, but I've have googled and still don't quite understand fstab and I really don't want to trash my system! I have an external usb hard drive I want to automount on bootup / startup. Not 100% sure of the best / safest way: here is some info on my drives

Code:

sudo fdisk -l

Disk /dev/sda: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x35073506

  Device Boot      Start        End      Blocks  Id  System
/dev/sda1  *          1      12748  102398278+  7  HPFS/NTFS
/dev/sda2          12749      14207    11719417+  83  Linux
/dev/sda3          14208      60801  374266305    5  Extended
/dev/sda5          14208      14331      995998+  82  Linux swap / Solaris
/dev/sda6          14332      60801  373270243+  83  Linux

Disk /dev/sdb: 1000.2 GB, 1000204886016 bytes
255 heads, 63 sectors/track, 121601 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0xddfe77c0

  Device Boot      Start        End      Blocks  Id  System
/dev/sdb1              1      121601  976760001    7  HPFS/NTFS


rich@htpc:~$ df
Filesystem          1K-blocks      Used Available Use% Mounted on
/dev/sda2            11535376  1929492  9019916  18% /
tmpfs                  1030344        0  1030344  0% /lib/init/rw
varrun                1030344      328  1030016  1% /var/run
varlock                1030344        0  1030344  0% /var/lock
udev                  1030344      176  1030168  1% /dev
tmpfs                  1030344        0  1030344  0% /dev/shm
lrm                    1030344      2392  1027952  1% /lib/modules/2.6.28-11-generic/volatile
/dev/sda6            373139168  1175216 371963952  1% /var/lib

*** ONCE MOUNTED THROUGH FILE MANAGER AND RUNNING DF AGAIN HERE IS THE DRIVE ***

/dev/sdb1            976760000  11307200 965452800  2% /media/Mybook

Here is my fstab file

# /etc/fstab: static file system information.
#
# Use 'vol_id --uuid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point>  <type>  <options>      <dump>  <pass>
proc            /proc          proc    defaults        0      0
# / was on /dev/sda2 during installation
UUID=af994ff2-a9b8-4977-b0ca-734b7ea56d93 /              ext3    errors=remount-ro 0      1
# /var/lib was on /dev/sda6 during installation
UUID=01cad37d-b1d5-4ec5-b107-e5af973da68c /var/lib        xfs    defaults        0      2
# swap was on /dev/sda5 during installation
UUID=537acc4a-eaf5-4d5f-bfa7-8af67666d63f none            swap    sw              0      0
/dev/scd0      /media/cdrom0  udf,iso9660 user,noauto,exec,utf8 0      0
/dev/fd0        /media/floppy0  auto    rw,user,noauto,exec,utf8 0      0

So the drive is a NTFS drive (I know,sorry!!!) and it's /dev/sdb1 and label is /media/Mybook

Thanks every so much.

tredegar 07-31-2009 12:28 PM

Well, if the device is always going to be at /dev/sdb1 (Think hard about what I am suggesting here).
You could put this in your /etc/fstab
Code:

/dev/sda2      /mnt/wherever        ntfs-3g defaults
Otherwise you might be better off mounting by UUID
Code:

UUID=7591fe5b-8907-406f-854e-321684957104 /mnt/wherever        ntfs-3g defaults
Obviously, your UUID will be different from mine.

Or use the LABEL:
Code:

LABEL=Mybook  /mnt/wherever        ntfs-3g defaults
See here: http://wiki.linuxquestions.org/wiki/Fstab

The directory /mnt/wherever needs to exist and have appropriate permissions for your security policy. Perms = 777 if you don't care who can read / write the drive. Eg (as root)
Code:

mkdir /mnt/Mybook
chmod 777 /mnt/Mybook

Before you try mounting the drive.

As usual with linux, there are many ways to achieve what you need.

udev is great for handling this sort of thing (especially if you have multiple drives / USB things that you want to plug in and out, and always have them appear at a sensible, known mountpoint).

See here: http://www.reactivated.net/writing_udev_rules.html

Have fun and welcome to LQ!

gwagchunks 07-31-2009 01:57 PM

Thanks Tredegar
 
Thanks for excellent reply! It has helped a lot. I have used the first suggestion in the post and it automounts perfectly. I will get around to using the uuid as I will probably add more drive in the future. Changing the permissions to enable sharing with other computers was a good call as well, I had not thought of that but I will probably do that in the near future. Thanks again! :D


All times are GMT -5. The time now is 02:53 AM.