Mount Partitions in Ubuntu



There is much confusion about mounting partitions in Ubuntu.  The best method is to add a line in your /etc/stab.  This file controls how Ubuntu mounts partitions.  This page will deal mainly deal with internal hard drives and such.  Ubuntu automatically mounts devices such as USB drives, firewire devices, flash cards, digital cameras, Zip drives, Jaz drives, etc.

With the inception of Ubuntu Feisty there is a GUI tool for NTFS configuration and mounting called ntfs-config.  This package is not availabe in Edgy or earlier distributions.  The only drawback of of using the ntfs-config tool is that it either selects ALL NTFS partitions to be read/write or read only.  If you have several NTFS partitions and want to make some read/write and others read only you will need to edit your fstab manually.  

To install the ntfs-config  package type the following in a terminal window:

sudo apt-get -y install ntfs-config


This package will install the NTFS Configuration tool along with ntfs-3g package.  To access the NTFS Configuration tool go to Applications--->System Tools and Click on NTFS Configuration Tool.  There is a good tutorial over at ubuntugeek.com, click here to read that tutorial.

First thing first is that we need to find out what kind and where the partition is.  To do this simply type the following command:

sudo fdisk -l

The output will look something like this:

Disk /dev/hda: 250.0 GB, 250059350016 bytes
255 heads, 63 sectors/track, 30401 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes


   Device Boot      Start         End      Blocks   Id  System
/dev/hda1   *           1        3102    24916783+   7  HPFS/NTFS
/dev/hda2            3103       16850   110430810    f  W95 Ext'd (LBA)
/dev/hda3           16851       30401   108848407+  83  Linux
/dev/hda5            3103       16473   107402526    7  HPFS/NTFS
/dev/hda6           16474       16850     3028221   82  Linux swap / Solaris


The location and name of the drive is /dev/hdax where x is an integer designation of the drive partition.  BTW hda is Parallel ATA and sda will be Serial ATA or SCSI if you were curious.

You could also load up Gnome Partition Editor and it will display the partitions and names.

Next we will need to then modify you /etc/fstab to have the partitions mounted.  First thing we need to make a folder in your /media folder for the mount to go to.  If you are mounting a windows drive type the following:

sudo mkdir /media/windows

The word windows is not magic but it is used in a descriptive sense.  We use the
/media folder as an icon will appear on your desktop linking you to that partition.  If you prefer you can use the /mnt folder for a more traditional approach.  Some people make a folder in the root called /windows, it does not matter just make sure you put the correct folder in your fstab.

We now will need to edit your fstab file.  Type the following command in a terminal:

sudo gedit /etc/fstab

This will bring bring up your drive mountings configuration text file.  At the bottom we will need to add the following line:

/dev/hda1       /media/windows ntfs  nls=utf8,umask=0222  0   0


This will tell Ubuntu to mount the Windows drive in the /media/windows folder.  The next option tells Ubuntu that it is an NTFS file system.  After the has been added you need to then save and reboot.  Once you log back on you will then see an icon on your desktop labeled "windows".  You can then access your windows partition and copy needed files over.

This method will not allow you to write as you will need the ntfs-3g package installed on your system.  There are rumors and reports that the ntfs-3g package can corrupt the NTFS file system.  I have used ntfs-3g for some time with no difficulties.  If you want to be able to read/write to NTFS dives type the following in a terminal:

sudo apt-get -y install ntfs-3g

After doing this substitute ntfs-3g for ntfs in your fstab file.

/dev/hda1       /media/windows ntfs-3g  defaults  0   0

You will now have read/write access when you login.  Remember, anyone on the PC will have read write access to the NTFS partitions using this approach.

Linux can read/write to ext2, ext3, fat, and vfat(FAT32).  Choose vfat for hard drives and USB drives as both your Windows and Linux can read and write to them with no difficulties.  I personally have not had any difficulties reading/writing to NTFS partitions using ntfs-3g.

After you have all your partitions setup in your fstab file type the following in a terminal:

sudo mount -a

What this command does is to execute all the mounting commands contained in your fstab file.

 



Repartitioning a hard drive that has Windows XP installed on another partition. (same physical drive)


If you are planning to repartition a partition on a drive that has Windows XP installed for dual booting purposes it is recommended to do the following:

You will have a new partition that needs to be mounted.

 


How to make that new partition usable by Ubuntu:

Another common question is that when you re-partition a hard drive or have other ext2 or ext3 partitions on a hard drive how can you make Ubuntu see them and then use them.  We will use the same methodology.  Suppose you have a 40G ext3 partition you wish to use.  Type the following again in a terminal

sudo mkdir /media/storage

The word storage is not magic again but it is used in a descriptive sense.  You will need to modify the fstab file again.

sudo gedit /etc/fstab

This will bring bring up your drive mountings configuration text file again.  Again at the bottom we will need to add a line:

/dev/hda3       /media/storage ext3  auto,defaults,rw  0   0

What the following line means is that the partition will be auto mounted, users can execute programs and be able to read and write (rw) to the drive.  Substitute hda3 for whatever drive you are trying to mount.

Note:  The usage of "
defaults" is so that one can execute programs, if you don't want execution of programs allowed use "user" in place of "defaults"

After this is done and you have saved the text file you need to adjust the permissions.  Type the following two commands in a terminal window.

Change ownership of the drive to the user that needs it.
sudo chown -R bob:bob /media/storage (substitute the username you wish to have access to the drive in place of bob)

Allow the user to read and write to the drive.
sudo chmod -R 755 /media/storage

After this is done type the following to execute your fstab modifications:

sudo mount -a

A good deal of the information here I learned from the following webpage http://www.tuxfiles.org/linuxhelp/fstab.html, other information I got through a trial end error approach.

Thanks to the guys over there.


I hope this helps.



Home