{"id":284679,"date":"2023-10-07T04:02:57","date_gmt":"2023-10-06T20:02:57","guid":{"rendered":"https:\/\/gulass.cn\/lnhrhqdgwjxt.html"},"modified":"2023-10-07T04:02:57","modified_gmt":"2023-10-06T20:02:57","slug":"lnhrhqdgwjxt","status":"publish","type":"post","link":"https:\/\/gulass.cn\/lnhrhqdgwjxt.html","title":{"rendered":"linux\u5185\u6838\u5982\u4f55\u542f\u52a8\u6839\u6587\u4ef6\u7cfb\u7edf\u955c\u50cf\u6587\u4ef6\u6587\u4ef6\u6e90\u7801\u4e0b\u8f7d"},"content":{"rendered":"

\u8981\u5b66\u4e60linux\u5185\u6838\uff0c\u5148\u8981\u624d\u80fd\u7f16\u8bd1\u5185\u6838\uff0c\u8fd8\u987b\u8981\u4e86\u89e3\u5185\u6838\u600e\u4e48\u542f\u52a8\u6839\u6587\u4ef6\u7cfb\u7edf<\/a>\u3002\u8fd9\u6837\u4f60\u80fd\u591f\u5728\u66f4\u6539linux\u5185\u6838\u4ee3\u7801\u4ee5\u540e\uff0c\u5b8c\u6210\u9a8c\u8bc1\u7684\u8fc7\u7a0b\u3002<\/p>\n

\u672c\u6587\u6559\u4f60\u5b8c\u6210\u4e0b\u8ff0\u8fc7\u7a0b\uff1a<\/p>\n

1.\u4e0b\u8f7dlinux\u5e76\u7f16\u8bd1linux\u5185\u6838\u6e90\u7801<\/p>\n

2.\u7f16\u8bd1busybox<\/p>\n

3.\u5236\u505a\u4e00\u4e2a\u6700\u5c0f\u7684\u6839\u6587\u4ef6\u7cfb\u7edf<\/p>\n

4.qemu\u542f\u52a8\u4f60\u7f16\u8bd1\u597d\u7684\u5185\u6838\u548c\u6839\u6587\u4ef6\u7cfb\u7edf<\/p>\n

linux\u6e90\u7801\u4e0b\u8f7d\u5730\u5740\uff1a<\/p>\n

\u6211\u9009\u62e9\u7684\u7248\u672c\u662f\uff1a4.9.229<\/p>\n

\u4e0b\u8f7d\u5230\u672c\u5730\uff0c\u89e3\u538b\uff0c\u4e4b\u540e\u6b65\u5165linux-4.9.229\u76ee\u5f55\uff1a<\/p>\n

linux\u8bbe\u5907\u9a71\u52a8\u5f00\u53d1\u8be6\u89e3 \u6e90\u7801_linux\u9a71\u52a8\u6e90\u7801\u5206\u6790_linux\u9a71\u52a8\u5f00\u53d1\u5de5\u5177<\/p>\n

1.\u6307\u5b9a\u786c\u4ef6\u4f53\u7cfb\u6784\u67b6\u3002<\/p>\n

\u4e3a\u4e86\u964d\u4f4e\u5b89\u88c5\u7f16\u8bd1\u5668\u7684\u8fc7\u7a0b\uff0c\u6211\u5728\u672c\u4f8b\u4e2d\u4f7f\u7528\u7684\u662fx86\uff0c\u7531\u4e8e\u6211\u7684\u5f00\u53d1\u73af\u5883\u5c31\u662fx86\u3002\u5047\u5982\u4f60\u8981\u7f16\u8bd1arm\u7684\u5185\u6838\uff0c\u5219\u6307\u5b9aARCH=arm\u4e14\u987b\u8981\u5b89\u88c5\u4ea4\u53c9\u7f16\u8bd1\u5668\u3002<\/p>\n

\n

# export ARCH=x86<\/code><\/pre>\n<\/p>\n

2.\u914d\u7f6eboardconfig,\u6b64\u5904\u914d\u7f6e\u4e3ax86_64_defconfig\u3002\u597d\u4e86\uff0c\u6211\u4eec\u70b9\u597d\u83dc\u4e86\uff0c\u83dc\u5355\u5c31\u662fx86_64_defconfig<\/p>\n

\n

# make  x86_64_defconfig<\/code><\/pre>\n<\/p>\n

3.\u914d\u7f6e\u5185\u6838<\/p>\n

\u8fd9\u4e00\u6b65\u5f53\u7136\u662f\u5bf9\u7b2c2\u6b65\u7684\u83dc\u5355\u8fdb\u884c\u5fae\u8c03\uff0c\u6211\u4eec\u987b\u8981\u5185\u6838\u652f\u6301ramdisk\u9a71\u52a8\uff0c\u6240\u4ee5\u987b\u8981\u9009\u4e2d\u5982\u4e0b\u914d\u7f6e\uff1a<\/p>\n

\n

General setup  --->\n       ----> [*] Initial RAM filesystem and RAM disk (initramfs\/initrd) support\n    Device Drivers  --->\n       [*] Block devices  --->\n                  RAM block device support\n               (65536) Default RAM disk size (kbytes)<\/code><\/pre>\n<\/p>\n

linux\u9a71\u52a8\u5f00\u53d1\u5de5\u5177_linux\u9a71\u52a8\u6e90\u7801\u5206\u6790_linux\u8bbe\u5907\u9a71\u52a8\u5f00\u53d1\u8be6\u89e3 \u6e90\u7801<\/p>\n

4.\u7f16\u8bd1\u5185\u6838<\/p>\n

\n

# make<\/code><\/pre>\n<\/p>\n

\u7f16\u8bd1\u6210\u529f\u540e\u7684\u5185\u6838\u5750\u843d\uff1aarch\/x86_64\/boot\/bzImage<\/p>\n

\u4e0b\u8f7dbuysbox\u6e90\u7801\uff0c\u4e0b\u8f7d\u5730\u5740\uff1a<\/p>\n

\u6211\u4f7f\u7528\u7684\u7248\u672c\u662fbusybox-1.30.0<\/p>\n

1.\u89e3\u538bbuysbox\u6e90\u7801<\/p>\n

\n

# tar xvf busybox-1.30.0.tar.bz2<\/code><\/pre>\n<\/p>\n

2.\u914d\u7f6ebuysbox\u6e90\u7801<\/p>\n

\u5728\u8fd9\u513f\u6211\u4eec\u628abusybox\u914d\u7f6e\u4e3a\u9759\u6001\u7f16\u8bd1\uff0c\u8fd9\u6837busybox\u5728\u8fd0\u884c\u7684\u65f6\u4faf\u5c31\u4e0d\u987b\u8981\u989d\u5916\u7684\u52a8\u6001\u94fe\u63a5\u5e93\u4e86\u3002<\/p>\n

\n

# make menuconfig\nBusybox Settings  --->\n      Build Options  --->\n            [*] Build BusyBox as a static binary (no shared libs)<\/code><\/pre>\n<\/p>\n

3.\u7f16\u8bd1\u548c\u5b89\u88c5<\/p>\n

\n

#make && make install<\/code><\/pre>\n<\/p>\n

4.\u7f16\u8bd1\u5b8c\u6210\u540e\u7684busybox\u5c31\u5b89\u88c5\u5728\u6e90\u7801\u6839\u76ee\u5f55\u4e0b\u7684_install\u76ee\u5f55\u4e86linux\u7cfb\u7edf\u4e0b\u8f7d\uff0c\u6211\u4eec\u6b65\u5165_install\u76ee\u5f55\uff0c\u8865\u5145\u4e00\u4e9b\u5fc5\u8981\u7684\u6587\u4ef6\u6216\u76ee\u5f55linux\u8bbe\u5907\u9a71\u52a8\u5f00\u53d1\u8be6\u89e3 \u6e90\u7801<\/strong>linux\u8bbe\u5907\u9a71\u52a8\u5f00\u53d1\u8be6\u89e3 \u6e90\u7801<\/strong>\uff0c\u76f8\u5173\u7684shell\u547d\u4ee4<\/a>\u5982\u4e0b\uff1a<\/p>\n

\n

# mkdir etc dev mnt\n# mkdir -p etc\/init.d\/\n# vim etc\/fstab\nproc  \/proc proc  defaults 0 0\ntemps \/tmp  rpoc  defaults 0 0\nnone  \/tmp  ramfs defaults 0 0\nsysfs \/sys  sysfs defaults 0 0\nmdev  \/dev  ramfs defaults 0 0\n# vim etc\/init.d\/rcS\nmkdir -p \/proc\nmkdir -p \/tmp\nmkdir -p \/sys\nmkdir -p \/mnt\n\/bin\/mount -a\nmkdir -p \/dev\/pts\nmount -t devpts devpts \/dev\/pts\necho \/sbin\/mdev > \/proc\/sys\/kernel\/hotplug\nmdev -s\n# chmod 755 etc\/init.d\/rcS\n# vim etc\/inittab\n::sysinit:\/etc\/init.d\/rcS\n::respawn:-\/bin\/sh\n::askfirst:-\/bin\/sh\n::cttlaltdel:\/bin\/umount -a -r\n# chmod 755 etc\/inittab\n# cd dev\n# mknod console c 5 1\n# mknod null c 1 3\n# mknod tty1 c 4 1 <\/code><\/pre>\n<\/p>\n

\u8fd9\u6837\u4e00\u4e2a\u6700\u5c0f\u7684\u3001\u5b8c\u6574\u7684\u53ef\u4ee5\u88ab\u5185\u6838\u542f\u52a8\u7684\u6587\u4ef6\u7cfb\u7edf\u5c31\u9f50\u6d3b\u5566\u3002<\/p>\n

linux\u8bbe\u5907\u9a71\u52a8\u5f00\u53d1\u8be6\u89e3 \u6e90\u7801_linux\u9a71\u52a8\u5f00\u53d1\u5de5\u5177_linux\u9a71\u52a8\u6e90\u7801\u5206\u6790<\/p>\n

\u5236\u505a\u6839\u6587\u4ef6\u7cfb\u7edf\u955c\u50cf\u6587\u4ef6\u3002<\/p>\n

\u601d\u8def\uff1a<\/p>\n

1.\u5148\u5236\u505a\u4e00\u4e2a\u7a7a\u7684\u955c\u50cf\u6587\u4ef6\uff1b<\/p>\n

2.\u4e4b\u540e\u628a\u6b64\u955c\u50cf\u6587\u4ef6\u4f4e\u683c\u4e3aext3\u683c\u5f0f\uff1b<\/p>\n

3.\u4e4b\u540e\u628a\u6b64\u955c\u50cf\u6587\u4ef6\u6302\u8f7d\uff0c\u5e76\u628a\u6839\u6587\u4ef6\u7cfb\u7edf\u590d\u5236\u5230\u6302\u8f7d\u76ee\u5f55\uff1b<\/p>\n

4.\u5378\u8f7d\u8be5\u955c\u50cf\u6587\u4ef6\u3002<\/p>\n

5.\u6253\u6210gzip\u5305\u3002<\/p>\n

\n

#!\/bin\/bash\nrm -rf rootfs.ext3\nrm -rf fs\ndd if=\/dev\/zero of=.\/rootfs.ext3 bs=1M count=32\nmkfs.ext3 rootfs.ext3\nmkdir fs\nmount -o loop rootfs.ext3 .\/fs\ncp -rf .\/_install\/* .\/fs\numount .\/fs\ngzip --best -c rootfs.ext3 > rootfs.img.gz <\/code><\/pre>\n<\/p>\n

\u6700\u7ec8\u751f\u6210\u7684\u6587\u4ef6\u7cfb\u7edf\u955c\u50cf\u540d\u5b50\u4e3a\uff1arootfs.img.gz<\/p>\n

\u6253\u7b97\u597d\u4e86\u5185\u6838\u548c\u6587\u4ef6\u7cfb\u7edf\u955c\u50cflinux\u57f9\u8bad\u73ed\uff0c\u5e78\u798f\u7684\u4e00\u523b\u9a6c\u4e0a\u5c06\u81f3\u4e86\uff1a<\/p>\n

\u901a\u8fc7qemu\u6a21\u62df\u5668\u542f\u52a8\u6211\u4eec\u81ea\u5df1\u7f16\u8bd1\u7684\u5185\u6838\u548c\u6587\u4ef6\u7cfb\u7edf\uff1a<\/p>\n

\n

# qemu-system-x86_64 \n  -kernel .\/linux-4.9.229\/arch\/x86_64\/boot\/bzImage  \n  -initrd .\/busybox-1.30.0\/rootfs.img.gz   \n  -append \"root=\/dev\/ram init=\/linuxrc\"  \n  -serial file:output.txt<\/code><\/pre>\n<\/p>\n

\u8fd9\u6837\u4e00\u4e2a\u5b8c\u6574\u7684\u6700\u5c0flinux\u7cfb\u7edf\u5c31\u4e0a\u53bb\u5566\uff1a<\/p>\n

linux\u9a71\u52a8\u6e90\u7801\u5206\u6790_linux\u9a71\u52a8\u5f00\u53d1\u5de5\u5177_linux\u8bbe\u5907\u9a71\u52a8\u5f00\u53d1\u8be6\u89e3 \u6e90\u7801<\/p>\n

\u597d\u4e86\uff0c\u7ecf\u8fc7\u4ee5\u4e0a\u7684\u6b65\u9aa4\uff0c\u4f60\u53ef\u4ee5\u81ea\u5df1\u7f16\u8bd1\u4e00\u4e2a\u5185\u6838\u548c\u6587\u4ef6\u7cfb\u7edf\u3002\u6709\u4e86\u8fd9\u6837\u7684\u57fa\u7840\uff0c\u4f60\u5728\u4ee5\u540e\u5c31\u53ef\u4ee5\u81ea\u7531\u7684\u66f4\u6539linux\u5185\u6838\u4ee3\u7801\u5e76run\u4e0a\u53bb\u8fdb\u884c\u9a8c\u8bc1\u5566\u3002<\/p>\n

\u8bb0\u5f97\u5173\u6ce8\u201c\u6280\u672f\u7b80\u8bf4\u201d\uff0c\u6301\u7eed\u5206\u4eablinux\u5185\u6838\u77e5\u8bc6\uff0c\u8ba9\u4f60\u4e00\u6b65\u4e00\u6b65\u6210\u4e3alinux\u5185\u6838\u5927\u4fa0\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"

\u8981\u5b66\u4e60linux\u5185\u6838\uff0c\u5148\u8981\u80fd\u591f\u7f16\u8bd1\u5185\u6838\uff0c\u8fd8\u9700\u8981\u4e86\u89e3\u5185\u6838\u5982\u4f55\u542f\u52a8\u6839\u6587\u4ef6\u7cfb\u7edf\u3002\u4e0b\u8f7dlinux\u5e76\u7f16\u8bd1linux\u5185\u6838\u6e90\u7801qemu\u542f\u52a8\u4f60\u7f16\u8bd1\u597d\u7684\u5185\u6838\u548c\u6839\u6587\u4ef6\u7cfb\u7edf\u5728\u8fd9\u91cc\u6211\u4eec\u628abusybox\u914d\u7f6e\u4e3a\u9759\u6001\u7f16\u8bd1\uff0c\u8fd9\u6837busybox\u5728\u8fd0\u884c\u7684\u65f6\u5019\u5c31\u4e0d\u9700\u8981\u989d\u5916\u7684\u52a8\u6001\u94fe\u63a5\u5e93\u4e86\u3002\u901a\u8fc7qemu\u6a21\u62df\u5668\u542f\u52a8\u6211\u4eec\u81ea\u5df1\u7f16\u8bd1\u7684\u5185\u6838\u548c\u6587\u4ef6\u7cfb\u7edf\uff1a\u597d\u4e86\uff0c\u7ecf\u8fc7\u4ee5\u4e0a\u7684\u6b65\u9aa4\uff0c\u4f60\u53ef\u4ee5\u81ea\u5df1\u7f16\u8bd1\u4e00\u4e2a\u5185\u6838\u548c\u6587\u4ef6\u7cfb\u7edf\u3002<\/p>\n","protected":false},"author":1,"featured_media":284680,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[988],"tags":[999],"class_list":["post-284679","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tougao","tag-999"],"acf":[],"_links":{"self":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts\/284679","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/comments?post=284679"}],"version-history":[{"count":0,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts\/284679\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/media\/284680"}],"wp:attachment":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/media?parent=284679"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/categories?post=284679"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/tags?post=284679"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}