linuxbuildrootrootfs

Buildroot doesn’t run as root and doesn’t want to run as root


I have 2 questions:

Why buildroot need to be root to create the /dev

Ref: http://free-electrons.com/~thomas/buildroot/manual/html/ch03.html


Solution

  • I am not sure to undrestand(from the directories description in Buildroot manual):

    Buildroot, a tool for generating a kernel and root filesystem, is executed on your host system as a normal user without need of superuser privileges.


    Why buildroot need to be root to create the /dev

    Buildroot does not use superuser privileges.


    what i know is that buildroot uses target to generate images/rootfs.tar; is it a simple compression with taror ...?

    The .tar is an ordinary archive without compression.
    You can configure/specify compression (and/or select filesystem images) using the make menuconfig procedure.


    could you please help me find the make target that generate images/rootfs.tar?

    You do not specify this in the make shell command.
    You can configure/specify tar and/or cpio archives with optional compression (and/or select filesystem images) using the make menuconfig procedure.


    In case of using NFS why can't we use directly the target folder as rootfs

    Because it is not suitable as a roofs.
    File owners & groups are incorrect (this could be irrelevant for NFS usage).
    File permissions may not be correct (e.g. setuid for the busybox binary).
    The /dev directory does not have the minimal device nodes that the target kernel requires.

    Instead of the required minimal device nodes (e.g. console), the target directory has ordinary files in dev:

    buildroot-2015.05/output/target$ ls -l dev
    total 4
    -rw--w--w- 1 me swdev    0 Sep 15 16:34 console
    lrwxrwxrwx 1 me swdev   10 Aug 14  2015 log -> ../tmp/log
    drwxrwxr-x 2 me swdev 4096 May 31  2015 pts
    $
    

    The target kernel cannot use these files when it expects device nodes. Instead of I/O performed through device nodes, ordinary file transfers will be attempted with these files.

    The actual dev directory should be:

    crw--w--w- 1 root root 5, 1 Sep 15 16:34 console
    lrwxrwxrwx 1 root root   10 Aug 14  2015 log -> ../tmp/log
    drwxr-xr-x 2 root root 4096 May 31  2015 pts
    

    what makes "untaring" images/rootfs.tar different than target

    Buildroot can cleverly create entries for the device nodes and assign the proper owner and group to each filename as it creates the archive (or filesystem image).
    This is simply generating binary data in the appropriate format that is inserted with actual archive entries (or to the fs image) written to a file.
    Only when it is un-archived (or the filesystem image is mounted) that the "data" is properly interpreted as for device nodes.