Mounting Partitions Automatically
Mounting Partitions Automatically
Mounting Partitions Automatically
1 of 10
https://help.ubuntu.com/community/AutomaticallyMount...
Partners
Support
Community
Ubuntu.com
Login to edit
Search
AutomaticallyMountPartitions
Mounting Partitions Automatically
There are broadly two aproaches Per-user mounting (usually under /media)
Systemwide mounting (anywhere, often under /mnt)
Per-user mounting does not require root access, it's just
automating the desktop interface. Systemwide mounts
(/etc/fstab) can allow access from before login, and are
therefore much more suitable for access through a network,
or by system services.
Commands should be entered on a terminal (Type terminal
in the program launcher of recent unity based Ubuntu
releases, or select Applications -> Accessories -> Terminal
from the menus on older releases).
Per-User Mounts
udisks
This is the modern replacement for gnome-mount. It's not
gnome specific.
When you mount a disc normally with the file browser
(nautilus etc) it mounts disks by interacting with udisks
behind the scenes.
You can do the same thing on the command line with the
udisks tool.
Contents
1. Mounting Partitions Automatically
2. Per-User Mounts
1. udisks
1. Finding the device
name of your Partition
2. Finding the UUID of
your partition
3. Adding to startup
2. Gnome-Mount
1. Installation
2. Usage
3. Systemwide Mounts
1. Manual Setup Help
2. Viewing the system's
physical information
3. Deciding which partitions to
mount
4. Preparing the system
5. Editing Ubuntu's filesystem
table
1. <file system>
2. <mount point>
3. <type>
4. <options>
5. <dump>
6. <pass>
7. <option> example
8. <type> example
9. fstab example
6. Mounting Fakeraid
7. Mounting and checking the
02/24/2013 04:42 PM
2 of 10
https://help.ubuntu.com/community/AutomaticallyMount...
eg
/usr/bin/udisks --mount /dev/sdb1
The bit after --mount is the device name of the partition you
want to mount. (/dev/something)
partitions
8. Using pysdm
1. Installation
2. Usage
4. Hints, Tips, and Technical
Information
1. Adding a bookmark
2. More technical tips
1. Symlinking for greater
convenience
2. Unmounting a
partition to prevent
unwanted access
3. Technical background
information
1. How Linux manages
partitions
Of course you need to replace 1313-F422 with the UUID of the device you want to mount.
Adding to startup
From the Ubuntu dash (click logo in top left) find startup applications or press Alt+F2 and type
gnome-session-properties
Push the Add button.
Choose a name, paste in your command and push the Add button
Gnome-Mount
This method is only available in Hardy and Karmic.
02/24/2013 04:42 PM
3 of 10
https://help.ubuntu.com/community/AutomaticallyMount...
There is no need to setup mountpoints or filesystems. This is particularly interesting if you want to use
the automatically created mountpoints instead of manually specifying them for each disk.
Installation
sudo apt-get install gnome-mount
Usage
You can mount a disk as a normal user via
gnome-mount -p myDiskLabel
where myDiskLabel is your disk name (e.g Data). To have the disk mounted each time you startup (thus
removing the password prompt on first usage of the disk), simply add above line to your list of startup
applications (System->Preferences->Startup Applications). Note that while mounting through
gnome-mount will not need a password, unmounting or remounting via Nautilus will still invoke the
password prompt.
Systemwide Mounts
Three methods will be discussed:
1. The first method is manually editing Ubuntu's filesystem table. This sounds more complex than it
really is.
2. The second method, for versions 6.06 and later, is described at MountingWindowsPartitions.
3. The third - simple - method is to install the pysdm package (in Gutsy) and then use SystemAdministration-Storage Device Manager without any manual editing of the fstab file, and
disregard most of the instructions that follow. (NOTE: psydm removed from repositories in 12.10
and presumably beyond - see http://ubuntuforums.org/showthread.php?p=12338212. Use of arios
automount or mount manager not recommended)
02/24/2013 04:42 PM
4 of 10
https://help.ubuntu.com/community/AutomaticallyMount...
fdisk will print the partition tables of all your disks. The output from this command will look something
like this;
Disk /dev/hda: 40.0 GB, 40013261856 bytes
255 heads, 63 sectors/track, 4439 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot
/dev/hda1 *
/dev/hda2
/dev/hda3
Start
1
639
4526
End
638
4525
4635
Blocks
5124703
31222327
497980
Id
b
83
82
System
W95 FAT32
Linux
Linux swap
If the system has multiple hard disk drives, multiple lists will be displayed.
English name
Linux type
W95 FAT32
Microsoft FAT32
vfat
vfat
vfat
Not used
Microsoft NTFS
ntfs
Apple_HFS
Apple HFS
hfsplus
A list of the form '/dev/hda1: /media/windows/ (vfat)', where '/dev/hda1' is the device, '/media/windows'
is the arbitrary location where the partition will appear when mounted, and 'vfat' is the Linux type, should
be created on paper, containing all partitions to be added.
02/24/2013 04:42 PM
5 of 10
https://help.ubuntu.com/community/AutomaticallyMount...
If a response like ls: /media/windows: No such file of directory is returned, the location is open. If a list of
files or nothing is returned, the location exists already, and the planned location will need to be altered.
Once every location has been confirmed as free, run the following command for each entry, replacing
'/media/windows' with the chosen location.
sudo mkdir /media/windows
or command line
nano -w /etc/fstab
The file opened contains lines of the form <device> <location> <Linux type> <options> <dump>
<pass>. Every element in this line is separated by whitespace (spaces and tabs).
# /etc/fstab: static file system information.
#
# <file system>
<mount point>
proc
/proc
# /dev/hdb1
UUID=e776c7ac-61d1-4ca2-8b59-0c874933b2de /
# /dev/hdb5
UUID=5ff60812-91c2-42bd-b628-8cb530f073fb none
/dev/hdc
/media/cdrom0
/dev/fd0
/media/floppy0
/dev/mapper/sil_aiaedhaeafaa1
/media/raid
<type>
proc
<options>
defaults
ext3
defaults,errors=
swap
udf,iso9660
auto
reiserfs
sw
user,noauto,exec
rw,user,noauto,e
user,nosuid,exec
<file system>
The first field, (fs_spec), describes the block special device or remote filesystem to be mounted.
For ordinary mounts it will hold (a link to) a block special device node (as created by mknod(8)) for the
device to be mounted, like /dev/cdrom or /dev/sdb7. For NFS mounts one will have <host>:<dir>,
02/24/2013 04:42 PM
6 of 10
https://help.ubuntu.com/community/AutomaticallyMount...
<mount point>
The second field, (fs_file), describes the mount point for the filesystem. For swap partitions, this field
should be specified as none. If the name of the mount point contains spaces these can be escaped as
\040.
<type>
The third field, (fs_vfstype), describes the type of the filesystem. Linux supports lots of filesystem types,
such as adfs, affs, autofs, coda, coherent, cramfs, devpts, efs, ext2, ext3, hfs, hpfs, iso9660, jfs, minix,
msdos, ncpfs, nfs, ntfs, proc, qnx4, reiserfs, romfs, smbfs, sysv, tmpfs, udf, ufs, umsdos, vfat, xenix, xfs,
and possibly others. For more details, see mount(8). For the filesystems currently supported by the
running kernel, see /proc/filesystems. An entry swap denotes a file or partition to be used for swapping,
cf. swapon(8). An entry ignore causes the line to be ignored. This is useful to show disk partitions which
are currently unused.
<options>
The fourth field, (fs_mntops), describes the mount options associated with the filesystem.
It is formatted as a comma separated list of options. It contains at least the type of mount plus any
additional options appropriate to the filesystem type. For documentation on the available options for
non-nfs file systems, see mount(8). For documention on all nfs-specific options have a look at nfs(5).
Common for all types of file system are the options noauto (do not mount when "mount -a" is given,
e.g., at boot time), user (allow a user to mount), and owner (allow device owner to mount), and
comment (e.g., for use by fstab-maintaining programs). The owner and comment options are Linuxspecific. For more details, see mount(8).
<dump>
The fifth field, (fs_freq), is used for these filesystems by the dump(8) command to determine which
filesystems need to be dumped. If the fifth field is not present, a value of zero is returned and dump will
assume that the filesystem does not need to be dumped.
<pass>
The sixth field, (fs_passno), is used by the fsck(8) program to determine the order in which filesystem
checks are done at reboot time. The root filesystem should be specified with a fs_passno of 1, and other
filesystems should have a fs_passno of 2. Filesystems within a drive will be checked sequentially, but
filesystems on different drives will be checked at the same time to utilize parallelism available in the
hardware. If the sixth field is not present or zero, a value of zero is returned and fsck will assume that the
02/24/2013 04:42 PM
7 of 10
https://help.ubuntu.com/community/AutomaticallyMount...
<option> example
To learn more about options, type 'man mount'.
Description Accessible by everyone
FAT(16/32)
user,auto,fmask=0111,dmask=0000
partition
user,auto,fmask=0177,dmask=0077,uid=1000
NTFS
partition*
rw,auto,user,fmask=0111,dmask=0000
rw,user,auto,fmask=0177,dmask=0077,uid=1000
Apple
Partition
user,auto,file_umask=0111,dir_umask=0000 user,auto,file_umask=0177,dir_umask=0077,uid=1000
*If you want write access to your file system, you should set the filesystem type to 'ntfs-3g' instead of
'ntfs'. You may need to install the package 'ntfs-3g' for this to work, so make sure it is installed before
you use ntfs-3g.
**uid=1000 restricts access to the user created while installing Ubuntu. 1001 is the user created after that,
and so forth. gid=# may be used with or in place of uid to grant access to a group. However, group and
user enumeration is beyond the scope of this article.
<type> example
Note for international users: if your filesystem contains funny symbols, you may need to add an option
for utf-8 support.
Filesystem type Option to enable utf-8 support
ntfs
nls=utf8
vfat
utf8
smbfs
iocharset=utf8,codepage=unicode,unicode
fstab example
So, to grant all users access to '/dev/hda1', which will be located at '/media/windows', and is of type 'vfat',
the line added would be.
02/24/2013 04:42 PM
8 of 10
/dev/hda1
/media/windows
vfat
https://help.ubuntu.com/community/AutomaticallyMount...
user,fmask=0111,dmask=0000
This entry is case-sensitive. In general, lower-case letters are used to avoid confusion.
'dump' and 'pass' are only of use to native filesystems. They can be set to '0' for all additional partitions.
For every item in the list of partitions to be mounted, add one line of the form above to the end of the
fstab file.
Mounting Fakeraid
Its assumed you have formated you raid set using dmraid command with instructions found at
FakeRaidHowto
You need to know the name of your raid set
sudo dmraid -ay
RAID set "sil_aiaedhaeafaa" already active
RAID set "sil_aiaedhaeafaa1" already active
/media/raid
reiserfs
user,nosuid,exec,nodev
Reboot
To verify that the partitions were mounted properly, open Gnome's file browser and direct it to the
locations at which the partitions were mounted. Click the 'File System' button to access '/', and navigate
from there. If the partition being examined contains files, the modifications were successful, and the
partitions will be automatically mounted every time the system is restarted.
If no files are found, please see XChatHowto and join #ubuntu on irc.freenode.net.
Using pysdm
Pysdm is a program to automatically setup partitions every time Ubuntu starts. This is verified to work in
9.04.
02/24/2013 04:42 PM
9 of 10
https://help.ubuntu.com/community/AutomaticallyMount...
Installation
sudo apt-get install pysdm
Usage
Select each partition you want to change in the list. Note the type. Often it is ext3 (Linus) or NTFS
(Windows). Use assistant and press OK. By default the partition is mounted at boottime. You can also
mount the partition now. Press Apply. Done.
A link to the directory '/media/windows' will be placed on the desktop. Files may be dragged into it, it
may be opened, it can be renamed and moved, and if it proves to be annoying, it can be deleted like any
other file without risking damage to its contents.
This process is called symlinking because the link created is symbolic. It merely points to the location
being referenced.
02/24/2013 04:42 PM
10 of 10
https://help.ubuntu.com/community/AutomaticallyMount...
partition or device, then unmount the device, preventing "accidental" access. (The potentially jokingly
malicious user would need to know the filesystem table, and while that information isn't well hidden, it's
hard to access without drawing attention.)
Try the following command to unmount a partition.
sudo umount /media/windows
The partition mounted at '/media/windows' will be unmounted, and attempts to access it will yeild only an
empty directory. To bring it back later, either reboot, or simply run the following command.
sudo mount /media/windows
CategoryBootAndPartition CategoryCommandLine
AutomaticallyMountPartitions (last edited 2013-01-18 19:50:15 by dez93-2000 @ 86-45-249-215dynamic.b-ras3.mvw.galway.eircom.net[86.45.249.215]:dez93-2000)
02/24/2013 04:42 PM