Quote:
Originally Posted by DarkLeon
How can I tell if I am in my c drive? Or is it called something else in Ubuntu ?
|
First, some background...
Linux doesn't have the same concept of drive letters as windows. Everything is part of a single virtual filesystem, starting simply as / (the root directory).
When you have extra disks or extra partitions, they are
mounted at some place in the virtual filesystem.
A simple example might be like this:
The machine has two hard disks. The first disk is mounted as root - it's files appear under the root directory /. The second drive is mounted under the /home directory, so everything under there is from the second disk.
When removable drives are connected to the machine, they are auto-mounted in sub-directories of the /media directory. For example, a USB pendrive gets mounted at /media/usbdisk, and all it's files are found in that directory.
The /etc/fstab file tells Linux where to mount different drives / partitions.
The extra bit of information you need to know to understand /etc/fstab is how Linux names drives and partitions. Here are a few of the common ones:
/dev/hda is the master drive on the first IDE channel. Partitions on that drive get numeric suffixes, so /dev/hda1 is the first primary partition of that drive, /dev/hda2 is the second primary partition and so on. Logical partition numbers start at 5.
/dev/hdb slave drive on the first IDE channel (second drive on the first IDE cable).
/dev/hdc is the master device on the second IDE channel. This is typically a CD drive.
/dev/hdd is the secondary slave IDE drive
/dev/fd0 is the first floppy disk drive
/dev/sda is the first SCSI drive
/dev/sdb is the second SCSI drive, etc.
Bare in mind that USB drives are handled through the SCSI driver system in Linux, so the get a /dev/sd? device name.
Partition numbers apply to all devices if the device supports partitions.
Knowing this, you can make some sense of the /etc/fstab file. In the example outlines above, it might look like this:
Code:
/dev/hda1 / ext3 defaults,errors=remount-ro 0 1
/dev/hdb2 /home ext3 defaults 0 2
OK, this is over-simplified because swap (virtual memory) is also described in the /etc/fstab, as well as things like the proc filesystem (which allows you to get information about the OS's state, like CPU details, process accounting information etc).
One last complication, the fstab file can use the volume label or drive serial number instead of the /dev/hd? name. Ubuntu Edgy does this by default, but it shows the /dev name in a comment above the line with the serial number.
OK, in this example we can see that the primary partition on the primary drive on the first IDE channel is mounted as root, and that the first primary partition of the slave drive on the first IDE channel is mounted as /home. The meanings of the other columns in this file can be fstab manual page (type "man fstab" to see it).
OK, to the answer of your question! Phew, took some time getting here, sorry!
There's a utility program called "df" which is installed on pretty much every Linux and Unix machine. If you tell it some directory/file name, it'll report the free space on the drive which that directory/file resides on. The nice thing it that it prints the device name on which the directory/file resides.
For example, to see the free space on the device on which the file /usr/share/doc/lsb-base/README.Debian resides (this is just some random filename I pulled out of the air), do this:
Code:
df /usr/share/doc/lsb-base/README.Debian
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/hda4 13733236 5742960 7292656 45% /
The output tells you that this file is on the device /dev/hda4, which is mounted as the root directory, "/". This is the forth primary partition on the master drive on the first IDE channel.