FS#18232 - [udev] post_install: mknod fails to create basic char devices if the files exist.

Attached to Project: Arch Linux
Opened by Jonathan Frazier (wide-eye) - Monday, 08 February 2010, 11:56 GMT
Last edited by Tobias Powalowski (tpowa) - Wednesday, 24 November 2010, 15:10 GMT
Task Type Bug Report
Category Packages: Core
Status Closed
Assigned To Tobias Powalowski (tpowa)
Thomas Bächler (brain0)
Architecture All
Severity High
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

Description:
in udev.install mknod will fail to create /dev/{null,console,zero} if one of the files exists because mknod does not replace existing files.

this occurs for /dev/null during an install with pacman -S base -r /mnt/:

( 53/108) installing udev [##########################################################################################################] 100%
sh: warning: setlocale: LC_ALL: cannot change locale (en_US.utf8)
mknod: `/dev/null': File exists

this results in an error at boot as /dev/null is not a special file and cannot be written to:
/etc/rc.d/functions: line 34: /dev/null: Read-Only file system

Additional info:
udev 151-2



Steps to reproduce:

install a system with pacman -S base -r /mnt and examine /mnt/dev/null

or test the logic of post_install() when /dev/null has been created by previously run install scripts:

$ touch null
$ [ -c null ] || mknod -m644 null c 1 3
mknod: `null': File exists
$ ls -la null
-rw-r--r-- 1 root root 0 Feb 8 06:08 null

null should be: "crw-r--r-- root root 1, 3"
This task depends upon

Closed by  Tobias Powalowski (tpowa)
Wednesday, 24 November 2010, 15:10 GMT
Reason for closing:  Fixed
Additional comments about closing:  udev-164-1
Comment by Gerardo Exequiel Pozzi (djgera) - Monday, 08 February 2010, 18:04 GMT
This is because is assumed that "/dev" (and "/proc" "/sys") are mounted on target directory when install the "base" group. Previous install scripts (before udev install) that do "> /dev/null" will write a normal file because does not exists. When udev install script checks that "/dev" and "/" are on the same FS, does not mount (bind) "/".

Comment by Jonathan Frazier (wide-eye) - Tuesday, 09 February 2010, 08:18 GMT
What part of installing base packages with pacman requires these partitions to be mounted? having read through the post_install functions in core I do not see a reason for it. After installing base with and without dev, proc and sys mounted I find 2 errors: mknod fails as I have described, and the autodetect hook in mkinitcpio fails to search /sys/devices. mkinitcpio after the error leaves extra modules in the initramfs so it is just like the fallback initramfs, remaining perfectly usable. This mknod is the only thing which requires user action to repair. I am suggesting to change udev.install to remove a bad /dev/null if it exists before running mknod. with this change pacman -Sy base -r /mnt will work with or without /dev mounted.

attached is a diff of the pacman output for two installs, with and without proc, sys, and dev mounted. and a diff -ur of the two install directories. the install timestamp differences from pacman.log and pacman db have been removed.
Comment by Thomas Bächler (brain0) - Sunday, 28 February 2010, 19:58 GMT
I experienced this problem myself recently when creating a chroot with pacman -S base.

We could move the post_install from udev to filesystem. Or/And we could make the procedure more robust.
Comment by Gerardo Exequiel Pozzi (djgera) - Sunday, 05 September 2010, 21:44 GMT
Looks like now, by the order of installed package, before udev there is no dev/null (as regular file). Anyway anyone can commit this? Just add "rm -f" before using mknod.
Comment by Thomas Bächler (brain0) - Monday, 06 September 2010, 05:23 GMT
Done.
Comment by Gerardo Exequiel Pozzi (djgera) - Thursday, 21 October 2010, 00:58 GMT
Great. Oops!, just a small fix. I missed -f to the last rm

Loading...