|
|
Restoring Clobbered /dev Files
© Copyright Darrell Anderson.
A particular bumper sticker remains popular for a good reason. To paraphrase that saying, Things Happen. When havoc strikes your computer, understanding why chaos resulted usually is helpful, but more often than not, the primary concern is restoration. Fix the problem!
The /dev directory in GNU/Linux is a special directory. Those files are not so much as files as thought of in the traditional sense but pointers and links to devices. There are two types of devices: block and character. Occasionally users clobber those files in advertent ways and need to restore the files to restore system functionality. The keys to restoring those clobbered files are contained in a text file and a system command. The text file is /usr/src/linux/Documentation/devices.txt. The system command is mknod.
Suppose, for example, you mistype the command to create a soft link from /dev/ttyS2 to /dev/modem and in that effort destroy the /dev/ttyS2 file. You need to restore that file.
- In any editor open the /usr/src/linux/Documentation/devices.txt text file.
- Next search for the device you want to restore. In this case, search for ttyS (case sensitive).
- You’ll find a section labeled: 4 char TTY devices.
- The 4 char information is important. The number 4 denotes the major device number. The text char denotes the device type—a character device as opposed to a block device.
- Next determine the minor device number. Determine that number by studying the applicable section. In this case, the device ttyS2 is assigned a minor number of 66.
- The ttyS2 device is a character device with major and minor device numbers of 4 and 66.
- Close the /usr/src/linux/Documentation/devices.txt text file.
- Now open a console session or if using X, an xterm or Konsole session.
- At the command line type:
mknod /dev/ttyS2 c 4 66
- However, you also should verify that you restore the device node with the appropriate permissions. In this case, ttySx devices are assigned permissions of 660 (rw-rw---). You subsequently can use the chmod 660 command to establish those permissions, but assigning them directly with the mknod command is just as easy:
mknod -m 660 /dev/ttyS2 c 4 66
- Your /dev/ttyS2 device should now be restored. Of course, more information about the mknod command is available from man mknod (although not much more!).
Finis.
Table of Contents
|
|