| Erik's linux page: Linux information for beginners and advanced users | ||
|---|---|---|
| Prev | Chapter 2. Some general words about Linux, mostly for new users. | Next |
Some words about partitions, Linux way of accessing (E)IDE disks, Linux way of using partitions and some other talk..
When newbies ask me about installing Linux, there's a lot of confusion about partitioning your HD, and how Linux access your HD and so on.. I'll try to explain some of it..
What's all this about partitions, boot sectors etc ?
If you're going to understand the text below, you should know what a primary and extended/logical partition is. You should also know how Linux names partitions located on different drives.
This applies to (E)IDE drives, the controller type sitting in most PC's. I'll check out how SCSI works, could someone help me with the information.
Linux way of accessing hardware.
In Linux, and most UNIX operating systems, you access almost all the hardware by reading/writing virtual files, mostly located in the /dev directory. This might seem a strange method, but when you get used to it, it is really natural.
(E)IDE controllers, and partitions on hard disks
Every IDE controller can have 2 disks, one master and one slave. In new home computers of today, there's often a (E)IDE controller, which provides the possibility of attaching 4 drives. Every drive can have four primary partitions, and a larger number of logical partitions. A partition is a piece of the hard disk, with a size you decide.
The difference between Primary and Logical partitions
With DOS/windows and a few other operating systems, you can only see one primary partition at one specific moment. Running DOS or windows, they are named C:. There can be four primary partitions, a PC limit as stupid as the 640 kb DOS memory limit, there should be no foreseeable limits in the soft/hardware you use.. that's my opinion. Anyway, due to information I have, Linux can see all primary partitions at one time, and use them.
There can be a larger number of logical partitions. An operating system can see several logical partitions at once, making it possible to access them all at the same moment. This is why one should use logical partitions where possible. Some operating systems must have a primary partition to start from, including DOS, and windows 3.xx and 95. I don't think that's clever.
The device names of different hard disks/partitions in the Linux file system.
So, now when we know the difference between a master and a slave, and a primary and a logical partition, we can understand the system which Linux uses to name the different drives/partitions in it's file system.
the base name for a (E)IDE controlled disk is /dev/hd?. The ? is a single letter. The system goes like this:
/dev/hda - master disk on first controller
/dev/hdb - slave disk on first controller
/dev/hdc - master disk on second controller
/dev/hdd - slave disk on second controller
/dev/hda1 - master disk on first controller, first primary partition.
/dev/hda2 - master disk on first controller, second primary partition.
/dev/hda5 - master disk on first controller, first logical partition.
/dev/hda6 - master disk on first controller, second logical partition.
OK, now I understand what a partition is.. how do I use it ? How do I access C: ? (Or, the mount thing)
Linux doesn't present the user with stupid drive letters, it has a much more intelligent way of doing that.
A mounted file system..
The advantages of a mounted file system is many.. You decide where you want the space, you can mount different file systems without problems..
How does it work ?
Well.. first you need a root file system, the base of all directories, named '/'. The directory separator in Linux/UNIX is '/', not '\' as in DOS.. during system startup you tell the kernel you want as an example /dev/hda5 as root file system. After that, you can tell the kernel, you want /dev/hda1 as /dosc and you access that drive exactly like any other directory. This way, you can mount just a few directories from a local hard disk, and keep shared volumes with large amounts of data at a central server. There's a protocol for sharing files over a network, the Network File System, and you won't notice the difference accessing that directory, from accessing a directory at your hard disk.
I hope you understand.. perhaps not a good explanation.
Two examples
To mount your floppy disk, located at /dev/fd0 and formatted with the MS DOS filesystem at /floppy you'll have to execute mount -t msdos /dev/fd0 /floppy. The -t msdos tells mount what filesystem to expect, sometimes you don't have to give this, it'll find out itself. Don't forget to umount /floppy before removing the floppy.
To mount your CDROM, let's say it's a ATAPI CDROM located at the second EIDE controller as master, you'll execute the following command. mount -t iso9660 /dev/hdc /cdrom. Make sure /cdrom exists, otherwise it won't work.
Using MSDOS floppies - the easy way
Sometimes you have to exchange data with users not running Linux. In such situations MSDOS floppy disks are quite useful. Now, how do you easily access those disks from Linux? Mtools is the answer! It allows formatting, copying and deletion of files on MSDOS formatted floppies. All this without mounting the filesystem, though you can of course mount a MSDOS filesystem from within Linux if you want to.
Formatting a MSDOS floppy
The first thing you might want to do when you need to use MSDOS disks, is to format it. This is done using the mformat command.
Finding the correct parameters to feed to mformat can be tricky. The best way is probably to use the minfoprogram with an existing (already formatted floppy). As an example, here is what minfo thinks one of my MSDOS floppies looks like
hostname:erik ~ % minfo a: device information: =================== filename="/dev/fd0" sectors per track: 18 heads: 2 cylinders: 80 mformat command line: mformat -t 80 -h 2 -s 18 a: bootsector information ====================== banner:"(k'\\IHC" sector size: 512 bytes cluster size: 1 sectors reserved (boot) sectors: 1 fats: 2 max available root directory slots: 224 small size: 2880 sectors media descriptor byte: 0xf0 sectors per fat: 9 sectors per track: 18 heads: 2 hidden sectors: 0 big size: 0 sectors physical drive id: 0x0 reserved=0x0 dos4=0x29 serial number: B03212D4 disk label="NO NAME " disk type="FAT12 " |
As you can see, it gives the correct parameters to format a floppy disk the same way using mformat
Moving, Copying or deleting files on a MSDOS floppy
Copying and moving are quite similar operations. Use the mcopy and mmove commands. The syntax is what you would expect. Ie mcopy *.exe a: works just the way copy would do under some DOS clone.
Deleting files is done with the mdel command. 'nough said :-)