Ramdisk root file system + initramfs

Source: Internet
Author: User
Ramdisk root file system + initramfs started the ramdisk root file experiment these days. Test Environment: Ubuntu12.04 first I think it is better to create the root file system, because one of the configuration kernels is related to the ramdisk size you have created. Here, I directly used the original ramdisk root file system + initramfs to start the ramdisk root file experiment over the past few days. Test Environment: Ubuntu 12.04 first I think it is better to create the root file system, because one of the configuration kernels is related to the ramdisk size you have created. Here I directly use the original root file system. 1. create a ramdisk root file system image first install the ext2 file system production tool: # sudo apt-get install genext2fs jump to the directory where your rootfs file system is located, run the following command # genext2fs-B 4096-d rootfs ramdisk-B indicates that the size of the created ramdisk is 40, 96 KB-d. it indicates that the ramdisk at the end of the root file system directory for ramdisk creation is ramdisk name, of course you can change the name. Note: If an error such as genext2fs: couldn't allocate a block (no free space) occurs, change 4096 to 8192 # gzip-9-f ramdisk. the ramdiskis compressed to ramdisk.gz 2 in simplified format. to configure the kernel, first extract the kernel to the working directory, then enter the kernel directory and execute the following statement. # Sudo su # make menuconfig (for example, if a user in ubuntu cannot execute this command, run the following command sudo apt-get install libncurses5-dev first) general setup --> [*] Initial RAM filesystem and RAM disk support --> [*] Optimize for size Device Drivers --> Block devices --> <*> RAM block device support (4096) default RAM disk size (kbytes) // if your previously created ramdisk is 8192kb, write it as 8192 File system --> <*> Second extended fs support // provide kernel support for ext2 File system exit save configuration. 3. Compile the kernel and run the following command: # make clean # make uImage the kernel image uImage generated after compilation is located in the current directory. Copy it to the/nfs Directory # cp uImage/nfs 4. connect the development board and computer with a network cable and a serial line (do not enable the development board now), enable minicom: # sudo minicom to power on the development board, and when the following characters appear, Hit any key to stop autoboot, press the space key on the keyboard to enter uboot. 6. use the uboot command to configure the environment variable # setenv serverip 10.0.0.1 // corresponding host IP address # setenv ethaddr 00: 26: 6c: 5a: a7: 51 description: the hardware address is the hardware address of the host, run ifconfig eth0 in another terminal to view # setenv ipaddr 10.0.0.2 // development board IP address # setenv bootargs initrd = 0x82.1600,0x200000 root =/dev/ram rw console = ttyS2, 115200n8 mem = 64 M init =/linuxrc description: it means starting from ramdisk. the starting address of the ramdisk compressed file is at the memory address 0x8000000, and the file size is 0x200000. This is really quite depressing ..... after the download is complete, always in Uncompressing Linux .................................... I stopped there, and I don't know how to do it for a few days. so .... I did not write the baud rate after console = ttySx. The last step is to add a baud rate. although I still don't understand it, why can't I do it without specifying the baud rate ~~ # Saveenv, reset the development board, and enter uboot again. 7. run the following command on another terminal to configure the host IP address # sudo ifconfig eth0 10.0.0.1 8. continue back to minicom to test whether the network is available # ping 10.0.0.1 if the output statement host 10.0.0.1 is alive indicates that the network is available 9. use uboot to download and write the kernel and ramdisk. # Nfs 0x82000000 10.0.0.1:/nfs/uImage # nfs 0x81000000 10.0.0.1:/nfs/ramdisk.gz note: ramdisk.gz must be the initrd address set in your parameter. 10. start the kernel # bootm 0x82000000 PS: if the following problem occurs during startup: Failed to execute/linuxrc. attempting defaults... kernel panic-not syncing: No init found. try passing init = option to kernel. the possible cause is that setenv bootargs initrd = 0x82.1600,0x200000 root =/dev/ram rw console = ttyS2, 115200n8 mem = 64 M init =/linuxrc's ramdisk size settings, change 0x200000 to 0x400000. To burn uImage and ramdisk, run the following command ): # nand erase 00280000 400000 // erase space 400000 from 0x00280000 # nand write 82000000 00280000 400000 400000 // read 00280000 size content from 0x82000000 to 0 x burn write ramdisk: # nand erase 00780000 400000 # nand write 81000000 00780000 400000 and set the startup command: # setenv bootcmd nand read 82000000 00280000 400000 \; nand read 81000000 00780000 400000 \; bootm 82000000 initramfs root file system startup is now based on Linux releases usually use initramfs instead of initrd. the architecture is simpler and applications are more flexible. First, you need to complete the simple root file system directory of rootfs. The only thing that needs to be modified is that the first program executed during initramfs root file system startup is init rather than linuxrc. Therefore, you need to add an init file to the root file system, the corresponding linuxrc file is no longer needed. Modify the root file system # cd/nfs/rootfs # ln-s bin/busybox init as follows to create a soft link init for busybox, this file is the init file we want to create. To configure the kernel, you only need to configure the following options: [*] Initial RAM filesystem and RAM disk (initramfs/initrd) support (/nfs/rootfs) Initramfs source file (s) // specify your rootfs path in brackets to compile and generate a uImage. When setting the uboot environment variable, you only need to change the bootargs variable # setenv bootargs console = ttys2, 115200n8 mem = 64 M. Other steps are no different from ramdisk.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.