Mount your Disks

External USB (and firewire) disks may be mounted, but not at the places you want and without the ownership you need if you do not normally log in as root. Also, Debian might not use ntfs-3g to mount NTFS Windows disks.

Check the computer file system to see whether your Windows disk is mounted somewhere. If so, see whether it does hold your Windows files (maybe down in the Users folder somewhere). You want to figure out what device the disk is. Is it /dev/sda1, /dev/sda2, ...?

Try mounting the disk using

  sudo -u root mkdir /c 
  sudo -u root mount -t ntfs-3g /dev/sda1 /c
The preamble sudo -u root is only needed when you are not logged in as root. On my machine, /dev/sda1 is the recovery Windows disk, and the normal Windows disk is /dev/sda2, so I must use sda2 instead of sda1. Old Linux versions might use hda instead of sda. To see what is on the disk that you just mounted, try ls /c or more generally
  sudo -u root ls /c
  sudo -u root ls /c/Users

If you are not logged on as root, you need to check that your numeric user ID and group ID are indeed 1000. Do

  ls -la
  ls -na
The third and fourth columns should give your user and group IDs in the output of the second command.

Add the Windows disk to the system file /etc/fstab that mounts the disks during boot with the proper parameters:

  sudoedit -u root /etc/fstab
or just nano /etc/fstab if you are logged in as root. At the end of the file add a line of the form
/dev/sda1 /c ntfs-3g defaults,uid=1000,gid=1000 0 0
if you do not log in as root, or just
/dev/sda1 /c ntfs-3g defaults 0 0
if you do. Of course, substitute the appropriate values of your system for sda1 and 1000. The purpose of the uid and gid is to give you permission to change and delete your own files. Otherwise, you will be refused that permission.

External USB disks can be mounted in similar ways. I have two that I like to see mounted in locations /h and /j. To do so, I created /h and /j like /c above. Then in my particular situation, I could use an /etc/fstab file of the form

#                        
proc            /proc           proc    defaults                   0       0
/dev/sda6       /               ext3    relatime,errors=remount-ro 0       1
/dev/sda5       none            swap    sw                         0       0
/dev/scd0       /media/cdrom0   udf,iso9660 user,noauto,exec,utf8  0       0
/dev/sda2       /c              ntfs-3g	defaults,uid=1000,gid=1000 0       0
/dev/sde1       /h              vfat    defaults,uid=1000,gid=1000 0       0
/dev/sdd1       /j              vfat    defaults,uid=1000,gid=1000 0       0
If you do not know the type of file system, look it up in the properties of the disk or try "auto". Leave uid and gid out if you log in as root.

However, there is a problem. Depending on exactly what USB port they are hooked up to, and when, my H and J disks might have different device names than /dev/sde1 respectively /dev/sdd1. But I still want to back up to the same physical disk. Therefor it is better to use hardware addresses for at least your USB disks. You can find them in a terminal using, e.g.,

sudo vol_id /dev/sdd1
which tells me that /dev/sdd1 (the J disk) has the following properties:
ID_FS_USAGE=filesystem
ID_FS_TYPE=vfat
ID_FS_VERSION=FAT32
ID_FS_UUID=D55F-3383
ID_FS_UUID_ENC=D55F-3383
ID_FS_LABEL=J
ID_FS_LABEL_ENC=J

I can now use the UUID to ensure that it is always the J disk that is mounted in directory /j. My actual /etc/fstab file follows this procedure and it actually is:

#                
proc            /proc           proc    defaults        0       0
UUID=db6f8822-98c7-4394-b067-3be67d6c9088 /               ext3    relatime,errors=remount-ro 0       1
UUID=0dd38a63-e21e-44db-bb08-19706cd62546 none            swap    sw              0       0
/dev/scd0       /media/cdrom0   udf,iso9660 user,noauto,exec,utf8 0       0
UUID=1C0694D10694AD70 /c	ntfs-3g	    defaults,uid=1000,gid=1000	0  0
UUID=4466-C6C4	      /h	vfat	    defaults,uid=1000,gid=1000	0  0
UUID=D55F-3383	      /j	vfat	    defaults,uid=1000,gid=1000	0  0
Do not mess up the lines that mount the system disk and swap space!

Check that after reboot, you can indeed freely access your disks. To get rid of a badly mounted disk on /j, use umount /j. First make sure no terminal window or file browser windows uses that disk. To try out a different mount interactively, use something like

sudo -u root mount -t vfat -o defaults,uid=1000,gid=1000 /dev/sdd1 /j
or just
mount -t vfat -o defaults /dev/sdd1 /j
if you are logged in as root. Try auto instead of vfat if you are unsure about the file system. See man mount for more.

A problem with Ubuntu is that it does not automatically put links on the desktop for disks mounted like that. Therefor, in a terminal window, I did it myself using:

cd Desktop
ln -s /c C
ln -s /c/f/dvdlib dvdlib
ln -s /home/dommelen Home
ln -s /h H
ln -s /j J
The folder /c/f/dvdlib on my Windows disk contains a listing of the contents of my collection of DVDs. For dommelen, substitute your username, or replace /home/dommelen by /root if you login as root.

When at work, I like to have my disk on the college Sun cluster mounted on my private PC. The normal way to do that is using Samba. Unfortunately, the college requires plain text passwords, and modern Linux versions of Samba will only transmit encrypted ones. A fix up is to open a file browser window, and then go into the File/ menu and select "Connect to Server." Use "ssh" and specify as folder the full path to your home folder on the remote cluster as found from pwd, in my case "/home/facstaff/dommelen". Your disk will be mounted much like it was a local disk. (But with definite limitations: usually you must move the files to a local disk before you can really use them.) The method works very nicely for my Debian desktop at work. My home laptop with Ubuntu seems to be losing the connection a lot. I have not examined carefully why.


Applies to software obtained May 2009.
Return to Linux on Lifebook S6520