How to create entries for hard disk partitions in /dev?


Results 1 to 15 of 18

Thread: How to create entries for hard disk partitions in /dev?

Threaded View

  1. #6
    Join Date
    Apr 2001
    Location
    SF Bay Area, CA
    Posts
    14,936
    If you have access to a /dev tree that has the correct device file in it, then you can simply:

    Code:
    cp -a /wherever/dev/hda59 /dev/hda59
    or whatever you need. (Without bind-mounting, that is.) The -a option tells cp to preserve pretty much everything (owner, group, permissions), and to act appropriately when you give it a device file (without -a, cp would try to copy the entire partition's contents, instead of just the device file), or a symlink, or a named pipe, or a named socket. (It also makes cp act recursively, so you have to be careful when using it on a directory; don't just use -a all the time.)

    Or, you could do this:

    Code:
    ls -l /wherever/dev/hda59
    brw-rw---- 1 root disk 3, 59 Dec 29 19:59 /dev/hda5
    and note the parts in bold (the "b" at the beginning, telling you it's a block device, and the "3, 59" in the middle telling you it's major 3, minor 59). Then use mknod:

    Code:
    mknod /dev/hda59 b 3 59
    chown root:disk /dev/hda59
    chmod 0660 /dev/hda59
    (The last two can probably be rolled into options given to mknod, but oh well, this works too.) The important part is the "b 3 59" -- these come directly from the output of ls -l.

    And as Icarus said, it's easier when using udev -- the partitions that exist just show up, automatically. But if your distro is still running kernel 2.4, that's not really an option.
    Last edited by bwkaz; 12-30-2006 at 02:07 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •