I have 2 disks in my machine, one holds my system and /home data. The other is a disk used purely for backing up /home/user stuff just in case.

The backup disk is an NTFS disk (I never got round to changing to ext since moving from 'doze).

Problem was that the backup disk wasn't being automatically mounted fr all users, so when I try to run my backup script as a user it would fail miserably.

I could mount the disk through the X system explorer without problem. But if I booted the machine and hadn't explicitly/manually mounted the backup disk my script would fail. This becomes a problem when trying to access that disk either from a remote ssh connection or through an automated process (eg cron backup).

After a bit of reading I ended up sorting the problem by adding an entry to the /etc/fstab file. This tells the system how to mount the disks.

Using gparted (a partitioning tool in Gnome) I was able to find the references for my disks that the system understood....
/dev/sdb1 - is the 1st partition on the disk labelled sdb, this is my boot partition
/dev/sdb2 - is the 2nd partition on the disk labelled sdb, this is the system + /home partition
/dev/sda1 - is the backup disk. It's before the other disk (sdA vs sdB) I think because the backup disk is on the old style ATA connector, the main disk is SATA.

I added the following line to /etc/fstab:
/dev/sda1        /media/backup          ntfs-3g  defaults     0 0

NOTE: Since upgrading to Fedora 13 I had to change the driver entry from ntfd-3g to ntfs. The upgrade to Fedora 13 was failing to boot so long as ntfs-3g remained in fstab file.
  • "/dev/sda1" is telling system this line is about that disk partition.
  • "/media/backup" is telling the system at what point to mount the partition, meaning users should be able to access the drive by navigating to /media/backup
  • "ntfs-3g" is a reference to the software that should read the disk. I think this is like a driver for the filesystem, but don't quote me on that!
Finally I need to create a create a directory at the point in the system where I want to mount the disk. This threw me for a while, I had assumed that would be automagically handle by the system. Apprently not.

So, as root:
$ mkdir /media/backup

That dir gets created as root, meaning users can't write to it. So when I run my backup script as my user it fails. Not ideal.

So with my limited Linux knowledge I have 2 options:
  1. set permissions to write for everyone
  2. set the group to one my user is a member of
I don't like option 1. Idea of setting permissions to writable for everyone I don't like.
I went for option 2, setting the group to my user group. In reality the backup drive will only be used by my user.

I should probably change it to a group that all users are a members of to do it properly. No doubt someone that knows more about *nix than I do will tell me of a better way to do things!

All done. Now when I log in I can read from the backup disk that appears to live at /media/backup. More importantly I can run my backup script (rsync).

Some more details here:
http://en.wikipedia.org/wiki/Fstab

Including some info on some of the options available in the last 3 columns I haven't explained (as I used defaults).

19-April-2010 and Motorola Dext

My new phone (Motorola Dext) wouldn't mount automagically like most any other USB device I plugged in (inc old Nokia N85). So I started looking into fstab entries again and came across a useful option known as 'user'.

My Motorola Dext fstab entry now reads:
UUID=3732-6131  /media/droid    vfat    defaults,user   0       0

Where UUID is the ID of the memory card, /media/droid is the mount point in the system, vfat is the filesystem driver. The important bit is the options field of the fstab file which reads 'defaults, user' meaning "use the defaults" (I don't know what they are!) and "user" to tell fstab that all users can mount this drive.

I shall be adding 'user' to the options for the NTFS backup drive in my fstab shortly!