Search code examples
filesystemrootuclinux

How can I add or remove any files into and from initramfs root file system?


As I entitled, I want to manipulate the root file system of my uClinux. It is based on initramfs.

I know /usr has most of the files which related to make root file system.

├── .built-in.o.cmd
├── .gen_init_cpio.cmd
├── .gitignore
├── .initramfs_data.cpio.gz.cmd
├── .initramfs_data.cpio.gz.d
├── .initramfs_data.o.cmd
├── Kconfig
├── Makefile
├── built-in.o
├── gen_init_cpio
├── gen_init_cpio.c
├── initramfs_data.S
└── initramfs_data.cpio.gz

This is it.

And there is a directory, ../romfs, which seems to be used as the root file system. There is a directory ../romfs/mnt/ And I want to make a directory ../romfs/mnt/flash But mkdir ../romfs/mnt/flash doesn't help. Downloaded image doesn't include ../romfs/mnt/flash And actually ../romfs/mnt/flash is removed right after the compilation.

How can I add or remove any directory to my root file system?

Thank you very much..


Solution

  • Let me post my solution to this problem of mine. I am posting this as an answer because it has volume too big to be put to comments to other's answer or my question.

    First I searched for fstab under the top directory of my project.

    find -name "fstab"
    

    The result is shown below.

    ./vendors/{vendorname}/{modelname}/fstab
    ./vendors/{vendorname}/{modelname}/fstab
    ./vendors/{vendorname}/{modelname}/fstab
    ./vendors/{vendorname}/{modelname}/fstab
    ./vendors/{vendorname}/{modelname}/fstab
    ./romfs/etc/fstab
    

    ./romfs/etc/fstab is copied from one of the fstab s under ./vendors/{vendorname}/{modelname}/ s.

    BINGO! ./vendors/{vendorname}/{modelname}/ includes everything I need.

    looking up ./vendors/{vendorname}/{modelname}/Makefile explains everything.

    I hope someone who found this question and answers can get useful information here!!

    Thanks.