I am working on a ARM-Based embedded system with a custom Debian Linux based on kernel 2.6.31. In the final system, the Root file system is stored as squashfs on flash. Now, the folder /dev is created by udev, but since there is no hot plugging functionality needed and booting time is critical, I wanted to delete udev and "hard code" the /dev folder (read here, page 5). because i still need to change parameters of the devices (with ioctl /sysfs) this does not work for me in this case. so i thought of mounting a tmpfs on /dev and change the parameters there. is this possible? and how to do best? my approach would be:
delete /dev from RFS
create tar containing basic devices
mount tmpfs /dev
untar tar-file into /dev
change parameters
Could this work? Do you see any problems?
I found out, that you can mount on top of already mounted mount point, is it somehow possible just to take data with while mounting the new file system? if so that would be very convenient!
Thanks
Update: I just tried that out, but I'm stuck at a certain point. I packed all my devices into devices.tar, packed it into /usr of my squashfs and added the following lines to mountkernfs.sh, which is executed right after INIT.
#mount /dev on tmpfs
echo -n "Mounting /dev on tmpfs..."
mount -o size=5M,mode=0755 -t tmpfs tmpfs /dev
mknod -m 600 /dev/console c 5 1
mknod -m 600 /dev/null c 1 3
echo "done."
echo -n "Populating /dev..."
tar -xf /usr/devices.tar -C /dev
echo "done."
This works fine on the version over NFS, if I place printf's in the code, I can see it executing, if I comment out the extracting part, its complaining about missing devices.
Booting OK
mmc0: new high speed SDHC card at address 0007
mmcblk0: mmc0:0007 SD04G 3.67 GiB
mmcblk0: p1
IP-Config: Unable to set interface netmask (-22).
Looking up port of RPC 100003/2 on 192.168.1.234
Looking up port of RPC 100005/1 on 192.168.1.234
VFS: Mounted root (nfs filesystem) on device 0:14.
Freeing init memory: 136K
INIT: version 2.86 booting
Mounting /dev on tmpfs...done.
Populating /dev...done.
Initializing /var...done.
Setting the system clock.
System Clock set to: Thu Sep 13 11:26:23 UTC 2012.
INIT: Entering runlevel: 2
UBI: attaching mtd8 to ubi0
Commenting out the extraction of the tar
mmc0: new high speed SDHC card at address 0007
mmcblk0: mmc0:0007 SD04G 3.67 GiB
mmcblk0: p1
IP-Config: Unable to set interface netmask (-22).
Looking up port of RPC 100003/2 on 192.168.1.234
Looking up port of RPC 100005/1 on 192.168.1.234
VFS: Mounted root (nfs filesystem) on device 0:14.
Freeing init memory: 136K
INIT: version 2.86 booting
Mounting /dev on tmpfs...done.
Populating /dev...done.
Initializing /var...done.
Setting the system clock.
Cannot access the Hardware Clock via any known method.
Use the --debug option to see the details of our search for an access method.
Unable to set System Clock to: Thu Sep 13 12:24:00 UTC 2012 ... (warning).
INIT: Entering runlevel: 2
libubi: error!: cannot open "/dev/ubi_ctrl"
So far so good. But if I pack the whole story into a squashfs and boot from there, it is acting strange. It's telling me while booting that it is unable to open an initial console and its throwing errors on mounting the UBIFS devices, but finally provides a login anyway. Over that my echo's are not executed. If I then log in, /dev is mounted as TMPFS as desired and all the devices reside inside. When I redo the "mount" command to mount the UBIFS partitions it is executed whitout problem and useable.
From squashfs
VFS: Mounted root (squashfs filesystem) readonly on device 31:15.
Freeing init memory: 136K
Warning: unable to open an initial console.
mmc0: new high speed SDHC card at address 0007
mmcblk0: mmc0:0007 SD04G 3.67 GiB
mmcblk0: p1
UBIFS error (pid 484): ubifs_get_sb: cannot open "ubi1_0", error -19
Additionally, a part of the rest of the bootscripts is still exexuted, but not all of them. Does anyone has a clue why?
Other question, is 5MB enough/too much for /dev?