LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   trying to understand /dev (https://www.linuxquestions.org/questions/linux-general-1/trying-to-understand-dev-148635/)

e1000 02-20-2004 11:59 PM

trying to understand /dev
 
I am in the process of trying to make a bootable CD distro and one of the initrd's tasks is to locate the CD drive so it can set up the loopback filesystem that will be the root fs.

my biggest problem is that i dont truely understand the /dev/ directory enough to use it. and of course knowing this is intregral for the task of finding my cdrom drive automatically.

when i search on the /dev directory i get all sorts of breif newb oriented pages, but i need an in depth tut on it and how to use it, does anyone know where i can find this? also, would using the devfs under the kernel be easier or will i still need to know about the /dev stuf?

LinuxBlackBox 02-21-2004 07:10 AM

What do you want to know, exactly? The /dev/ directory is where all of the hardware that your computer is configured to use is stored. Linux uses everything on the system as a file, including hardware. The cd drive would probably be /dev/cdrom.

e1000 02-21-2004 02:15 PM

do me a favor, type "ls -l /dev/cdrom"; /dev/cdrom is not a device but its a link to the real cdrom device which us usually designated as /dev/hd*, the scripts job would be to find the real cdrom then set up the real root filesystem image as a /dev/loop* so that it could be mounted.

what i dont understand is the mechanics of stuf like "mknod" and what the "major" and "minor" numbers are, and im sure that's inportant to what i need to do, and at the verry least it would be usefull to know what they are and how to use them.

Darktyco 02-21-2004 07:06 PM

Why can't your script follow the soft link?

Device major/minor numbers are identifiers for devices. For an example look in the file /proc/stat at the disk_io line. The first numbers in parenthesis are the major and minor numbers of all the disks in your system. Eg disk_io: (3,0): (92,92,113,0,0) (3,1): (38582,9146,261475,29436,388120)

e1000 02-22-2004 01:47 AM

Why can't your script follow the soft link?

im not designing it for my machine, if i was it would be so much easier cause i already know what my cdrom drives designation is. im trying to make this work on any ide based system.

hopefully one of the things my script can do is make a symlink to /dev/cdrom

/bin/bash 02-22-2004 03:17 AM

Have you read The Bootdisk HOWTO? That has some good information on setting up a basic Linux filesystem. Even though it is written for a floppy it still is relevant for a cdrom bootdisk.

The file devices.txt is the file I use when I want to know the major/minor of a device, it comes with the kernel sources, so you should have one at:
/usr/src/linux/Documentation/devices.txt

As far as mknod goes it's real simple to use, you just need to know the major/minor number of the device and whether it is a character or block device.

farmerdan 02-22-2004 06:11 AM

Hello, e1000,

I just finished project that took me deeply into understanding /dev/xxxx. I posted what I did in the "Success Stories" forum, here

The story may not be interesting to you but I found some articles that talked about /dev/ and helped me learn what info I had there and how it worked. I provided links to the articles.

Yesterday, I'm running Mandrake 9.2, I discoverd that some of the articles I referenced were installed on my hard drive :o , in, off all places, a directory called HOWTO.

There's another reference that I found quite helpful. I think the name of it is "Introduction to Linux." It has a great discussion on the file system. I don't have great conficence in the accuracy of this link, but you can try it here.

Good luck.


All times are GMT -5. The time now is 04:58 PM.