The production of linux rootfs.img

Cramfs is a read-only compressed file system. The file system type can be ext2, ext3, etc.
Cramfs and romfs are just a file system type. Ramdisk is equivalent to a piece of hard disk space, which can be understood as a virtual hard disk in the memory, so You can have various file systems supported by Linux on it. So what you asked, it is really not a hierarchical concept with romfs and cramfs. ^-^Congratulations, the directory of the root file system you got right is rootfs (all the files you will use in the future are here)
like this: mkcramfs rootfs rootfs.cramfs and you are done. As the name suggests, it is read-only compression, so it saves space. If your flash is smaller, use this! After the system starts, the kernel loads it into the memory and decompresses it, so it takes up more memory. It depends on your needs.

And ramdisk? This is more used. The ramdisk is equivalent to a piece of hard disk space, which can be understood as a virtual hard disk in the memory, so it can have various file systems supported by your Linux. So what you asked, it is really not a hierarchical concept with romfs and cramfs. The key is that in the future, you can write in ramdisk, which is an important difference from cramfs.
Specific production method:
dd if=/dev/zero of=rootfs.img bs=1M count=100 an integer (see your actual space required, usually 10M)
format it to the file system you need , Such as ext2, ext3, reiserfs, etc.,
such as ext3: mkfs.ext3 -m 0 -O none -F root.img
and then mount it to a directory, such as tmp:
mount -o loop root.img /tmp/

Then, copy all files in the directory where your file system is located to the tmp directory: For example, your file system directory is in /root/rootfs-test:
cp -av /root/rootfs-test/* /tmp/ (Note one here Details: When copying, use the parameter a to mean copy all, v means only copy the link itself, not the content it points to, this is very important!) In addition, some people often use: cp -pdR, you can also try this Try, which means what the original is, copy is what it used to be.

Then unmount the /tmp/ directory.
umount /tmp In

general, ramdisk is to be compressed. For the generated img and rootfs.img above, you can compress it like this:
gzip -v9 rootfs.img will automatically generate rootfs.img.gz, the general compression rate, 30%!

Guess you like

Origin blog.csdn.net/daocaokafei/article/details/114845020