Well I am a newbie in Linux world. Everyday learning by working. I use dual booting and in one drive Windows 7 is installed and in another drive Ubuntu 14.04 LTS is installed. My first O/S was windows 7. There was few drives like Workshop, Movies, Soft etc. Now I was about to change drives in terminal to access files stored in different drives. After spending couple of hours I discovered a way to access different files in different drives. What I did is first of all I mounted lets say /dev/sda2 drive in /media/username folder using this command....
$ sudo mount /dev/sda2/ media/username
Once mounted then I can easily change directories by using cd
command.
Now my questions are...
- Is this really a correct way to change drives to access files?
- I can go forward like
$cd /media/username
but how to go backward? I mean go back to root or go back to media? In windows CMD I am usingcd..
to go one folder back. Is there any similar command for terminal? - What is the difference between drive and partition?
- How to unmount a drive or any file?
- My last question is as far as I know in Linux files are arranged
under root
/
directory. If so then it might don't respect windows drive systems. If so then all files should be accessed without mounting any drive to /media/username folder?
First, note there is a typo in
mount
your command. It should be:Here
/dev/sda2
is the device (in this case, a hard drive's partition) you want to access, and/media/username
is your mountpoint, i.e., the location in the filesystem where you want to mount the device.To answer your questions:
Yes, using
cd
is the normal way to change directories. Andmount
is perfectly fine to mount devices that are not already mounted. If you mount it often, you may want to make an entry in/etc/fstab
so that in the future you can mount a particular device to a particular mountpoint with self-defined options, e.g., by simply writingmount /media/username
. You may even want to consider mounting it automatically, at boot time. There is a lot of excellent documentation on the subject. Just search forfstab
.I guess you want to do a bit of reading about the Linux filesystem. There's also good documentation for this, see, e.g., here for a short overview.
/
is the root folder in which everything is contained, organized in various subfolders. Here's a few hints concerningcd
:cd
(without arguments) will get you to your home folder, typically/home/username
cd -
will get you to the previous folder (where you were before you changed to the current folder)cd ..
will get you to the parent folder (one level up). This is equivalent tocd..
in Windows CMD.cd /
will get you to the root folder, though I personally rarely need that.A (hard) drive is actually a disk that you can store data on. It is usually divided into several partitions. Perhaps confusingly, in the Windows world these partitions are also called drives. This is not the case in the Linux world, though. We simply call them partitions, or perhaps "devices" in a technical context.
To unmount a mounted device, use the command
sudo umount <MOUNTPOINT>
, e.g., in your example,...where
/media/username
is a mounted partition (you could also usesudo umount /dev/sda2
, though this is perhaps less intuitive). Simply writemount
(without arguments) to see a list of all currently mounted devices with their mountpoints.In Linux, you have to mount each of your Windows "drives" on a separate mountpoint. You are completely free to choose where, and you already know how to do it, as you showed with your
mount
command. :)