Linux System Administration
One of Linux's amazing abilities is to read the filesystems of other operating systems. The most commonly used filesystem for the PC architecture is the DOS FAT (File Allocation Table) filesystem. This is the filesystem used by PC-DOS, MS-DOS, DR-DOS, etc. Linux has two ways to read files that are in the FAT format. First, you can compile support into the kernel (at the DOS filesystem prompt in 'make config') and then mount a drive using the command: mount -t msdos /dev/hda3 /mnt. This will mount your third partition of the first drive onto the /mnt directory.
Now this is fine and dandy if you have a hard drive, but what about floppies? If you're anything like me, you don't label your disks, and important things like next month's article wind up next to your unused Windows 3.1 install diskettes (now formatted) on a counter. Mounting and unmounting (with umount) would be a pain in the tail, because you now have to issue three commands to get a directory, the mount, the directory, then the umount. Sure you can put this in a batch file, but mounting takes a while. There has to be a better way. There is.
Most of the distributions of Linux come with a package called mtools. This handy package was designed for Suns and other systems that did not have easy FAT support. It's system-independent, so you don't need to go tinkering with your kernel or re-compile it. Just install the software and go. Most of the commands have names that a DOS user would know such as del, dir, md, rd, and so on. The difference is that the mtools have the letter 'm' in front of the command to specify that it's an mtools command. So 'dir' would be 'mdir', 'del' would be 'mdel', and so on.
Because mtools does nothing to your kernel, you don't need to mount and unmount diskettes. Need to copy a file quickly from a floppy? Just use 'mcopy'. The box at left lists the available mtools commands and their respective DOS counterparts. Two commands that do not have real DOS counterparts are mread and mwrite. These two commands are defined as low level reads or writes. Mread will read only from a FAT filesystem to a Linux file, and mwrite will write only from a Linux file to a FAT filesystem. You may want to use mread and mwrite if you are in a multi-user setup and you want some people to be able to only read FAT filesystems, and others to only write to them. Remember that the FAT filesystem has no user ownership and all files can be modified if users have access to mtools. Be sure to keep this in mind if you plan on having multiple users.
In order to use mtools properly, you must have a /etc/mtools file set up. To do that, you have to know how your floppy drives are seen by Linux. As I mentioned in a previous article, all of your physical devices such as your modem, monitor, printer, and sound card, are listed as special files in the /dev directory. The same is true of your drives. There are a list of files in the /dev directory that start with fd0 or fd1 of the form:
/dev/fdXYNNNNwhereX 0 - First floppy drive (A)1 - Second floppy drive (B)Y d - low density 5.25"D - low density 3.5"h - high density 5.25"H - high density 3.5"NNNN - Three or four digit number listing the number of 1K blocks on that drive. A high density 5.25" can have 360, 720, or 1200 while a high density 3.5" can have 360, 720, and 1440. Low density 5.25" is 360, and low density 3.5" has 360 and 720.
This means about 18 files in the /dev directory just for floppy drives. Luckily, you won't need to remember these combinations except for special circumstances.
Why? Because two additional files, /dev/fd0 and /dev/fd1 are set up as auto-sensing devices. When Linux boots up, it checks your system setup (the BIOS) for what floppy drives you have. The BIOS then tells the kernel what floppy drives you have, what size they are (5.25" or 3.5") and if they are high-density or low-density. In addition, when you insert a pre-formatted disk in the drive, Linux can determine if you have a high-density or low-density disk. So you can mount a low density floppy in a high density drive by just using 'mount -t msdos /dev/fd1 /mnt'.
Okay, now back to mtools and /etc/mtools.
An entry in /etc/mtools looks like this:
d <device> <fat> <tracks> <heads> <sectors>
d Drive letter you want to use. Yes, you can assign the first floppy drive to 'Q:' like you always wanted. Just be sure that your entry does not have the ':' in it. Just the drive letter.
device In most cases, this will be the /dev entry that you want to use. This can be /dev/fd0, /dev/hda1, or /dev/sda1 (for you SCSI people).
fat Size of the FAT table. Floppy drives and hard drive partitions have a size of 12, while large hard drive partitions have a size of 16. If you're unsure about your hard drive setting, use the 'fdisk -l' command which lists all of the partitions on all of your hard drives whether they are IDE or SCSI. DOS drives should say either 'DOS 12-bit <32M' or 'DOS 16-bit >=32M' Whatever is before the '-bit' is what you want for <fat>.
If you have a hard drive, or are using /dev/fd0 or /dev/fd1 as a device for an entry, you may fill in the rest as 0. This tells mtools to ask the kernel to find out. For other entries, you'll need to specify:
tracks Number of tracks on the drive. High density have 80 tracks while low density has 40.
heads Number of heads. Always 2 unless you have a really old drive. Like one of those drives where you have to flip the diskette over to read the second side.
sectors Number of sectors for the disk. 3.5 inch disks have 18 and 5.25 inch have 15.
The only time you would want to specify a drive using the tracks, heads or sectors is when you would want to format a disk. Set up the drives you would most want to format. For me, this is my high density 3.5 inch drive, so my entry would look like this:
e /dev/fd0H1440 12 80 2 18
I have my A through D drives set up as my two floppy drives and two DOS hard drives. The helps me avoid confusion while mucking with my drives.
Once you have your /etc/mtools file set up, save it and try accessing the drives you just set up. Try 'mdir c:' to see if it works. If you get a directory, it's working. If you get a 'Probable non-DOS disk' or a similar error message, you may be looking at the wrong partition. Edit your /etc/mtools file again and find the correct partition with the 'fdisk -l' command. Once you have all your drives set up, you can have fun with all the mtools commands.
Now on to formatting floppy disks. Now that you have /etc/mtools set up, this is a bit easier to do. If you have a new disk, you'll need to low-level format the diskette before you can put a DOS FAT filesystem on it. Both of these steps are done by the DOS format command, but we have to do it in two steps (unless you make a shell script). If all of your diskettes are in DOS FAT format, you can skip the next paragraph and find out how to do quick formats the mtools way. If your disks are in tar format or have been used as Linux boot disks, you shouldn't have to low-level format them, because mformat is more flexible than DOS's “format /q” command.
First is the low-level formatting. This is done with the fdformat command. The fdformat command uses as its option the device file you used earlier to define the
device in /etc/mtools. For example, the high density 3.5" disk you would put in drive 'A' is /dev/fd0H1440. So, to format that disk would be:
You should see a little message saying that it has 80 tracks, 18 sectors per track, total 1440KB. You should then see it formatting, then verifying the diskette. Once this is done, you can lay down a DOS FAT filesystem.
To install the FAT filesystem, the mformat utility is used. It will only accept a drive letter, which is why you wanted different drive types set up in /etc/mtools. Since I had my high density 3.5" drive set up as drive E, I can just type:
and my diskette will now be in DOS FAT format. Since this merely lays down a new FAT filesystem and root directory, it is comparable to quick-formatting programs under DOS like 'format /q'. If you get an error or the disk is unreadable with mdir, go back and low-level format the diskette, then re-format.
Once you have the FAT filesystem on the disk, it is compatable with mtools, native DOS, and can be mounted from the Linux kernel. It is as if you formatted it under DOS.
You can also place any supported Linux filesystem on the diskette like ext2fs, xiafs and extfs. Merely replace the mformat command with the command used to make that particular filesystem, such as mke2fs. You too can have your own library of Extended File-system diskettes, each 1.4MB big.
Using mtools will help you keep some of your DOS compatability, and it's easy to setup and use.
Practical Task Scheduling Deployment
July 20, 2016 12:00 pm CDT
One of the best things about the UNIX environment (aside from being stable and efficient) is the vast array of software tools available to help you do your job. Traditionally, a UNIX tool does only one thing, but does that one thing very well. For example, grep is very easy to use and can search vast amounts of data quickly. The find tool can find a particular file or files based on all kinds of criteria. It's pretty easy to string these tools together to build even more powerful tools, such as a tool that finds all of the .log files in the /home directory and searches each one for a particular entry. This erector-set mentality allows UNIX system administrators to seem to always have the right tool for the job.
Cron traditionally has been considered another such a tool for job scheduling, but is it enough? This webinar considers that very question. The first part builds on a previous Geek Guide, Beyond Cron, and briefly describes how to know when it might be time to consider upgrading your job scheduling infrastructure. The second part presents an actual planning and implementation framework.
Join Linux Journal's Mike Diehl and Pat Cameron of Help Systems.
Free to Linux Journal readers.Register Now!
- SUSE LLC's SUSE Manager
- Murat Yener and Onur Dundar's Expert Android Studio (Wrox)
- My +1 Sword of Productivity
- Non-Linux FOSS: Caffeine!
- Managing Linux Using Puppet
- Doing for User Space What We Did for Kernel Space
- SuperTuxKart 0.9.2 Released
- Parsing an RSS News Feed with a Bash Script
- Google's SwiftShader Released
- Rogue Wave Software's Zend Server
With all the industry talk about the benefits of Linux on Power and all the performance advantages offered by its open architecture, you may be considering a move in that direction. If you are thinking about analytics, big data and cloud computing, you would be right to evaluate Power. The idea of using commodity x86 hardware and replacing it every three years is an outdated cost model. It doesn’t consider the total cost of ownership, and it doesn’t consider the advantage of real processing power, high-availability and multithreading like a demon.
This ebook takes a look at some of the practical applications of the Linux on Power platform and ways you might bring all the performance power of this open architecture to bear for your organization. There are no smoke and mirrors here—just hard, cold, empirical evidence provided by independent sources. I also consider some innovative ways Linux on Power will be used in the future.Get the Guide