Article Title: how to create an Image file in Linux. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
See what you want to make rh_linux.img look like. If it is a file system, you need to do this:
Dd if =/dev/zero of = rh_linux.img count = CONTS
The count parameter indicates the size of the file to be created (in blocks, the size of each block is 512 bytes. if the size of rh_linux.img is 1 MB, CONTS = 2000 ).
After creating rh_linux.img, you need to use the file system tool (mkfs. ext2, mkfs. ext3, mkfs. format it (for example, mkfs. ext3 rh_linux.img); next use: mount-o loop MDIR rh_linux.img to mount the image file to the MDIR directory and boot. copy the bin file.
I. Why is such a Linux
I have always wanted to create a small linux of my own, but all the results obtained from searching on the Internet are made in linux on a floppy disk and started with lilo. Unfortunately, my laptop does not have a software drive, so these are not suitable for you. Simply create a linux instance that can be started and run from the CD.
II. Introduction to Linux startup
After the system powers up, it enters the bios, then reads the master boot record (MBR) of the hard disk, and then calls another boot program (grub or lilo) to load the kernel and image files. After the kernel is loaded, the system stores the file system in ram and runs the system. Here we use grub to load kernel and image files.
III. Compile the kernel
I use the linux 2.6 Kernel. the detailed kernel compilation method can be obtained from the following articles. I will not go into details here.
Http://hi.baidu.com/lianxi1999/blog/item/95c782111f75a212b8127b03.html
4. compile busybox
Busybox is a software integrated with more than one hundred common linux commands and tools. my understanding is to generate a small program with common commands in linux. After we put the compiled busybox program into our system, we can use some common commands in linux.
Compiling busybox is the same as compiling other linux programs. first, download busybox. I use version 1.0.
# Tar xvfz busybox-1.00.tar.gz // unlock busybox
# Cd busybox-1.00
# Make menuconfig // Configure busybox
The following are functional options that need to be compiled into busybox. other options can be compiled as needed.
General Configuration options
Show verbose applet usage messages
Runtime SUID/SGID configuration via/etc/busybox. conf
Build Options
Build BusyBox as a static binary (no shared libs)
This option must be selected so that busybox can be compiled into a static link executable file, and the runtime is independent of other function libraries. otherwise, other library files must be required to run and cannot work properly on a single Linux kernel.
Installation Options
Don't use/usr
This option must also be selected. otherwise, after make install, busybox will be installed in the/usr of the original system, which will overwrite the original command of the system. after this option is selected, make install will generate a directory named _ install under the busybox directory, which contains busybox and its link.
Other options are some basic linux command options. you can compile the commands you need. Generally, you can use the default command.
After configuration, exit and save.
# Make // compile busybox
# Make install // install busybox
After compilation, generate the subdirectory _ install in the busybox Directory. the content is as follows:
Bin
Linuxrc-> bin/busybox
Sbin
[1] [2] [3] [4] Next page