= Mounting Partitions Automatically = ||<>|| There are broadly two aproaches - * [[#Per-User_Mounts|Per-user mounting]] (usually under /media) * [[#Systemwide_Mounts|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 [[http://manpages.ubuntu.com/manpages/precise/en/man1/udisks.1.html|udisks]] tool. For example: {{{ /usr/bin/udisks --mount /dev/sdb1 }}} The bit after '''--mount''' is the device name of the partition you want to mount. ('''/dev/something'''). The command will mount ''/dev/sdb1'' in ''/media/'' where '''' is the identifier of the particular partition. Read below to find the uuid of your partition. === Finding the device name of your Partition === * Open your partition in nautilus (this makes sure it's mounted) * type '''mount''' in a terminal. You should see a line with your disk name on it like: {{{ /dev/sdb1 on /media/My-Happy-Disk type vfat .... }}} === Finding the UUID of your partition === A device name like /dev/sdb1 is based on where your physical drive is plugged in and the order the drives were made available to the computer, so if your computer changes the same command could mount a different partition. It's possible for this to happen just from a software upgrade. The solution is to use a UUID. A UUID is a globally unique name for the partition. A UUID will remain the same if you put an internal disk into an external USB caddy, or change the name of the partition. * Type '''ls -al /dev/disk/by-uuid/''' you will see an entry that matches the name you saw before: {{{ lrwxrwxrwx 1 root root 10 2012-02-15 10:23 1313-F422 -> ../../sdb1 }}} The UUID in the example is ''1313-F422'' You can now determine the command you need for mounting the device by UUID. For our example it would be {{{ /usr/bin/udisks --mount /dev/disk/by-uuid/1313-F422 }}} Of course you need to replace ''1313-F422'' with the UUID of the device you want to mount. Again, this will mount your partition in ''/media/'' which is not consistent with how nautilus mounts partitions. The partitions mounted by nautilus can be found in ''/media//'' with '''' being the current logged-in user. To keep the folder structure consistent an alternative command can be used that takes care of the correct mountpoint automatically: {{{ udisksctl mount --block-device /dev/disk/by-uuid/ }}} Of course, '''' needs to be adjusted to the correct UUID of your partition, e.g., 1313-F422 in this example. === 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 = 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 '''System-Administration-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) == Manual Setup Help == To mount hard disk partitions, you should have a basic understanding of the information below. Once installed you can browse to System > Network and File Systems > Basic understanding is still required... == Viewing the system's physical information == To read the layout of the physical disks in the system, the 'fdisk' command is used. Before panicking, realize that fdisk will be used with only non-destructive options; specifically, it will be used with 'l' (lower-case 'L', not '1'), which lists the partition table of the specified disk. {{{ sudo fdisk -l }}} As an example, here is what the output would be if one had a laptop with one internal drive, and usb drive plugged in: {{{ WARNING: GPT (GUID Partition Table) detected on '/dev/sda'! The util fdisk doesn't support GPT. Use GNU Parted. Disk /dev/sda: 180.0 GB, 180045766656 bytes 255 heads, 63 sectors/track, 21889 cylinders, total 351651888 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00000000 Device Boot Start End Blocks Id System /dev/sda1 1 351651887 175825943+ ee GPT Disk /dev/sdb: 8019 MB, 8019509248 bytes 255 heads, 63 sectors/track, 974 cylinders, total 15663104 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0xc3072e18 Device Boot Start End Blocks Id System /dev/sdb1 * 2192 15663103 7830456 b W95 FAT32 }}} If the system has multiple hard disk drives, multiple lists will be displayed. == Deciding which partitions to mount == Most systems only have ''/dev/hda'', which is the hard disk drive, and ''/dev/hdc'', which is the CD-ROM, or optical, drive. If more were listed when the command above was run, they can be identified as follows: ''hda'' is the first drive on the first IDE channel (0:0), ''hdb'' is the second drive (0:1), ''hdc'' is the third drive (1:0), and ''hdd'' is the fourth (1:1). SCSI and S-ATA disks have names like ''sda'' and ''sdb''. Look through the list generated above to identify the partition(s) to be mounted. The following table lists some common 'System' types, which may help this process. ||System name||English name||Linux type|| ||W95 FAT32||Microsoft FAT32||vfat|| ||W95 FAT32 (LBA)||Microsoft FAT32||vfat|| ||W95 FAT16 (LBA)||Microsoft FAT16||vfat|| ||W95 Ext'd (LBA)||Microsoft extended partition||Not used|| ||NTFS volume set||Microsoft NTFS||ntfs|| ||NTFS volume set||Microsoft NTFS with read-write access||ntfs-3g|| ||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. == Preparing the system == Look through the list which was just created. For every location ('/media/windows'), run the following command. {{{ ls /media/windows }}} 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 }}} == Editing Ubuntu's filesystem table == '''It is possible to break Ubuntu if some of the earlier lines in the file opened during this step are modified, so be sure to read this section carefully.''' Ubuntu's filesystem table is located at '/etc/fstab'. Open this file for editing by running the following command for Ubuntu {{{ gksu gedit /etc/fstab }}} or this command for Kubuntu {{{ kdesu kate /etc/fstab }}} or command line {{{ nano -w /etc/fstab }}} The file opened contains lines of the form '' ''. Every element in this line is separated by whitespace (spaces and tabs): {{{ # /etc/fstab: static file system information. # # Use 'blkid' 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). # # # / was on /dev/sda2 during installation UUID=a2db89ed-d599-4138-8838-0b950b6c3fbb / ext4 errors=remount-ro 0 1 # /boot/efi was on /dev/sda1 during installation UUID=AEF0-9F26 /boot/efi vfat defaults 0 1 # swap was on /dev/sda3 during installation UUID=df17fdb9-57a4-4302-856e-3cd656848355 none swap sw 0 0 }}} === === 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 :, e.g., `knuth.aeb.nl:/`. For procfs, use proc. Instead of giving the device explicitly, one may indicate the (ext2 or xfs) filesystem that is to be mounted by its UUID or volume label (cf. e2label(8) or xfs_admin(8)), writing LABEL=