2.1 Where are my drives?
Linux shows all the directories in one directory tree, irrespectively of what drives/hardware they are found on. Generally, this is a much better solution than the traditional DOS/Windows model--it completely abstracts the file system from the underlying hardware. You will appreciate this if you ever have to re-arrange or expand your hardware or add network resources. But for the users who are accustomed to the DOS way of dealing with drives, it adds some extra complexity.
Mount it. The mounting adds all the directories and files from your CD to your Linux directory tree so you can easily access them without the drive letter. As root, you can mount the CDROM with a command like this: mount -t auto /dev/cdrom /mnt/cdrom If this works, the content of your CD appears in the directory /mnt/cdrom Chances are this command will not work for you right away--you may have to customize it. Here is how it works. The command tells the operating system to mount a filesystem autodetecting the filesystem type ("-t auto"). The device is /dev/cdrom. The mountpoint (the directory where to which "mounting" takes place) is /mnt/cdrom. This directory must exist and be empty. If it does not exist, create it with: mkdir /mnt/cdrom If the mounting command fails, make sure that the device /dev/cdrom exists. If it doesn’t, where is your CDROM? Chances are it is something like /dev/hdb if you have an IDE CDROM. Try /dev/hdb instead of /dev/cdrom in the mount example above. If this fails, you can try /dev/hdc or /dev/hdd, if your cd is an IDE CDROM. If none of them is your CDROM, maybe you don’t have IDE but a SCSI CDROM? Then try /dev/sda1, dev/sda2, etc. ["hda" is the the primary IDE master drive, "hdb" is the primary IDE slave drive, "hdc" is the secondary IDE master (if you have two IDE interfaces on your computer), hdd is the secondary IDE slave, "sda" is the first SCSI interface and the number is the SCSI device id number.] It is a good idea to have a device /dev/cdrom anyway because some programs assume that it exists. If it does not exist on your system, you may create it as a symbolic link using, for example: ln -s /dev/hdb /dev/cdrom if your cdrom is the /dev/hdb drive. 62 If you cannot mount because "the device is already mounted or directory busy", perhaps the mountpoint /mnt/cdrom is your current directory. You have to change the directory to somewhere else in order to be able to mount to it; for example change the current directory to the root directory by issuing this command: cd / To unmount a mounted CD, exit the directory /mnt/cdrom and type as a root: umount /mnt/cdrom Your CDROM may refuse to eject the media if it is not unmounted. Also, you may have problems mounting the next CD if the previous one was not unmounted. If you cannot unmount because "the device is busy", perhaps /mnt/cdrom (or any subdirectory underneath) is your current directory? You need to change your current directory to somewhere else out of the mountpoint in order to unmount the device.
2.3 How to mount a floppy, zip drive, DOS/Windows partition, or a network drive?
Very much the same as CDROM--see the previous answer if you did not read it. Floppy. I can mount my floppy (as root) with: mount -t auto /dev/fd0 /mnt/floppy Again, make sure that the directory /mnt/floppy exists and is empty. Also, /mnt/floppy/ cannot be your current directory. After a successful mount, the files from the floppy appear in the directory/mnt/floppy/ . All the users will be able to read the files, but only root will be able to modify/delete the files. Please read further if you wanted the users to be able to write to the floppy. To unmount a floppy (you *must* do this before ejecting the disk!) use: umount /mnt/floppy If you cannot unmount because "the device is busy", perhaps the /mnt/floppy/ directory is your current directory. Exit it by typing (for example): cd which will change your current directory to your home directory. Zipdrive. I mount the parallel port external zipdrive (scsi emulation) with: 63 mount -t vfat /dev/sda4 /mnt/zipdrive The "-t vfat" is used here because zip disks come preformatted in the vfat filesystem, which is the filesystem of MS Windows with the long filename support. You won’t be able to eject the disk without unmounting it. All zipdrives (internal SCSI and IDE, external SCSI and parallel port) but the USB are supported under Linux (April 1999). DOS/Windows partition. I use a dual boot system with both Linux and MS Windows on the same computer. I can access files on the DOS/Windows partition after mounting it with the following command: mount -t vfat /dev/hda1 /mnt/dosdrive Again, you may have to customize this command depending on what partition your DOS filesystem is. The "hda1" means the first IDE hard drive (hd a), first partition (1); "hda2" is the first IDE hard drive, second partition; "hda3"--the first IDE hard drive, third partition; "hdb1"--second IDE hard drive, first partition (or just "hdb" if it is the CDROM installed as a slave on your first IDE interface). "hdc" is the third IDE drive, hdd is the fourth IDE drive. SCSI drives have analogous names but start with letters "sd", followed by the letter indicating the SCSI interface, followed by the number indicating the SCSI device id . For example sda4 means "first SCSI interface, id number 4". To mount so that all the users can read and write, you may want to try: mount -t vfat -o user,rw,exec,umask=000 /dev/hda1 /mnt/dosdrive This uses options (-o user,rw,exec,umask=000) to give absolutely everybody all the permission to all files on your DOS /dev/hda1 partition (you should ask yourself if this is really safe on your system). If users still can’t write to the DOS partitions, perhaps the permissions on your mountpoint need to be set. This command (executed by root) will set up the permissions on the mountpoint /mnt/dosdrive so that all users will be given rights to read, write and execute: chmod a=rwx /mnt/dosdrive Network File System (NFS). This is great for direct access to files that reside on another Linux computer. For mounting of a remote filesystem as NFS, first check if the NFS service is enabled (use the program setup). NFS also requires permission from the other computer. To configure the permissions on the server machine, run as root: netconf and adjust the setting under "Exported File Systems" menu. If you prefer to do it manually, the permissions are set in the file /etc/exports. My /etc/exports looks like this: 64 /usr hacker(ro) mars(ro) /home hacker(rw) mars(rw) /mnt hacker(rw) mars(rw) This gives the machines called hacker and mars the permission to mount the directories /usr/ (read-only access), /home and /mnt (read-write). If you set up your NFS properly, you should now be able to mount a network directory using a command like this: mount -t nfs mars:/home /mnt/mars_home This mounts the contents of the directory /home/ on a machine called "mars" into the directory /mnt/mars_home/ (which must exist and be empty). Many operating systems know NFS, but MS Windows doesn’t. Therefore MS Windows remote shares have to be dealt with differently. See the next answer for details.
2.4 How to mount a remote MS Windows filesystem through Samba?
2.5 Any quick way to access a file on a DOS/Windows floppy?
Use "mtools", no mounting required. For example, I can use the mdir command to quickly inspect the content of the root directory on my DOS floppy: 65 mdir a:\ I can also use mcopy to copy the file "autoexec.bat" from the root directory on the floppy to my current directory on Linux: mcopy a:\autoexec.bat . You have to be root to be able to write to a floppy. Type "mtools" to see the supported commands in the rich mtools set, which parallel the most popular DOS commands (for example: mformat, mtype, mren, mmove, mdel, mrd, mattib, ...), and use manual pages if you have problems using them. For example: man mtype will show me how to display a content of a text file on a DOS partition. To access DOS drives other than a: or b:, you have to configure mtools so as to indicate which devices are associated with other DOS "drive letters". This is quite easy--you just edit and modify the file /etc/mtools.conf. I typically use pico to do it (as root): pico /etc/mtools.conf For example, my /etc/mtools contains a line like this: drive c: file="/dev/hda1" which instructs the mtools that the partition "/dev/hda1" will be called "c:" The setup of /etc/mtools.conf requires just uncommenting (removing the "#" at the beginning of the line) and adjusting the appropriate entry.
2.6 Mounting works when I am root. Can a normal user mount?
You have to edit the file /etc/fstab as root to give the normal users the permission to mount a particular drive. For example I can use the pico text editor to do this: pico -w /etc/fstab The option "-w" turns off the long line wrap. Here is the content of my /etc/fstab: /dev/hda2 /ext2 defaults 1 1 /dev/hdc3 /home ext2 defaults 1 2 /dev/hdc2 /usr ext2 defaults 1 2 /dev/hdc4 swap swap defaults 0 0 /dev/fd0 /mnt/floppy auto noauto,users,rw 0 0 /dev/cdrom /mnt/cdrom auto noauto,user,ro 0 0 /dev/sda4 /mnt/zipdrive vfat noauto,user,rw,exec 0 0 66 /dev/hda1 /mnt/dosdrive vfat noauto,user,rw 0 0 none /proc proc defaults 0 0 hacker:/mnt/cdrom /mnt/hacker_cdrom nfs noauto,user,ro 0 0 hacker:/mnt/floppy /mnt/hacker_floppy nfs noauto,user,rw 0 0 hacker:/home /mnt/hacker_home nfs noauto,user,rw 0 0 hacker:/usr /mnt/hacker_usr nfs noauto,user,rw 0 0 Each line contains six space-delimited fields (this means that each line has six entries separated by white space). The first field is the name of the device. The second field is the mountpoint (an existing directory on your Linux system to which the resource will be mounted). The third is filesystem type. For removable media that may contain filesystems of several types, I use the option "auto" to let Linux probe which filesystem is currently present there. (The order in which they are probed is determined by the content of the file /etc/filesystems . You may want to make sure that it specifies "vfat" before "msdos" or the long DOS filename may be cut short.) The fourth field contains options: "auto" = mount the filesystem on the system startup; "rw" = read and write allowed; "ro" = read only, "user" = users have the permission to mount this filesystem (one can also use "users" to allow a user to mount and another user to unmount--otherwise only the user that mounted the filesystem can unmount it), "exec" execution of programs is permitted from this filesystem. The number in the field 5 specifies if the filesystem is to be backed up during a system backup, the number in the field 6 determines if to check up the filesystem integrity during bootup. The hacker stuff in my /etc/fstab are filesystems on another computer (called "hacker") on my home network and it serves here as an example of how to mount network resources. Check man fstab for more info. For example, if regular (non-root) users have the permission to mount the cdrom (the "user" option is specified), they can mount it using a command like this: mount /mnt/cdrom The command which the root uses for mounting (see here [p 63] ) will not work for a regular user because the regular user is restricted by the options in /etc/fstab and therefore s/he cannot specify simultenously both the device and the mountpoint. For a regular user to be able to write to a disk or execute a program on it, s/he must also be given the appropriate permission on the "mountpoint" directory. For example, this will give all the users all the permissions (read, write, execute) on the directory /mnt/floppy : chmod a+rwx /mnt/floppy Now (also the "rw" option is specified for the floppy in the /etc/fstab) the user will be able to write to a floppy. If the "exec" option was enabled in the /etc/fstab, the user would also be able to execute programs from the floppy. Please note that the DOS vfat file system doesn’t know about the file permissions the way Linux does. Linux manages this during mounting by giving the default file permissions on the mounted filesystem: the user who mounted the filesystem will be the owner of all files and will be given the right to write to the filesystem (if "rw" was specified in fstab) but other users can only read. If you wanted to change this behaviour, you could use the "umask=" option so that the appropriate line in 67 your /etc/fstab may look like this example: /dev/sda4 /mnt/zipdrive vfat noauto,users,rw,exec,umask=000 0 0 This gives absolutely everybody all the permissions on your zipdrive (mounting, unmounting, read, write, execute). To summarize, the file /etc/fstab is the place to keep your defaults on how to mount filesystems and what kind of access is allowed for users. You really want to customize it to simplify mounting on your system. Linux default mounting scheme is restrictive so as to be secure, you may want to remove some restrictions when setting up Linux at home. 4.2.7 Mounting command is too long, how can I simplify it with an alias? An alias is an abbreviation of a more complex or often used operating system command. For creating aliases, I edit, as root, the file /etc/bashrc . This way the aliases are available for all the users on the system. (For creating user-specific aliases, I edit the file .bashrc in the user home directory.) The relevant part of my /etc/bashrc looks like this: alias cdrom="mount -v /mnt/cdrom" alias ucdrom="umount -v /mnt/cdrom" alias dosdrive="mount -v /mnt/dosdrive" alias udosdrive="umount -v /mnt/dosdrive" alias zipdrive="mount -v /mnt/zipdrive" alias uzipdrive="umount -v /mnt/zipdrive" alias floppy="mount -v /mnt/floppy" alias ufloppy="umount -v /mnt/floppy" The option "-v" stands for "verbose", i.e., it tells Linux to talk to me a lot during mounting. For the aliases to take effect, the user has to re-login. Now the user can mount the floppy using this simple command: floppy and s/he can unmount it using ufloppy 4.2.8 Can I automount? You can. Automount will automatically mount a filesystem as you access it and unmount when you stop using it. To set up automount, I first run the programs setup (as root). Go to the option "netsysv" (RH5.2) or "System Services" (RH6.0) and make sure that automount service ("autofs") is enabled. 68 Then, I configure automount by editing the files /etc/auto.master and /etc/auto.misc, e.g. (as root): pico /etc/auto.master My /etc/auto.master looks like that: /misc /etc/auto.misc --timeout 1 This says that my automount devices will be mounted in the directory/misc (which must exist and be empty). My automount drives will automatically unmount one second after I stop using them (for example, after I exit the directory). This is a short time--you may choose a longer one. The detailed config file is /etc/auto.misc . Here is mine: kernel -ro,soft,intr ftp.kernel.org:/pub/linux cdrom -fstype=auto,ro :/dev/cdrom floppy -fstype=auto,rw :/dev/fd0 zipdrive -fstype=vfat,rw :/dev/sda4 dosdrive -fstype=vfat,ro :/dev/hda1 hacker_cdrom -fstype=nfs,ro hacker:/mnt/cdrom hacker_floppy -fstype=nfs,rw hacker:/mnt/floppy hacker_usr -fstype=nfs,ro hacker:/usr Each line consists of 3 space delimited fields. The first field is the "key" which will be the name of the subdirectory (under /misc) to which the device will be mounted. This directory must NOT exist. It will not be visible when I use the command ls , but I can "cd" to it and my device will then mount. Don’t ask me why it is so, and how to use this automount in GUI. I don’t know. The hacker stuff in my auto.misc is the cdrom and floppy from another computer in my home network. I automount to the directory /misc (not /mnt) so that I can also mount filesystems manually, without using automount, to the directory /mnt. 4.2.9 How do I get my parallel-port (external) Zip drive recognized? RedHat 5.2 During the initial RH5.2 installation, answer "yes" to the question "do you have scsi devices" Then pick up the parallel port zip drive (ppa) from the list. During the disk partitioning later in the installation process, either have a disk in your zip drive or tell the install process to "skip" when it attempts to access your zip drive. If you didn’t setup your Zip drive during the initial RedHat installation, you may also add the Zip support later in a way similar to adding the network card or any other module to the kernel: As root, start an X-terminal, and run /usr/bin/kernelcfg 69 to insert the ppa module into the kernel. (The "ppa" stands for, I guess, the "parallel port first interface ’a’ ".) After everything is done, inspect /proc/modules to see if the ppa module is loaded (or run as root lsmod to list the loaded modules). The information from kernelcfg goes to the file /etc/conf.modules so if you have difficulty removing modules (e.g. inserted by mistake)--as I did--just edit and adjust this file manually. Now your zipdrive should be recognized. Put a zipdisk into it and try mounting using the previously described command (as root): mount -t vfat /dev/sda4 /mnt/zipdrive Using the Linux kernel ver.2.0.36 and below, you will not be able to use a printer which is connected through the parallel port zip drive (this works with the kernel 2.2.x). Use the command uname -a to see which version of kernel you are running. RedHat 6.0 and 6.1 The zipdrive (zip100 drive) installation did not work during my upgrade to RedHat 6.0 (the installation program said that it couldn’t find the zipdrive). So, after the installation was completed, I issued the following commands to insert the modules for parallel port zip drive into the kernel (as root): /sbin/insmod parport /sbin/insmod ppa To have these two lines executed automatically after each bootup, I added them at the end of the file /etc/rc.d/rc.local (this file is something like autoexec.bat on DOS). If this still does not work for you, you may also want to edit the file /etc/conf.modules. Mine contains such a line: alias parport_lowlevel parport_pc and there is no line mentioning the "ppa" module. For the newer Zip250 drive, I have the following two lines executed from my /etc/rc.d/rc.local file: /sbin/insmod parport /sbin/insmod imm 70 4.2.10 Can I set 32-bit hard drive I/O? I know nothing about harddrives, but saw a review of RedHat 6.0 by Edward Choh (http://hardwarezone.community.com.sg/main.htm), in which he gave some interesting tips, including setting up the 32 bit input/output (I/O) and direct memory access (DMA). I tried it, and it worked fine for me. Be warned that it can possibly harm the content of your harddrive, so do not do it if you are a real PC newbie, don’t feel geeky today, or have a weak heart--I can’t guarantee it will work for you. The turning on of the 32-bit I/O and DMA has to be done by root, and I did it in a single-user mode (to minimize the damage to the file system if something went wrong and I had to reboot). I definitely would not do it on a system currently running many programs or X-windows, and would have a current backup of any precious data. To boot your computer in a single-user mode, I type this at the lilo prompt (during bootup): linux single Say I would like enable the 32-bit I/O on my first IDE harddrive, which is "hda". First, I time the harddrive current performance, and note the score: hdparm -t /dev/hda Now, I display my current I/O and DMA settings: hdparm -c /dev/hda [my system showed 0, meaning that the 32-bit I/O is turned off and the default 16-bit access is used] hdparm -d /dev/hda [my system showed 0 again, meaning that the harddrive DMA access is turned off]. Now, I turn on the 32 bit IO and DMA: hdparm -c 1 /dev/hda hdparm -d 1 /dev/hda Now, I can time the performance of the harddrive again to compare the score with the original one: hdparm -t /dev/hda If everything worked ok, and the performance has improved, I can "commit" the new settings, so they can survive a soft reset: hdparm -k 1 /dev/hda 71 To have the new settings in effect every time you reboot the machine, you may add a line at the end of the file /etc/rc.d/rc.local (this file is something like AUTOEXEC.BAT in DOS): hdparm -c 1 -d 1 -k 1 /dev/hda If something did not work as expected, or the performance did not really improve, I can reboot at any time and the old settings will be in effect as long as I did not perform the last operation. I performed this tune-up on 4 hard drives on our home network. It was a success on 3 newer hardrives: the performance improved by 30-300% and at least one computer "feels" faster than before. One harddrive (which is always flaky) hanged the computer hard during the performance test and I had to reset the machine (no damage done).
No comments:
Post a Comment