Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
12748 Discussions

initramfs problem: can't replace motd

Altera_Forum
Honored Contributor II
2,218 Views

Let me ask a really dumb question... 

 

Why can't I replace the /etc/motd file with my own? 

 

I'm using pretty much the default kernel and app config of uClinux which means all the files in uClinux-dist/romfs/ are going to be my file system after compilation. 

 

I've had success building simple stand alone executables and throwing them in the /bin directory, but this is the first time I've tried to make a modification to an existing file. I figured motd is appropriate as it has no effect on the system other than being printed at boot time, and the results are easy to see. 

 

Before compilation I replace uClinux-dist/romfs/etc/motd with my own. When I run make, somewhere along the line it gets completely replaced. 

 

In trying to figure out where the source file is, I changed the permissions of the motd to 000 to force an error on compilation when it attempts to overwrite. This only brought me to /uClinux-dist/linux-2.6.x/usr/initramfs_data.cpio.gz which is an archive I can't open because my OS doesn't know what a cpio file is. 

 

I tried removing the line "../romfs/etc/motd \" from /uClinux-dist/linux-2.6.x/usr/.initramfs_data.cpio.d in hopes it would ignore the motd file after that. No Luck, it came back. 

 

Can someone shed some light on this mystery? 

 

Thanks, 

Todd
0 Kudos
7 Replies
Altera_Forum
Honored Contributor II
834 Views

eltoddo, 

 

You might be better off by changing the last line of your board's "rc" script to call your own program instead of "motd". 

 

The nios2 "rc" script is located in the .../nios2-linux/uClinux-dist/vendors/Altera/nios2 directory. The last line reads "cat /etc/motd". 

 

Good Huntin' 

cb
0 Kudos
Altera_Forum
Honored Contributor II
834 Views

Good suggestion cb, 

 

I originally tried editing the romfs/etc/rc file and found that it was also replaced. I just assumed that the file was also overwritten by the same mysterious force that motd is. 

 

Changing the rc file in the location you suggested worked and allowed me to change the output to motd.alt. So the work-around allowed me to accomplish using a different file. 

 

Still, I really don't like the idea of motd being replaced/generated by a source file which I have no idea where it comes from. Now I question which other files I make changes to will be blown away by rebuilding the kernel. 

 

If anyone knows where motd is generated/copied from please let me know so I can have some idea of what changes I can make and which I can't. 

 

Cheers, 

Todd
0 Kudos
Altera_Forum
Honored Contributor II
834 Views

Please change the files at 

nios2-linux/uClinux-dist/vendors/Altera/nios2 

 

They are copied to romfs/etc when making "romfs" target. 

 

- Hippo
0 Kudos
Altera_Forum
Honored Contributor II
834 Views

Hi Hippo, 

 

Thanks for the heads up on that directory. That addresses a whole bunch of the files I'll be after soon. But the motd file is unaccounted for. 

 

Something must either generate it or copy it's contents from another file. Could it be decompressed out of an archive?
0 Kudos
Altera_Forum
Honored Contributor II
834 Views

I think anything not in the specific vendor directory is in vendors/Generic/romfs/

0 Kudos
Altera_Forum
Honored Contributor II
834 Views

Hey ykozlov,  

 

Good catch! Sure enough the motd file there, if changed, will be put in romfs in the kernel image file. 

 

I'm pretty sure I tried modifying each 'motd' file in the uClinux-dist folder tree. Oh well, I guess I missed this one somehow. 

 

Nice to have closure on this. 

 

Cheers!
0 Kudos
Altera_Forum
Honored Contributor II
834 Views

IMHO, the correct way is to create the file in your vendors/* directory and modify the make file there accordingly.  

 

Moreover at best you create your own vendors/* directory. 

 

-Michael
0 Kudos
Reply