Open main menu

Linux and Unix Users Group at Virginia Teck Wiki β

Changes

Ubuntu

4,956 bytes added, 17:51, 25 February 2011
Automatically Mount Partitions
=Automatically Mount Partitions=
 
If you are dual-booting operating systems, you can mount your partitions after you have logged in, or you can mount partitions at boot. When mounting partitions at start-up you can do it either through programs that are out there, or you can mount it manually.
 
== Program ==
If you decide that you would like to mount your partitions through a program there are a few out there that can help you. One example program that will do this is psydm.
 
===Psydm===
<pre>
$ sudo apt-get install psydm
</pre>
 
Once this is installed, it is pretty self explanatory. The type of Hard drive should be noted. Often the partitions that will show are ext3 (linux), NTFS (Windows), and HFS+(Mac). Using the assistant will allow to mount the partition then and by default it will also mount at startup.
 
== Manually ==
DISCLAIMER: USING THIS METHOD, WILL WRITE YOUR FILE SYSTEM TABLE FILE. WHEN WRITING ON ANY SYSTEM FILE YOU CAN POTENTIALLY DAMAGE YOUR SYSTEM. USE AT OWN RISK.
 
To manually mount partitions at start up we will need to edit fstab (file system table) which is found at /etc/fstab. When deciding which partition to mount you need to see the partitions that are currently on your hard drive.
<pre>
$ sudo blkid
</pre>
 
 
 
The output will give you the partition, it's UUID, label (if it has one), and type of filesystem. The output should look similar to:
<pre>
/dev/sda1: LABEL="System Reserved" UUID="AEF4B555F4B5208F" TYPE="ntfs"
/dev/sda2: UUID="EA68C7FE68C7C791" TYPE="ntfs"
/dev/sda5: UUID="3eedabec-f260-4fd7-ace7-a76c2e3723a4" TYPE="ext4"
/dev/sda6: UUID="943d37c8-50f7-4959-9464-9e7386f14f7f" TYPE="swap"
</pre>
 
Where /dev/sda(x) is the hard drive. For this tutorial, we will mount /dev/sda2, which is the windows partition that is on my hard drive.
 
Before editing the fstab file, make sure that you back it up. To edit the fstab file, you can use one of two commands which will depend on preference (these commands will be in terminal).
Ubuntu:
<pre>
$ gksu gedit /etc/fstab
</pre>
Command line:
<pre>
$ sudo nano -w /etc/fstab
</pre>
 
Fstab should look something like this:
<pre>
# /etc/fstab: static file system information.
#
# Use 'blkid -o value -s UUID' 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).
#
# <file system> <mount point> <type> <options> <dump> <pass>
proc /proc proc nodev,noexec,nosuid 0 0
# / was on /dev/sda5 during installation
UUID=3eedabec-f260-4fd7-ace7-a76c2e3723a4 / ext4 errors=remount-ro 0 1
# swap was on /dev/sda6 during installation
UUID=943d37c8-50f7-4959-9464-9e7386f14f7f none swap sw 0 0
</pre>
 
The "#" sign will comment out anything and it will not be read. As I said earlier, we are going to mount /dev/sda2. However there are two ways to go about mounting this partition of your hard drive. Either by the UUID (shown earlier) or by /dev/sda(x). (Again it is personal preference of which you choose but I would suggest using the UUID as your file will remain consistent and as it says in fstab "UUID= as a more robust way to name devices that works even if disks are added and removed."
 
Now, on to mounting the partition.
 
<pre>
# Windows partition (Or whatever you want to call it.)
UUID=EA68C7FE68C7C791 /media/EA68C7FE68C7C791 ntfs rw,auto,user,fmask=0111,dmask=0000 0 0
</pre>
(The above entry is case specific, so make sure that everything matches.)
 
"UUID="(your hard drives UUID) will specify which hard drive. "/media/(UUID)" specifies the mount point, "ntfs" specifies the filesystem. The next line is what is important. If you want to be able to write to this partition when it is mounted, you will need to put "rw". If for some reason you are having trouble writing to this partition you may need to download the package "ntfs-3g", however this is the set-up I have, and it works just fine.
 
The line "rw,auto,user,fmask=0111,dmask=0000" will allow all users to mount, read, and edit the partition. If you don't want this, you can use uid (for users) and gid (for groups) after dmask to determine who will be able to do that. "dump" and "pass" are for use of native filesystems and will be set to "0", hens the "0 0" after "dmask=0000".
'''WARNING: If you do not fill out all of that information your system will NOT load correctly and you will have some problems.'''
 
If you system runs into problems loading after editing this file, it is more than likely because you stopped writing the file after entering "UUID=(the UUID)". To fix this you can use a live cd to re-write the file by running the system off of the cd and editing the file as root (you may just want to take the whole thing out completely and figure out what you did wrong.)
 
For further information visit,
https://help.ubuntu.com/community/AutomaticallyMountPartitions
Anonymous user