Okay, you want to replace eudev. Let's explore your options. The context of why you want to replace eudev is very important, as the best choice depends on your motivations.
Understanding the Landscape: eudev, udev, and systemd
udev: This is the original device manager for the Linux kernel. It dynamically manages device nodes in /dev, handles hotplug events, and assigns permissions based on rules.
systemd-udevd: This is the version of udev that is integrated into the systemd init system. It's the most common implementation in modern Linux distributions.
eudev: This is a fork of systemd-udevd created as a standalone udev implementation, independent of systemd. It aims to be a lighter-weight alternative and avoid tight coupling with systemd. It's primarily used on systems where systemd is not desired.
Why Replace eudev? (And What That Means For Your Options)
Before diving into alternatives, let's understand why you might want to replace eudev. Here are common reasons, and how they affect the answer:
You Want to Get Rid of systemd: This is the most likely reason someone would want to replace eudev in the first place! If your goal is to remove systemd entirely, replacing eudev is a necessary step, but not the only one. You'll need to replace allsystemd components, including the init system.
You're Experiencing Issues with eudev: Perhaps you're encountering bugs, performance problems, or compatibility issues specific to eudev.
You Want a More Minimal Device Manager: You might be looking for something even lighter than eudev.
You Need a Specific Feature Not Available in eudev: This is less common, but if you have a unique requirement, it might necessitate an alternative.
You're Just Curious/Experimenting: You want to explore other options for academic purposes.
Options for Replacing eudev:
The options are highly dependent on whether you want to keep systemd. Let's deal with that first.
A. If You WANT to keep systemd
This is the simplest solution.
Switch to systemd-udevd: Most distributions that offer eudev as an option also offer systemd-udevd. The switch is usually a matter of package management. The package name varies by distribution (e.g., systemd-udev or just systemd). Check your distribution's documentation for the exact package name and instructions. This is the easiest and most supported solution for most systems. You'll need to uninstall eudev first.
bash
# Example for Debian/Ubuntu (adapt as needed)
sudo apt remove eudev
sudo apt install systemd
Your distribution's init system should start the systemd-udevd automatically on boot. Reboot to ensure everything is working.
B. If You Do NOT Want to Keep systemd (And Therefore, eudev)
This is significantly more complex and requires replacing the init system as well.
mdev (Busybox):mdev is a very lightweight device manager included in Busybox. It's suitable for embedded systems or environments where resources are extremely limited. It's significantly simpler than udev, so it may not handle complex device configurations as easily. This requires using Busybox as your init system (or at least a system that's compatible with it).
Cons: Limited functionality, requires Busybox, configuration can be more manual.
udevd (standalone, original): This refers to the original, pre-systemd version of udev. It is extremely difficult to find, maintain, and integrate into a modern system. It's typically only useful for historical purposes or very niche use cases. I would strongly advise against this unless you have a very specific, well-understood reason. This is generally not a practical option for most users.
Other Minimal init Systems and Device Managers: There may be other very minimal init systems that also include a basic udev-like component. These are typically quite specialized. Examples might include:
s6
Runit
dinit (relatively new but actively developed, aims to be systemd-compatible)
Important Considerations for Replacing eudev Without systemd:
Init System Replacement: Replacing eudevrequires replacing your init system. You can't just swap eudev for something else while keeping systemd or eudev as your init.
Bootloader Configuration: You will need to configure your bootloader (e.g., GRUB, LILO) to use the new init system.
Service Management: You'll need a way to manage services (starting, stopping, enabling, disabling). systemd provides systemctl. You'll need to choose an alternative service manager that works with your new init system. Options depend on which init system you use (e.g., runit has its own service management, s6 does too).
Logging:systemd also provides a logging system (journald). You'll need an alternative logging solution (e.g., syslog, rsyslog, or simply writing to files).
Networking:systemd has some network configuration tools. You'll need to configure networking using other tools (e.g., ifconfig, ip, dhclient, network manager daemons like wicd).
System Clock:systemd handles the system clock. You'll need to use ntpd, chronyd, or a similar service.
Dependency Hell: Many applications and libraries on a modern Linux system have dependencies, even optional ones, on systemd. Removing systemd may break those applications. You'll need to carefully identify and resolve any dependency issues. This can involve patching software or finding alternatives.
Community Support: Smaller init systems often have less community support than systemd. This means you might have to troubleshoot problems yourself.
How to Choose the Right Option
Define Your Goals:Why are you replacing eudev? Is it just to get rid of systemd? Are you having specific problems? What level of complexity are you willing to accept?
Research: Thoroughly research the alternatives. Read the documentation, understand the dependencies, and look for examples of people who have successfully used them.
Start Small: If you're replacing systemd, start by testing the new init system and device manager in a virtual machine. This will allow you to experiment without breaking your main system.
Backup:Always back up your system before making major changes like this.
Be Prepared for Troubleshooting: Replacing systemd and its components is a complex task. You will likely encounter problems. Be prepared to spend time troubleshooting and resolving issues.
Example: Replacing eudev with mdev (Busybox) - Very High-Level Overview (Difficult)
This is a very simplified overview. The exact steps will vary depending on your distribution and desired configuration.
Install Busybox: Install the busybox package for your distribution.
Create a Basic Filesystem: You'll need to set up a basic root filesystem with the necessary directories (e.g., /dev, /proc, /sys, /tmp, /etc).
Configure mdev: Create an mdev.conf file in /etc/mdev.conf to define the device node creation rules. This is significantly less sophisticated than udev's rule system.
Create an Init Script: Write a basic init script (usually named init and placed in the root directory) that will start mdev and other essential services.
Configure the Bootloader: Modify your bootloader configuration to boot into the Busybox-based root filesystem and use the init script.
Remove eudev: Uninstall the eudev package.
In Summary
If you just want a well-supported udev implementation and are okay with systemd, switching to systemd-udevd is by far the easiest and recommended solution.
If you want to get rid of systemd entirely, replacing eudev with something like mdev is possible, but it's a significant undertaking that requires replacing the init system and other core components. It is not for the faint of heart and is not a task for beginners.
Carefully consider the trade-offs between complexity, functionality, and support before making a decision. Research your options and test them thoroughly.
Good luck! Be patient, and don't hesitate to ask more specific questions as you proceed.
User
not systemd nor busybox... so udev?
Assistant
Okay, you want to replace eudev with something that's not systemd or Busybox. This severely limits your options and increases the complexity significantly. This means you're likely pursuing a very specific or unusual configuration. Let's analyze that scenario:
The Core Problem:
The challenge here is that udev was essentially "absorbed" by systemd. The original, standalone udev project is effectively defunct and unmaintained. Finding a working, pre-systemd udev is going to be extremely difficult and likely involve a lot of manual patching and porting. Moreover, even if you find such an archive, it was designed to work with older kernels and system libraries.
Why is this difficult?
Maintenance: The original udev codebase is no longer maintained. It won't have the necessary updates to handle modern hardware, kernel changes, or security vulnerabilities.
Dependencies: Even the older udev likely had dependencies on certain libraries and tools that might be difficult to satisfy on a modern system without pulling in parts of systemd.
Integration: Integrating a standalone udev into a modern Linux system without systemd requires writing a lot of custom glue code to handle init, service management, logging, and other system services.
Realistic Assessment of "Original udev":
While technically possible, finding and getting the original udev to work is likely to be an enormous amount of effort. It would likely be more effort than developing your own minimalistic device manager from scratch.
Considering the Constraints: What Are Your Actual Options?
Given that you explicitly exclude systemd and Busybox, and the original udev is essentially a dead end, your realistic options are:
Roll Your Own Device Manager (Very Advanced):
The Concept: This involves writing your own software (in C, perhaps) to listen for kernel hotplug events (using netlink sockets), read device information from /sys, and create device nodes in /dev according to your own rules.
Complexity: This is highly complex and requires deep knowledge of the Linux kernel, device drivers, and system programming.
A development effort is required.
User
i use runit with evdev
Assistant
Okay, that's crucial information! You're already using runit and eudev. The fact that you have runit already in place significantly changes the situation. Now, let's clarify what you want to achieve by replacing eudev.
Since you're running runit, the core goal is likely to either:
Reduce dependencies further/increase system lightness: You want to reduce the overall footprint and dependencies of your system, and eudev is seen as too heavy.
Specific incompatibility or bug fix: There's a specific issue with eudev that you're trying to solve.
Given the "runit" context, here's a more refined breakdown of your options, keeping the "no systemd or busybox" constraint:
mdev Integration with runit (Likely the Best Option):
Even though you excluded Busybox, the mdev component can be extracted and potentially used even without using Busybox as your full shell. This involves:
Compile mdev as a standalone binary: You would need to obtain the source code from Busybox, and specifically configure the compilation to only build mdev. This can be tricky, as Busybox is usually compiled as a single monolithic binary. You might have to extract the mdev source files and create a separate build script.
Manual Device Node Creation: Since you already have runit, you can modify your runit scripts to call mdev at boot and on device hotplug events. You'll also need to create the initial /dev directory structure.
mdev.conf Configuration: You would still use the mdev.conf file to define the device node creation rules.
Advantages: More lightweight than eudev.
Why this might be preferred: Since mdev is very small, it minimizes the dependencies. It also still provides reasonable device node management via the mdev.conf file. You can avoid using all of Busybox.
Writing Custom Device Node Management Scripts:
You could bypass any device manager entirely and create your own shell scripts that are triggered by uevents.
How: You would need to listen for the kernel's uevent messages via a netlink socket. When a new device is added, the kernel sends a message to the socket. You could then write a script to interpret the message and create the necessary device nodes.
libudev-zero (https://github.com/illiliti/libudev-zero) is a very interesting option that fits well within the constraints you've outlined. It's specifically designed to be a minimal, standalone replacement for libudev that doesn't depend on systemd. Given your use of runit, this could be a very good fit.
Analysis of libudev-zero:
Goal: To provide a minimal libudev API implementation without the baggage of systemd. This allows applications to continue to use the libudev API without requiring the full systemd stack.
Dependencies: Its main dependencies are libkmod and libmnl. These are significantly lighter than the dependencies of systemd or even eudev.
Implementation: It focuses on providing the core functionality needed for device enumeration, hotplug event handling, and querying device properties.
Suitability for runit: Since you're already using runit as your init system and want to replace eudev, libudev-zero provides a way to keep applications that rely on libudev working without needing systemd. You would still likely need some glue code (e.g., runit services or shell scripts) to handle device node creation.
How to Integrate libudev-zero with runit:
Build and Install libudev-zero:
Clone the repository: git clone https://github.com/illiliti/libudev-zero.git
Build it:
bash
cd libudev-zero
mkdir build
cd build
cmake .. -DCMAKE_INSTALL_PREFIX=/usr # Or your desired prefix
make
sudo make install
Ensure that you have the required build tools (e.g., CMake, a C compiler, libkmod and libmnl development packages).
You may need to configure your system's linker to find the installed library (e.g., by adding /usr/local/lib or /usr/lib to /etc/ld.so.conf and running ldconfig).
User
no i use udevil to mount thing
Assistant
Ah, udevil! That clarifies things significantly. udevil is a user-friendly frontend for libudev that handles mounting and unmounting removable devices. The fact that you're using udevil means that applications using libudevmust work.
Given your use of runit and udevil, the best approach is clearly to leverage libudev-zero as a drop-in replacement for the libudev provided by either systemd or eudev. You don't necessarily need to write your own udev rule parser or create device nodes directly, as udevil handles much of this.
Here's the refined strategy:
Install libudev-zero: As previously outlined, clone the repository, build it, and install it. Make sure your linker is configured to find it.
bash
git clone https://github.com/illiliti/libudev-zero.git
cd libudev-zero
mkdir build
cd build
cmake .. -DCMAKE_INSTALL_PREFIX=/usr
make
sudo make install
sudo ldconfig #Refresh dynamic link cache
Verify libudev-zero is Used by udevil:
You'll need to ensure that udevil is actually using the libudev-zero library instead of the libudev from systemd or eudev. This might involve recompiling udevil against libudev-zero, or modifying the system's library search paths.
Recompile udevil (Likely Required): Download the udevil source code, configure the build system to use libudev-zero (usually by setting the LIBUDEV_CFLAGS and LIBUDEV_LIBS environment variables or CMake options), and recompile udevil. This ensures it links against libudev-zero.
bash
Effort:
significant
Feasibility: Only feasible if you have very specific and limited requirements, and a strong development background.
Libraries to possibly use: libudev might be usable, but be aware that even its current versions have strong connections to systemd.
Why? You would only do this if you need extreme control and minimization, and absolutely cannot use any existing solutions.
Use a Minimal Init System with Device Management Capabilities (Less Extreme, Still Difficult):
This assumes that the sole thing you dislike about systemd is its size, complexity, or ideology, but not its functionality. Therefore, you might want to consider these:
dinit: dinit aims to be a modern init system that is leaner and more modular than systemd. It can be compiled without libsystemd dependencies. It is relatively new, but aims to be reasonably compatible, which might allow your applications to run. You'd need to investigate its device management features.
Runit: RunIt is a process supervision suite. It includes a basic device manager functionality.
s6: Similar to Runit, s6 offers process supervision and init functionalities and also has device management features.
Consequences: You still need to replace systemd, which means you need to reconfigure your bootloader, install these tools, and resolve dependency issues.
Practical Recommendations (Assuming You're Open to Alternatives):
Before pursuing the extremely difficult path of rolling your own or resurrecting the original udev, I strongly recommend reconsidering your constraints. Ask yourself:
What specifically do you dislike about systemd or Busybox? Is it their size, their complexity, their philosophy, or something else?
Can you compromise? Is there a way to use a slightly modified or customized version of an existing solution to meet your needs? For example, can you disable unnecessary features in systemd?
Are you optimizing prematurely? Is the perceived performance benefit of a custom solution worth the development and maintenance effort?
In Summary:
Replacing eudev without systemd or Busybox is extremely challenging and likely impractical due to the state of the original udev codebase.
Rolling your own device manager is possible, but it's a significant development project.
Consider using a minimal init system with device management features as a potentially less complex alternative.
Carefully evaluate your requirements and constraints to determine the most realistic and effective solution.
Given the limitations, I would encourage you to explain your use case and reasons for excluding systemd and Busybox in more detail. There might be a more practical solution that I haven't considered.
Complexity: High. You need to understand the uevent message format, the device information in /sys, and how to create device nodes correctly.
Advantages: Extremely minimal.
Disadvantages: Time-consuming, error-prone, and difficult to maintain.
Enhanced udev Replacement With a Custom Process Manager (Advanced):
The Idea: Replace only the device manager daemon (udevd) part of eudev with a lightweight, custom one. You can still use the existing udev rules to configure your devices.
Implementation: You'd need to write a new daemon that listens for uevents from the kernel. For each event, it applies the rules stored in /etc/udev/rules.d (the same rules that udev uses). Based on the matching rules, it will create device nodes and set permissions.
Advantages: Uses the existing udev rules framework, meaning that you don't need to rewrite them. You have a new daemon, so there's a cleaner separation of concerns.
Disadvantages: Requires more development effort.
Libraries to Consider: You would need to inspect how eudev parses /etc/udev/rules.d, and reuse or reimplement that functionality in your own daemon.
How to Choose
If you want the simplest path with reasonable device management, then try extracting and using just the mdev component of Busybox with runit. You'll still need to compile it and set up the configuration, but it minimizes the dependencies.
If you want the most minimal solution possible, then write custom shell scripts to manage device nodes based on uevents. However, this is best suited for very simple setups with few devices.
If you want a more robust solution that is more flexible and can handle more complex device configurations, then develop your own process manager and interface it with the /etc/udev/rules.d files. This is the most complex, but also gives you the most control.
Steps to Try Using mdev with runit:
Download the Busybox source code:
bash
wget https://busybox.net/downloads/busybox-1.36.1.tar.bz2 # Or latest version
tar -xjvf busybox-1.36.1.tar.bz2
cd busybox-1.36.1
Configure Busybox for standalone mdev compilation:
Create a .config file with the minimum needed:
bash
make defconfig # Start with a default configuration
make menuconfig
# Unselect almost everything, except for these:
# Busybox Settings --->
# General Configuration --->
# [*] Build Busybox as a static binary (no shared libs)
# Coreutils --->
# [*] mdev
# [*] Support /etc/mdev.conf
# Linux System Utilities --->
# [*] mdev
# [*] Support /etc/mdev.conf
# Save the .config
Compile Busybox:
bash
make
Extract mdev:
The compiled mdev binary will be in busybox-1.36.1/. Copy it to somewhere accessible:
Create a runit service for device management:
Create a directory /etc/service/devman or similar. Inside it, create a run script:
bash
#!/bin/sh
# /etc/service/devman/run
mkdir -p /dev # Ensure /dev exists
mount -t devtmpfs devtmpfs /dev # Mount devtmpfs
# Initial scan:
mdev -s
# Listen for hotplug events:
while true; do
mdev -f # Wait for an event and act
done
Make the run script executable: chmod +x /etc/service/devman/run
Enable the runit service:
Use ln -s /etc/service/devman /service/devman to enable the service.
Reboot:
Reboot your system to test.
Uninstall eudev:
bash
# Example for Debian/Ubuntu (adapt as needed)
sudo apt remove eudev
This is a general outline. You may need to adapt it to your specific system configuration. Remember to back up your system before making significant changes!
Device Node Management (Crucial Step):
libudev-zero provides the library for interacting with devices, but it doesn't automatically create device nodes. You'll still need a mechanism for creating those nodes. You have a few options, ordered from simpler to more complex:
Option A: mdev (again) with libudev-zero: You can still use mdev (as outlined in the previous response), but instead of relying on eudev, you can use the libudev-zero library. This would require modifying mdev to link against libudev-zero instead of libudev from systemd.
Option B: Custom Script Based on udev Rules:
Parse udev Rules: You would need to write a script (e.g., in Python or shell) that parses the udev rules in /etc/udev/rules.d. This is the most complex part. The format of these rules can be complex.
libudev-zero for Device Info: Within the script, you would use libudev-zero to enumerate devices and get their properties.
Apply Rules: For each device, your script would iterate through the udev rules, find the matching rules, and execute the corresponding actions (e.g., create device nodes, set permissions).
Option C: Custom C Daemon: Similar to Option B, but implemented as a C daemon for potentially better performance. It uses libudev-zero to monitor devices and create device nodes according to udev rules. This is the most complex option and likely requires a strong understanding of C programming and system-level concepts.
runit Services:
Create runit services to manage the device node creation process (using either mdev, a custom script, or a custom daemon). This service would start at boot and listen for hotplug events.
Remove eudev:
After you have configured your system to use libudev-zero and your device management solution, remove eudev.
Example (Simplified) runit service for a Python Script (Option B):
This is a very simplified example.
python
#!/usr/bin/env python3
# /etc/service/udev-manager/run
import pyudev # Install pyudev package (pip install pyudev)
import os
import subprocess # For running commands like mkdir, chmod
def create_device_node(dev):
devpath = dev.device_node
# Basic Example, expand as needed
if devpath:
print(f"Creating device {devpath}")
try:
# Create the directory if needed
os.makedirs(os.path.dirname(devpath), exist_ok=True)
# Determine major/minor numbers. In real life, you'd parse this carefully
# from /sys
major = 1
minor = 2
mode = "660"
command = ["mknod", devpath, "c", str(major), str(minor)]
subprocess.run(command, check=True)
#Set permissions
command = ["chmod", mode, devpath]
subprocess.run(command, check=True)
except Exception as e:
print(f"Error creating {devpath}: {e}")
context = pyudev.Context()
#Enumerate existing devices:
for device in context.list_devices():
create_device_node(device)
#Listen for new devices:
monitor = pyudev.Monitor.from_netlink(context)
monitor.filter_by(subsystem='block') # Example subsystem
for action, device in monitor:
if action == 'add':
create_device_node(device)
Put this into /etc/service/udev-manager/run. Make it executable chmod +x /etc/service/udev-manager/run. Create link -s /etc/service/udev-manager /service/udev-manager.
Advantages of using libudev-zero:
Minimal Dependencies: Avoids the bloat and complexity of systemd.
libudev API Compatibility: Allows applications that use libudev to work without modification.
Integration with runit: Seamlessly integrates with your existing runit setup.
Control: Gives you more control over device node creation.
Disadvantages:
Development Effort: Requires some development effort to handle device node creation, parse udev rules (if needed), and create the runit service.
Maintenance: You are responsible for maintaining the scripts or daemon that handles device node creation.
Rule Parsing: The format of udev rules can be intricate. Implementing a full parser can be complex.
Conclusion:
libudev-zero is a very promising solution for replacing eudev in your runit-based system. It provides a minimal, standalone libudev API implementation that allows you to keep applications that depend on libudev working without needing systemd. You'll need to invest some time in developing a device node management solution (using mdev, a custom script, or a custom daemon), but it gives you a good balance between functionality, control, and minimal dependencies.
# Get udevil source - example, replace with your distro's source method
apt source udevil
cd udevil-x.y.z # replace with actual version
# Example settings, adjust as needed for your build system and distro paths
export LIBUDEV_CFLAGS="-I/usr/include" # or /usr/local/include
export LIBUDEV_LIBS="-ludev" # Make sure libudev-zero installed to correct library path
# Configure, build, and install - distro-specific
./configure
make
sudo make install
Library Preloading (Less Reliable): As a temporary measure (for testing), you could try using LD_PRELOAD to force udevil to use libudev-zero at runtime. However, this is not a reliable long-term solution.
bash
LD_PRELOAD=/usr/lib/libudev.so.0 udevil --mount /dev/sdb1 # Or the correct path to your libudev-zero
If this works, then it confirms that udevilcan work with libudev-zero.
Device Node Management and Initial /dev Population:
While udevil will handle mounting and unmounting, you still need to ensure that the necessary device nodes exist in /dev when the system boots. This is because udevil relies on these device nodes being present.
Option A: Use devtmpfs and a simple mdev -s:
Mount devtmpfs onto /dev
Run mdev -s at boot to populate /dev
Option B: Implement Minimal Device Node Creation Script: For very specific, known devices, create a script (run by runit) that uses mknod to create the device nodes. Example:
bash
#!/bin/sh
# /etc/service/device-nodes/run
mkdir -p /dev
mknod /dev/sda b 8 0 # Example for sda
chmod 660 /dev/sda # Set permissions
Advantages Very simple
Disadvantages Only good for static device setups.
runit Services:
Create runit services to manage these tasks:
A service to mount devtmpfs on /dev (if you are using devtmpfs)
A service to run mdev -s or your manual device node creation script at boot.
Remove eudev:
Once you've verified that udevil is working correctly with libudev-zero and that your device nodes are being created properly, remove eudev.
Example runit Service for Mounting devtmpfs and running mdev -s:
Make that executable (chmod +x) and link to /service.
Why This Approach Is Best:
Leverages udevil: It takes advantage of the functionality already provided by udevil for mounting and unmounting devices.
Minimal Effort: It avoids the complexity of writing a full-fledged udev rule parser or device manager.
libudev-zero Compatibility: It ensures that udevil uses libudev-zero instead of the systemd or eudev version.
Dependency Reduction: It removes eudev, reducing the dependencies of your system.
Important Considerations:
Testing: Thoroughly test all device-related functionality after replacing eudev. Make sure you can mount, unmount, and access removable devices correctly.
udev Rules: Examine the udev rules currently used by udevil (if any) to ensure they are still compatible with libudev-zero. Some rules might rely on systemd-specific features.
In summary, given your use of runit and udevil, the best strategy is to:
Install libudev-zero.
Recompile udevil against libudev-zero.
Ensure device nodes are created at boot using devtmpfs and mdev or a manual script.
Create runit services to manage these tasks.
Remove eudev.
This approach provides the most straightforward path to replacing eudev while minimizing dependencies and leveraging your existing system configuration.