Printable Version of Topic

Click here to view this topic in its original format

Linuxhelp _ Tips and Tricks _ How to mount a drive or partition

Posted by: Corey Jul 9 2003, 09:06 AM

When coming from the Windows world, the idea of "mounting" a drive seems a bit strange, afterall, your used to popping in a cd and clicking on the icon in My Computer to open it up. You're used to Windows "just doing it" when it came to showing new partitions in the My Computer tab.

Think of "mounting" as inserting a filesystem into your current system. The beauty of mounting is that everything is in a nice neat structure, everything is a part of the filesystem and makes it easier to maintain.

You can mount anything from a cdrom to a hard drive. I will cover these 2 different mediums.

First thing, we need a mount point. Historically, Linux users (and distributions) use the directory /mnt to hold all the mount points. Mount points like /mnt/cdrom and /mnt/floppy were common. However, recently, different distributions are changing this "assumed" standard. SuSE puts cdroms and floppys in /media and windows partitions in /windows. While Debian uses /floppy and /cdrom . While all of these are fine for their uses, i'm still a fan of /mnt . So, here we go:

Mounting a CD-Rom

First off, create your mount point (note, your distribution may already have a mount point, this is just an example):
[quote]$ mkdir /mnt/cdrom[/quote]

Make sure you have a cd in the drive, and it is a Data cd (you cannot mount audio cds). And mount it with the following:
[quote]$ mount -t iso9660 /dev/cdrom /mnt/cdrom[/quote]

The above is a little tricky, especially the "/dev/cdrom" part. /dev/cdrom is usually a symlink to the appropriate cdrom device. If your system has more then one cdroms or a scsi device, this could varry. This goes beyond the scope of this PAQ, so you will have to determine which cdrom device is correct.

When you are finished with the CD, be sure to Un-Mount it because you cannot eject the cd until it's un-mounted.

[quote]$ umount /mnt/cdrom[/quote]

Hard Drive (Partition)

Hard drives and partitions can be a little more trickier then cdroms due to the many many different types of filesystems they could contain. Notice above in the mounting of the cdrom, I have one paramater "-t iso9660"? What this is doign is stating the filesystem of what is being mounted. This almost always needs to be stated so mount can mount it properly. The man page for mount (man mount) gives a list of every filesystem it supports as well as additional options to pass to mount. Some basic filesystems are:

ext2 - The Linux ext2 filesystem, which is currently the standard
ext3 - The Linux journalled filesystem
reiserfs - A fast journalled filesystem for linux
ntfs - The Windows NT filesystem
vfat - The Windows FAT16/FAT32 filesystems.

So, say you're dual-booting your linux system with Windows 98 and you want to have access to your files on that partition. First off, you would make the mount point:

[quote]$ mkdir /mnt/win98[/quote]

Now, mount the partition to that mountpoint:

[quote]$ mount -t vfat /dev/hda1 /mnt/win98[/quote]

This assumes that your Windows partition is located in /dev/hda1 , this can be easily figured out with the "fdisk -l" command to show you which one is the Windows system. Now, you are able to browse to that directory, read and write to the windows directory.

Note: The NTFS filesystem can only be mounted as read-only. So, if you mount this, you will only be able to read from it and not write any data. There are ways to mount it as read/write, but it is very dangerous and should not be done by anyone.

There is also a file located in /etc/fstab which automatically mounts your partitions on bootup. So, if you wanted your Windows partition to automatically be mounted on bootup, you would need to add it to this file. Please refer to the man page for instructions on how to do this.

Posted by: hughesjr Nov 15 2003, 11:24 AM

Mounting a Samba share is very similar (after installing the packages smbfs and smbclient).

The command is:

mount -t smbfs -o username=user,password=user_password //win-server-name/sharename /mountdir

-t smbfs is the filesystem type (smbfs).

-o username=user,password=user_password is a username and password (on the sharing computer) of a user who can access the share.

//win-server-name/sharename is the sharing computer's name and share name you created on the sharing computer.

/mountdir is where you want to mount the folders into your linux system.

(the packages needed are different for different linux distros .. for debain you need smbfs, smbclient ... for redhat/suse/fedora/mandrake use need samba-client, samba-common)

Powered by Invision Power Board (
© Invision Power Services (