Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I have a partition to hold my media files and photos. But it does not mount automatically. So for when I open shotwell it lists all my photos as "Missing" until I open the partition in Nautilus and then restart shotwell. Is there a way to have it mount on login?

share|improve this question
    
Why is it not mounted during boot? Is it a removable device or ...? –  Riccardo Murri Oct 14 '10 at 22:49
add comment

3 Answers

up vote 2 down vote accepted

fstab Syntax

Quote: [Device] [Mount Point] [File_system] [Options] [dump] [fsck order] Device = Physical location.

/dev/hdxy or /dev/sdxy.

x will be a letter starting with a, then b,c,.... y will be a number starting with 1, then 2,3,....

Thus hda1 = First partition on the master HD.

See Basic partitioning for more information

Note: zip discs are always numbered "4". Example: USB Zip = /dev/sda4.

Note: You can also identify a device by udev, volume label (AKA LABEL), or uuid.

These fstab techniques are helpful for removable media because the device (/dev/sdxy) may change. For example, sometimes the USB device will be assigned /dev/sda1, other times /dev/sdb1. This depends on what order you connect USB devices, and where (which USB slot) you use to connect. This can be a major aggravation as you must identify the device before you can mount it. fstab does not work well if the device name keeps changing.

To list your devices, first put connect your USB device (it does not need to be mounted). By volume label: Code:

ls /dev/disk/by-label -lah

By id: Code:

ls /dev/disk/by-id -lah

By uuid: Code:

ls /dev/disk/by-uuid -lah

IMO, LABEL is easiest to use as you can set a label and it is human readable.

The format to use instead of the device name in the fstab file is:

LABEL= (Where is the volume label name, ex. "data").

UUID= (Where is some alphanumeric (hex) like fab05680-eb08-4420-959a-ff915cdfcb44).

Again, IMO, using a label has a strong advantage with removable media (flash drives).

See How to use Labels below.

For udev: udev does the same thing as LABEL, but I find it more complicated. See How to udev for a very nice how to on udev.

Mount point. This is where the partition is mounted or accessed within the "tree" (ie /mnt/hda1). You can use any name you like. In general

  1. /mnt Typically used for fixed hard drives HD/SCSI. If you mount your hard drive in /mnt it will NOT show in "Places" and your Desktop.
  2. /media Typically used for removable media (CD/DVD/USB/Zip). If you mount your hard drive in /media it WILL show in "Places" and your Desktop.

Examples:

  1. /mnt/windows
  2. /mnt/data
  3. /media/usb

To make a mount point: Code:

sudo mkdir /media/usb

File types:

auto: The file system type (ext3, iso9660, etc) it detected automatically. Usually works. Used for removable devices (CD/DVD, Floppy drives, or USB/Flash drives) as the file system may vary on these devices.

Linux file systems: ext2, ext3, jfs, reiserfs, reiser4, xfs, swap.

Windows: vfat = FAT 32, FAT 16 ntfs= NTFS

Note: For NTFS rw ntfs-3g

CD/DVD/iso: iso9660

To mount an iso image (*.iso NOT CD/DVD device):
Code:

sudo mount -t iso9660 -o ro,loop=/dev/loop0 <ISO_File> <Mount_Point>

Options:

defaults = rw, suid, dev, exec, auto, nouser, and async.

Options for a separate /home : nodev,nosuid,relatime

My recommended options for removable (USB) drives are in green.

auto= mounted at boot noauto= not mounted at boot

user= when mounted the mount point is owned by the user who mounted the partition users= when mounted the mount point is owned by the user who mounted the partition and the group users

ro= read only rw= read/write

VFAT/NTFS:

Ownership and permissios of vfat / ntfs are set at the time of mounting. This is often a source of confusion.

uid= Sets owner. Syntax: may use user_name or user ID #. gid= sets group ownership of mount point. Again may use group_name or GID #.

umask can be used to set permissions if you wish to change the default. Syntax is "odd" at first. To set a permissions of 777, umask=000 To set permissions of 700, umask=077

Best is to set directories with executable permissions and file with read write. To do this, use fmask and dmask (rather then umask): dmask=027 fmask=137

With these options files are not executable (all colored green in a terminal w/ ls)

Linux native file systems: Use defaults or users. To change ownership and permissions, mount the partition, then use chown and chmod.

Note: Warning re: sync and flash devices: Warning

Additional Options:

* sync/async - All I/O to the file system should be done (a)synchronously.
* auto - The filesystem can be mounted automatically (at bootup, or when mount is passed the -a option). This is really unnecessary as this is the default action of mount -a anyway.
* noauto - The filesystem will NOT be automatically mounted at startup, or when mount passed -a. You must explicitly mount the filesystem.
* dev/nodev - Interpret/Do not interpret character or block special devices on the file system.
* exec / noexec - Permit/Prevent the execution of binaries from the filesystem.
* suid/nosuid - Permit/Block the operation of suid, and sgid bits.
* ro - Mount read-only.
* rw - Mount read-write.
* user - Permit any user to mount the filesystem. This automatically implies noexec, nosuid,nodev unless overridden.
* nouser - Only permit root to mount the filesystem. This is also a default setting.
* defaults - Use default settings. Equivalent to rw, suid, dev, exec, auto, nouser, async.
* _netdev - Used for network shares (nfs, samba, sshfs, etc), mounting the network share is delayed until after the boot process brings up the network (otherwise the mount will fail as the network is not up).

Dump Dump: Dump field sets whether the backup utility dump will backup file system. If set to "0" file system ignored, "1" file system is backed up.

Fsck order Fsck: Fsck order is to tell fsck what order to check the file systems, if set to "0" file system is ignored.

share|improve this answer
    
Wow, Super complete answer! Thanks so much! –  Lifeling Oct 17 '10 at 3:32
add comment

If the partition is NTFS type (Windows), then you have to, first of all, install ntfs-3g driver through the Ubuntu Software Center, Synaptic or by typing the following line in the console (Applications->Accessories->Terminal):

sudo apt-get install ntfs-3g

If you haven't already, create the folder that will be used as mount point.

sudo mkdir /media/music (you can call it "music" or whatever you like)

Now you have all things set, you can start to follow this steps:


1. Get the info about the disk

Get the UUID of the partition, which is a serial key that identifies the disk.

sudo blkid

An example output line should look like this:

/dev/sda5: UUID="246699c0-1262-4d0d-94dd-6496b33467d4" TYPE="ext3"


2. Edit the fstab configuration file

This file contains a list of devices and their mounting rules (automatic, on demand, etc.). It is located at /etc/fstab

Open the text editor as super-user and edit the file:

gksudo gedit /etc/fstab

Check the output of the command used in the previous step and take notice on

  • partition TYPE (example: ext4);
  • UUID, provided by the blkid command;

and add the following line:

UUID=xxxxxxxx-xxx-xxx-xxx-xxxxxxxx /mount/point/ file-system defaults 0 0
  • UUID should be replaced with the serial key obtained with the blkid command
  • file-system should be replaced with the TYPE value.
share|improve this answer
    
You're missing the mountpoint, between the UUID and the file-system type. –  Marius Gedminas Oct 15 '10 at 0:09
    
Oh, you're right! I'll edit it. Thanks. –  Astiam Oct 15 '10 at 7:13
add comment

Check your /etc/fstab - That holds all the information for partitions to be mounted. If it is listed there, check that it has "auto" and "user" in the options section. If it isn't there, then it depends on what your filesystem is what you would put in the line.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.