Difference between revisions of "Mdev"

From ArchWiki
Jump to: navigation, search
m (Sanity check: templates Package, RootCmd, File do not exist, replaced with proper templates)
(Adjusted nonexistent templates. This page should be removed because it is an identical copy of https://wiki.gentoo.org/wiki/Mdev)
Line 1: Line 1:
{{Deletion|This poorly written page already exits in Gentoo wiki and has no Arch related info.}}
+
{{Deletion|This poorly written page already exits in Gentoo wiki and has no Arch related info. As a matter of fact, it is almost an exact copy of the [https://wiki.gentoo.org/wiki/Mdev Gentoo wiki page Mdev].}}
 +
{{Poor writing|This page is not properly adapted to Arch Linux.}}
 
The aim of this page is to document how to replace udev in Linux with mdev, thus allowing a separate /usr partition, without an initramfs. The auther uses Gentoo Linux with Icewm as the WM. The instructions here should be applicable to other distros, assuming you can make the necessary changes.
 
The aim of this page is to document how to replace udev in Linux with mdev, thus allowing a separate /usr partition, without an initramfs. The auther uses Gentoo Linux with Icewm as the WM. The instructions here should be applicable to other distros, assuming you can make the necessary changes.
 
==Will mdev work on my system?==
 
==Will mdev work on my system?==
Line 23: Line 24:
 
# Configure the keyboard and mouse explicitly in ''/etc/X11/xorg.conf'' (or wherever else you keep your ''xorg.conf'').
 
# Configure the keyboard and mouse explicitly in ''/etc/X11/xorg.conf'' (or wherever else you keep your ''xorg.conf'').
 
#* Edit the two '''InputDevice''' sections to look like this. The critical lines are noted.
 
#* Edit the two '''InputDevice''' sections to look like this. The critical lines are noted.
{{File|/etc/X11/xorg.conf|Explicit input device configuration|<pre>
+
{{Hc|head=/etc/X11/xorg.conf - Explicit input device configuration|output=<nowiki>
<pre>    Section "InputDevice"
+
    Section "InputDevice"
 
             Identifier  "Keyboard0"
 
             Identifier  "Keyboard0"
 
             Driver      "evdev"                      # Critical
 
             Driver      "evdev"                      # Critical
Line 36: Line 37:
 
             Option      "Device" "/dev/input/event4"  # Also critical
 
             Option      "Device" "/dev/input/event4"  # Also critical
 
             Option      "ZAxisMapping" "4 5 6 7"
 
             Option      "ZAxisMapping" "4 5 6 7"
     EndSection</pre>}}
+
     EndSection</nowiki>}}
  
 
===ATI/AMD binary blobs===
 
===ATI/AMD binary blobs===
Line 54: Line 55:
 
If you prefer '''make menuconfig''', the route is as shown below. Note that the "Automount devtmpfs..." option won't appear until you enable the "Maintain a devtmpfs..." option.
 
If you prefer '''make menuconfig''', the route is as shown below. Note that the "Automount devtmpfs..." option won't appear until you enable the "Maintain a devtmpfs..." option.
  
{{Kernel|Setting devtmpfs|<pre>
+
Kernel: Setting devtmpfs <nowiki>
 
   Device Drivers --->
 
   Device Drivers --->
 
     Generic Driver Options --->
 
     Generic Driver Options --->
 
       [*] Maintain a devtmpfs filesystem to mount at /dev
 
       [*] Maintain a devtmpfs filesystem to mount at /dev
       [*] Automount devtmpfs at /dev, after the kernel mounted the rootfs</pre>}}
+
       [*] Automount devtmpfs at /dev, after the kernel mounted the rootfs</nowiki>
  
 
Once you've made the changes, rebuild the kernel. Do '''NOT''' reboot yet.
 
Once you've made the changes, rebuild the kernel. Do '''NOT''' reboot yet.
Line 64: Line 65:
 
===Emerging busybox===
 
===Emerging busybox===
 
For our circumstance, you will need the <tt>mdev</tt> USE flag set for busybox. The <tt>static</tt> USE flag is probably also a good idea. In the ''/etc/portage/package.use/mdev'' file, add the line
 
For our circumstance, you will need the <tt>mdev</tt> USE flag set for busybox. The <tt>static</tt> USE flag is probably also a good idea. In the ''/etc/portage/package.use/mdev'' file, add the line
{{File|/etc/portage/package.use/mdev||<pre>sys-apps/busybox static mdev</pre>}}
+
{{Hc|head=/etc/portage/package.use/mdev|output=<nowiki>sys-apps/busybox static mdev</nowiki>}}
 
Now, you may run '''emerge sys-apps/busybox'''.
 
Now, you may run '''emerge sys-apps/busybox'''.
 
If you're using a distro other than Gentoo, or building Busybox manually, do whatever necessary in your situation to enable the mdev option.
 
If you're using a distro other than Gentoo, or building Busybox manually, do whatever necessary in your situation to enable the mdev option.
Line 71: Line 72:
 
You will need ''/sbin/linuxrc'' to contain at least
 
You will need ''/sbin/linuxrc'' to contain at least
  
{{File|/sbin/linuxrc|Custom busybox based linuxrc|<pre>
+
{{Hc|head=/sbin/linuxrc - Custom busybox based linuxrc|output=<nowiki>
<pre>#!/bin/busybox ash
+
#!/bin/busybox ash
 
mount -t proc proc /proc
 
mount -t proc proc /proc
 
mount -t sysfs sysfs /sys
 
mount -t sysfs sysfs /sys
exec /sbin/init</pre>}}
+
exec /sbin/init</nowiki>}}
  
 
This should be enough for most users. If you have an unusual setup, you may need to place additional steps in your ''/sbin/linuxrc''. Remember to run '''chmod 744 /sbin/linuxrc''' to make the file executable.
 
This should be enough for most users. If you have an unusual setup, you may need to place additional steps in your ''/sbin/linuxrc''. Remember to run '''chmod 744 /sbin/linuxrc''' to make the file executable.
Line 83: Line 84:
 
===Replace the udev service===
 
===Replace the udev service===
 
Remove udev from the services list, replacing it with mdev:
 
Remove udev from the services list, replacing it with mdev:
{{RootCmd|rc-update del udev sysinit }}
+
rc-update del udev sysinit
{{RootCmd|rc-update add mdev sysinit }}
+
c-update add mdev sysinit
  
 
===Reboot===
 
===Reboot===
Line 97: Line 98:
 
==Setting up a USB printer running under CUPS==
 
==Setting up a USB printer running under CUPS==
 
===Make 'find' available at early boot-time===
 
===Make 'find' available at early boot-time===
{{RootCmd|cd /bin }}
+
cd /bin
{{RootCmd|ln -s /bin/busybox find }}
+
ln -s /bin/busybox find
 
===Rebuild the kernel===
 
===Rebuild the kernel===
 
For libusb (and hence CUPS) to see the USB ports, set <tt>CONFIG_USB_DEVICE_CLASS=y</tt> and <tt>CONFIG_USB_DEVICEFS=y</tt> in your kernel configuration.  You will also need to enable <tt>CONFIG_USB_PRINTER</tt>, despite the injunction in the cups-1.5.2 ebuild to disable it.  If you use '''make menuconfig''', these items are found here:
 
For libusb (and hence CUPS) to see the USB ports, set <tt>CONFIG_USB_DEVICE_CLASS=y</tt> and <tt>CONFIG_USB_DEVICEFS=y</tt> in your kernel configuration.  You will also need to enable <tt>CONFIG_USB_PRINTER</tt>, despite the injunction in the cups-1.5.2 ebuild to disable it.  If you use '''make menuconfig''', these items are found here:
{{Kernel|Enabling generation of USB devices at boot time|<pre>
+
Kernel: Enabling generation of USB devices at boot time|<nowiki>
 
   Device Drivers --->
 
   Device Drivers --->
 
     [*] Support for Host-side USB
 
     [*] Support for Host-side USB
 
       [*] USB device filesystem [DEPRECATED]
 
       [*] USB device filesystem [DEPRECATED]
 
       [*] USB device class-devices [DEPRECATED]
 
       [*] USB device class-devices [DEPRECATED]
     [*] USB Printer support</pre>}}
+
     [*] USB Printer support</nowiki>
 
(Don't worry about the "DEPRECATED"s.)
 
(Don't worry about the "DEPRECATED"s.)
 
===Configure the new kernel into your bootloader and reboot into it===
 
===Configure the new kernel into your bootloader and reboot into it===

Revision as of 20:22, 8 June 2012

Tango-edit-cut.pngThis section is being considered for removal.Tango-edit-cut.png

Reason: This poorly written page already exits in Gentoo wiki and has no Arch related info. As a matter of fact, it is almost an exact copy of the Gentoo wiki page Mdev. (Discuss in Talk:Mdev#)

Tango-edit-clear.pngThis article or section needs language, wiki syntax or style improvements.Tango-edit-clear.png

Reason: This page is not properly adapted to Arch Linux. (Discuss in Talk:Mdev#)

The aim of this page is to document how to replace udev in Linux with mdev, thus allowing a separate /usr partition, without an initramfs. The auther uses Gentoo Linux with Icewm as the WM. The instructions here should be applicable to other distros, assuming you can make the necessary changes.

Will mdev work on my system?

I run a simple Gentoo install, using ICEWM, and no "desktop environment". An xorg.conf is not required on my system. Note that a "desktop environment" is not required to run Abiword, Firefox, Gimp, Gnumeric, etc. However, "Koffice apps" like Kmail seem to pull in most of KDE as a dependancy. In general, if you use KDE or lvm2, you may have problems, and may not be able to get by with mdev. One beta tester reports getting close with lvm2, but it's not there yet.

There is one more sanity check that Gentoo users can run to check for udev dependancy. I don't think this can be duplicated in other distros.

Sanity check

To /etc/portage/package.mask/mdev, add the line

/etc/portage/package.mask/mdev - Mask away udev
sys-fs/udev

Execute the two commands as root:

euse -D udev
emerge -pvuDN world

If the only errors you get are for not being able to re-install udev as required by virtual/dev-manager, you can proceed to the next stage. Otherwise, udev might be a hard dependency of some package you requested.

Software requiring extra steps

GNOME 2

GNOME version 2 has been made to work under mdev.

  1. Rebuild xorg-server without udev support
    • In Gentoo, build with emerge xorg-server
    • If you're running a different distro, use your package manager.
  2. Configure the keyboard and mouse explicitly in /etc/X11/xorg.conf (or wherever else you keep your xorg.conf).
    • Edit the two InputDevice sections to look like this. The critical lines are noted.
/etc/X11/xorg.conf - Explicit input device configuration
    Section "InputDevice"
            Identifier  "Keyboard0"
            Driver      "evdev"                       # Critical
            Option      "Device" "/dev/input/event3"  # Also critical
    EndSection

    Section "InputDevice"
            Identifier  "Mouse0"
            Driver      "evdev"                       # Critical
            Option      "Protocol" "auto"
            Option      "Device" "/dev/input/event4"  # Also critical
            Option      "ZAxisMapping" "4 5 6 7"
    EndSection

ATI/AMD binary blobs

Some ATI/AMD Radeon cards require binary blobs. The Gentoo radeon-ucode ebuild pulls down all the binary blobs available at http://people.freedesktop.org/~ag5f/radeon_ucode/ to support many different models.

If I leave the binary blobs in the library directory, the kernel needs udev to figure out which one of the many binary blobs to load. If I remove all the other binary blobs, leaving only the correct one in the library directory, it loads automatically.

Warning / Disclaimer

Proceed only if the above stages don't reveal any udev dependencies. Furthermore:

  • This is a beta.
  • Use a spare test machine or a VM.
  • If you don't follow the instructions correctly, the result may be an unbootable Linux.
  • Even if you do follow the instructions correctly, the result may be an unbootable Linux.

Replacing udev with mdev

Setting up your kernel for devtmpfs

Set up your kernel to support and automount a devtmpfs filesystem at /dev. If you prefer to edit .config directly, set CONFIG_DEVTMPFS=y and CONFIG_DEVTMPFS_MOUNT=y.

If you prefer make menuconfig, the route is as shown below. Note that the "Automount devtmpfs..." option won't appear until you enable the "Maintain a devtmpfs..." option.

Kernel: Setting devtmpfs Device Drivers ---> Generic Driver Options ---> [*] Maintain a devtmpfs filesystem to mount at /dev [*] Automount devtmpfs at /dev, after the kernel mounted the rootfs

Once you've made the changes, rebuild the kernel. Do NOT reboot yet.

Emerging busybox

For our circumstance, you will need the mdev USE flag set for busybox. The static USE flag is probably also a good idea. In the /etc/portage/package.use/mdev file, add the line

/etc/portage/package.use/mdev
sys-apps/busybox static mdev

Now, you may run emerge sys-apps/busybox. If you're using a distro other than Gentoo, or building Busybox manually, do whatever necessary in your situation to enable the mdev option.

Creating /sbin/linuxrc

You will need /sbin/linuxrc to contain at least

/sbin/linuxrc - Custom busybox based linuxrc
#!/bin/busybox ash
mount -t proc proc /proc
mount -t sysfs sysfs /sys
exec /sbin/init

This should be enough for most users. If you have an unusual setup, you may need to place additional steps in your /sbin/linuxrc. Remember to run chmod 744 /sbin/linuxrc to make the file executable.

Configure the bootloader

Append init=/sbin/linuxrc to your kernel command line. If you use lilo, remember to re-run lilo to implement the changes. If you use a different bootloader, apply any necessary equivalent steps.

Replace the udev service

Remove udev from the services list, replacing it with mdev:

rc-update del udev sysinit
c-update add mdev sysinit

Reboot

Reboot to your new kernel. You should now be running without using udev.

Cleanup

Remove udev from your system by running emerge --unmerge sys-fs/udev. In the /etc/portage/package.mask, append the line sys-fs/udev. Create /etc/portage/package.mask if it doesn't already exist.

You should now have a completely udev-free machine.


Setting up a USB printer running under CUPS

Make 'find' available at early boot-time

cd /bin
ln -s /bin/busybox find

Rebuild the kernel

For libusb (and hence CUPS) to see the USB ports, set CONFIG_USB_DEVICE_CLASS=y and CONFIG_USB_DEVICEFS=y in your kernel configuration. You will also need to enable CONFIG_USB_PRINTER, despite the injunction in the cups-1.5.2 ebuild to disable it. If you use make menuconfig, these items are found here: Kernel: Enabling generation of USB devices at boot time| Device Drivers ---> [*] Support for Host-side USB [*] USB device filesystem [DEPRECATED] [*] USB device class-devices [DEPRECATED] [*] USB Printer support (Don't worry about the "DEPRECATED"s.)

Configure the new kernel into your bootloader and reboot into it

Verify the presence of the new device nodes

You should see a hierarchy of device nodes under /dev/bus/usb/. If you switch on your printer, you will probably see a node for it at /dev/lp0. You should be able to run lsusb successfully, and this should display your printer's details.

Configure your printer in CUPS

You should now be able to configure CUPS in the usual way. CUPS should find your printer, and will give it a URI something like parallel:/dev/lp0.


Notes

This set of instructions was originally written by Walt Dnes and hosted at http://www.waltdnes.org/mdev/. It was imported to the Gentoo wiki with some editing by Michael Mol per discussion on the gentoo-user mailing list.

  • mdev unlike udev does not support auto-modules loading thus you will need to use /etc/conf.d/modules and put there all the modules like you used to load (nvidia, wl etc.). Also, /etc/conf.d/modules have own _args variables as it does not support /etc/modprobe.d. You may need to move your configuration there.
  • mdev -s does not create /dev/mapper nodes. You may need to manualy create them or use 'dmsetup mknodes' from lvm2 (good idea is to add it after mdev -s in init script).
  • you should use mouse and kbd drivers for xorg inputs. evdev need udev to be built. Mousedrv (mouse) may conflict with synaptics driver, when both are loaded, non of them really work. (bug?)