In Windows operating system you have one root folder for device you connect (eg. C:,D:..), but in Linux, or any POSIX system in general, there is always only one root folder /. This root folder is a place, where your main hdd is usually mounted, but if you wish to work with another disk, or any other device, you will have to create a new folder and then mount the device to this folder.
Let's imagine, that you have just connected a flash disk and you would like to have a look at the data in your flash. First you will have to find the device descriptor for your flash. All descriptors are located in /dev folder. Every connected device should have its own descriptor in this directory. All hard drives descriptors are called /dev/hdx, where x is a letter. Your first hdd should be /dev/hda. But you will need to mount the partition, not the drive itself. Partitions are called /dev/hdxy, where x is still the same letter, and y is a number marking the partition. So if you have one partition on disk /dev/hda it should be called /dev/hda1.
There's one small complication with non-IDE drives. These are not called /dev/hdx, but /dev/sdx. The sd stands for "special device". But now, to make things easier, in kernel 2.6.31 and newer, there are no /dev/hdx devices anymore. Every storage device is now called /dev/sdx, no matter, whether it's an IDE device, or not.
If you have connected your flash, you should be shown some message showing the descriptor for your new device. Now imagine your new flash is called /dev/sdc and has one partition called /dev/sdc1, which you would like to mount to /mnt/flash. First thing you will have to do is to make sure, that you have folder /mnt/flash on your system and then mount the flash.
mkdir /mnt/flash
mount /dev/sdc1 /mnt/flash
Now you should be able to view the /mnt/flash directory, where you should see the contents of your flash disk. We have used the mount command for the first time. Its basic syntax is
mount -t type device dir
If you don't specify the -t option, as we did, mount will try to decide the type (e.g. filesystem) itself. Now you know how to mount a storage device but mount can do even more interesting things. You can for example mount a nfs share to your computer.
mount -t nfs 10.0.0.1:/share /mnt/server
This would mount a share folder located on 10.0.0.1 to our local /mnt/server folder. If your server is running Windows and has a samba share, you can mount it as well.
mount -t smbfs //10.0.0.1/share /mnt/server -o username=user,password=pass
You can see, that there is some difference. You will have to specify your username and your password to make it work.
So now we have something mounted, but you may also want to unmount something. We will use the umount command. Its syntax is really simple. It may look like this
umount /dev/sdc1
If you have troubles, like getting "device is bussy" you may also try this.
umount -l /dev/sdc1
This should work as a workaround. Please note, that if you mount with the mount command it will be mounted only until you restart the system. If you wish your mount to stay mounted even after reboot, you would have to use /etc/fstab file. We will have a look at this next time.