{"id":1157,"date":"2024-03-13T14:53:12","date_gmt":"2024-03-13T06:53:12","guid":{"rendered":"https:\/\/imuslab.com\/wordpress\/?p=1157"},"modified":"2024-03-13T14:53:12","modified_gmt":"2024-03-13T06:53:12","slug":"%e5%9c%a8-linux-%e4%b8%8a%e5%bb%ba%e7%ab%8b%e4%b8%80%e5%80%8b%e6%9c%89%e5%ae%b9%e9%87%8f%e9%99%90%e5%88%b6%e7%9a%84%e8%b3%87%e6%96%99%e5%a4%be","status":"publish","type":"post","link":"https:\/\/imuslab.com\/wordpress\/2024\/03\/13\/%e5%9c%a8-linux-%e4%b8%8a%e5%bb%ba%e7%ab%8b%e4%b8%80%e5%80%8b%e6%9c%89%e5%ae%b9%e9%87%8f%e9%99%90%e5%88%b6%e7%9a%84%e8%b3%87%e6%96%99%e5%a4%be\/","title":{"rendered":"\u5728 Linux \u4e0a\u5efa\u7acb\u4e00\u500b\u6709\u5bb9\u91cf\u9650\u5236\u7684\u8cc7\u6599\u593e"},"content":{"rendered":"\n<p>\u6700\u8fd1\u6211\u5728\u7814\u7a76 mdadm \u7684\u6642\u5019\u7121\u610f\u4e2d\u767c\u73fe\u4e86\u4e00\u500b\u53ef\u4ee5\u4f9d\u9760 losetup \u548c partition \u6620\u50cf\u6a94\u7684\u795e\u5947\u65b9\u6cd5\u4f86\u5efa\u7acb\u4e00\u500b\u5177\u6709\u5bb9\u91cf\u9650\u5236\u7684\u8cc7\u6599\u593e\u3002\u6240\u4ee5\u5c31\u5beb\u9019\u7bc7\u4f86\u7c21\u55ae\u8a18\u9304\u4e00\u4e0b\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u597d\uff0c\u53ef\u662f\u9019\u6709\u751a\u9ebc\u7528\uff1f<\/h3>\n\n\n\n<p>\u4e4b\u524d\u6211\u5728\u958b\u767c ArozOS \u7684\u6642\u5019\u60f3\u8457\u7d66\u4f7f\u7528\u8005\u5efa\u7acb\u4e00\u500b storage quota\u3002\u672c\u4f86\u60f3\u8457\u7528 linux \u7684 File System \u4f86 implement \u9019\u500b\u529f\u80fd\uff0c\u53ef\u662f\u627e\u4e86\u5f88\u4e45\u4e4b\u5f8c\u767c\u73fe\u65b9\u6cd5\u90fd\u5f88\u9ebb\u7169\u6216\u662f\u904e\u65bc\u8907\u96dc\uff08\u4f8b\u5982\u4f9d\u8cf4\u4e00\u4e9b\u7279\u5225\u7684 file system format \/ container\uff09\u3002\u6240\u4ee5\u5982\u679c\u525b\u597d\u4f60\u60f3\u8a2d\u7f6e\u4e00\u500b hard limit \u7d66\u4e00\u4e9b\u8edf\u9ad4\u4f86\u505a buffer \/ upload \u4e4b\u985e\u7684\uff0c\u90fd\u53ef\u4ee5\u8003\u616e\u9019\u500b\u65b9\u6cd5\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u9996\u5148\uff0c\u5efa\u7acb\u4e00\u500b\u6620\u50cf\u6a94<\/h2>\n\n\n\n<p>\u6211\u5011\u7b2c\u4e00\u4ef6\u4e8b\u60c5\u8981\u505a\u7684\u5c31\u662f\u5efa\u7acb\u4e00\u500b\u56fa\u5b9a\u5927\u5c0f\u7684\u6620\u50cf\u6a94\u3002\u4ee5\u6211\u9019\u88e1\u70ba\u4f8b\uff0c\u6211\u5efa\u7acb\u4e86\u4e00\u500b 64MB \u7684\u6620\u50cf\u6a94\u4f86\u6a21\u64ec\u4e00\u500b\u786c\u789f partition\u3002 bs \u662f block size\uff0c\u5c31\u662f\u7cfb\u7d71\u6703 buffer \u591a\u5c11 data \u624d\u6703\u771f\u6b63\u5beb\u9032\u53bb\u9019\u500b\uff08block \uff09device\uff0c\u9019\u88e1\u7528\u7684\u662f 4MB\u3002 count \u662f\u9019\u500b\u865b\u64ec\u786c\u789f\u88e1\u6709\u591a\u5c11\u500b block\uff0c16 \u500b 4MB \u7684 block \u52a0\u8d77\u4f86\u5c31\u662f 64MB \u5566 <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo dd if\/dev\/zero of=sdX.img bs=4M count=16<\/code><\/pre>\n\n\n\n<p>\u81f3\u65bc \/dev\/zero \u662f\u751a\u9ebc\uff0c\u5b83\u662f\u4e00\u500b\u53ea\u6703\u4e0d\u65b7\u5410\u51fa 0 \u7684 byte stream\u3002\u4f60\u53ef\u4ee5\u628a\u5b83\u7576\u6210\u4e00\u500b\u7121\u9650\u5927\u7684\u6a94\u6848\uff0c\u88e1\u9762\u53ea\u5b58\u5728\u7121\u9650\u500b 0\u3002\u900f\u904e dd \u6307\u4ee4\uff0c\u6211\u5011\u5c31\u53ef\u4ee5\u628a\u9700\u8981\u7684 0 bit \u5f9e\u9019\u500b\u6a94\u6848\u88e1 clone \u51fa\u4f86\u4f86\u5efa\u7acb\u6211\u5011\u9700\u8981\u7684\u6620\u50cf\u6a94\u5927\u5c0f\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u4e4b\u5f8c\uff1a\u5efa\u7acb\u6a94\u6848\u7cfb\u7d71<\/h2>\n\n\n\n<p>\u5728\u5efa\u7acb\u4e86\u4e00\u500b\u7a7a\u767d\u7684\u6620\u50cf\u6a94\u4e4b\u5f8c\uff0c\u900f\u904e ls \u6307\u4ee4\u6211\u5011\u53ef\u4ee5\u770b\u5230\u65b0\u9bae\u7684 .img \u6a94\u51fa\u73fe\u4e86\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>aroz@orangepizero2:~\/raidtest$ ls\nsdX.img<\/code><\/pre>\n\n\n\n<p>\u7136\u5f8c\u6211\u5011\u5c31\u662f\u9700\u8981\u5c0d\u5b83\u9032\u884c\u683c\u5f0f\u5316\uff0c\u5c31\u53e4\u4eba\u6240\u8aaa<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p> Everything is a file <\/p><cite>Linus Torvalds did not say this<\/cite><\/blockquote>\n\n\n\n<p>\u6240\u4ee5\u6211\u5011\u53ef\u4ee5\u76f4\u63a5\u5c0d\u5b83\u7528 mkfs \u8ddf mount \u6307\u4ee4\u3002\u5047\u8a2d\u6211\u5011\u6709\u4e00\u500b\u53eb sdX\/ \u7684\u8cc7\u6599\u593e\uff0c\u90a3\u6211\u5011\u5c31\u53ef\u4ee5\u628a\u6620\u50cf\u6a94\u683c\u5f0f\u5316\u4e4b\u5f8c\u639b\u5230\u90a3\u500b\u8cc7\u6599\u593e\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ \u5efa\u7acb\u639b\u8f09\u9ede\naroz@orangepizero2:~\/raidtest$ mkdir sdX\n\n\/\/\u7528 ext4 \u628a\u6620\u50cf\u6a94\u683c\u5f0f\u5316\naroz@orangepizero2:~\/raidtest$ sudo mkfs.ext4 sdX.img\nmke2fs 1.47.0 (5-Feb-2023)\nDiscarding device blocks: done\nCreating filesystem with 65536 1k blocks and 16384 inodes\nFilesystem UUID: bf600d34-c93a-48bc-ad27-27255fbd1333\nSuperblock backups stored on blocks:\n        8193, 24577, 40961, 57345\n\nAllocating group tables: done\nWriting inode tables: done\nCreating journal (4096 blocks): done\nWriting superblocks and filesystem accounting information: done\n\n\/\/\u6aa2\u67e5\u770b\u770b\u662f\u4e0d\u662f\u9700\u8981\u7684\u8cc7\u6599\u593e\u548c\u6a94\u6848\u90fd\u5b58\u5728\naroz@orangepizero2:~\/raidtest$ ls\nsdX  sdX.img\n\n\/\/\u628a\u6620\u50cf\u6a94\u639b\u4e0a\u53bb\naroz@orangepizero2:~\/raidtest$ sudo mount sdX.img .\/sdX\n<\/code><\/pre>\n\n\n\n<p>\u4e4b\u5f8c\u6211\u5011\u5c31\u53ef\u4ee5\u5728 df \u88e1\u770b\u5230\u639b\u8f09\u7684\u865b\u64ec\u786c\u789f \/ \u6620\u50cf\u6a94\u4e86<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>aroz@orangepizero2:~\/raidtest$ df -h\nFilesystem      Size  Used Avail Use% Mounted on\nudev            386M     0  386M   0% \/dev\ntmpfs            92M  2.4M   90M   3% \/run\n\/dev\/mmcblk0p1   29G  3.8G   25G  14% \/\ntmpfs           460M     0  460M   0% \/dev\/shm\ntmpfs           5.0M     0  5.0M   0% \/run\/lock\ntmpfs           460M     0  460M   0% \/tmp\n\/dev\/zram1       47M   18M   26M  41% \/var\/log\ntmpfs            92M     0   92M   0% \/run\/user\/1000\n\/dev\/loop0       55M   14K   51M   1% \/home\/aroz\/raidtest\/sdX &lt;- \u9019\u88e1<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u90a3 \/dev\/loop0 \u662f\u751a\u9ebc\uff01\uff1f<\/h2>\n\n\n\n<p>\u9019\u500b\u662f loopback device\uff0c\u5982\u679c\u4f60\u6c92\u8010\u5fc3\u7684\u8a71\u95dc\u9375\u5b57\u662f losetup \uff08<\/p>\n\n\n\n<p>\u561b\uff0c\u7c21\u55ae\u4f86\u8aaa\u4e00\u500b\u865b\u64ec\u7684 block device\u3002\u5b83\u662f\u4e00\u500b kernel driver \u4f86\u63d0\u4f9b loopback \u7684 block device emulation\uff0c\u7528\u9014\u4f8b\u5982\u8aaa\u628a .img \u6a94\u6848\u639b\u6210\u4e00\u500b storage device\u3002<\/p>\n\n\n\n<p>\u5982\u679c\u4f60\u60f3\u67e5\u770b\u73fe\u6709\u7684 loopback device \u7684\u8a71\u53ef\u4ee5\u7528 losetup -a \u6307\u4ee4<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>aroz@orangepizero2:~\/raidtest$ sudo losetup -a\n\/dev\/loop0: &#91;45825]:268807 (\/home\/aroz\/raidtest\/sdX.img)<\/code><\/pre>\n\n\n\n<p>\u8981\u79fb\u9664\u7684\u8a71\uff08\u5982\u679c\u4f60\u662f\u7528 umount \u6307\u4ee4\u7684\u8a71\u5b83\u61c9\u8a72\u662f\u6703\u81ea\u52d5\u79fb\u9664\u7684\uff0c\u4f46\u662f\u5728\u4e00\u4e9b\u5947\u602a\u60c5\u6cc1\u4e0b\u4f60\u53ef\u80fd\u6703\u9700\u8981\u624b\u52d5\u63a7\u5236\uff09\uff0c\u4f60\u53ef\u4ee5\u7528\u5b83\u7684 -d \u6307\u4ee4\u3002<\/p>\n\n\n\n<p>\u5927\u6982\u5c31\u662f\u9019\u6a23\u4e86\uff0c\u4e4b\u5f8c\u4f60\u5c31\u53ef\u4ee5\u8b93\u6c92\u8fa6\u6cd5\u63a7\u5236 quota \u7684\u8edf\u9ad4\u7528\u90a3\u500b\u8cc7\u6599\u593e\u4f86\u7576 data folder\u3002\u9019\u6a23\u4e00\u4f46\u6eff\u4e86\u7684\u8a71\u5b83\u5c31\u6703\u5f48 storage full \u7684\u8b66\u544a\uff0c\u540c\u6642\u9593\u4e5f\u4e0d\u6703\u628a\u4f3a\u670d\u5668\u7684\u5be6\u9ad4\u786c\u789f\u585e\u6eff\uff0c\u9177\u5427\uff1f<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6700\u8fd1\u6211\u5728\u7814\u7a76 mdadm \u7684\u6642\u5019\u7121\u610f\u4e2d\u767c\u73fe\u4e86\u4e00\u500b\u53ef\u4ee5\u4f9d\u9760 losetup \u548c partition \u6620\u50cf\u6a94\u7684\u795e\u5947\u65b9\u6cd5\u4f86\u5efa\u7acb\u4e00\u500b\u5177\u6709\u5bb9\u91cf\u9650\u5236\u7684\u8cc7\u6599\u593e\u3002\u6240\u4ee5\u5c31\u5beb\u9019\u7bc7\u4f86\u7c21\u55ae\u8a18\u9304\u4e00\u4e0b\u3002 \u597d\uff0c\u53ef\u662f\u9019\u6709\u751a\u9ebc\u7528\uff1f \u4e4b\u524d\u6211\u5728\u958b\u767c ArozOS \u7684\u6642\u5019\u60f3\u8457\u7d66\u4f7f\u7528\u8005\u5efa\u7acb\u4e00\u500b storage quota\u3002\u672c\u4f86\u60f3\u8457\u7528 linux \u7684 File System \u4f86 implement \u9019\u500b\u529f\u80fd\uff0c\u53ef\u662f\u627e\u4e86\u5f88\u4e45\u4e4b\u5f8c\u767c\u73fe\u65b9\u6cd5\u90fd\u5f88\u9ebb\u7169\u6216\u662f\u904e\u65bc\u8907\u96dc\uff08\u4f8b\u5982\u4f9d\u8cf4\u4e00\u4e9b\u7279\u5225\u7684 file system format \/ container\uff09\u3002\u6240\u4ee5\u5982\u679c\u525b\u597d\u4f60\u60f3\u8a2d\u7f6e\u4e00\u500b hard limit \u7d66\u4e00\u4e9b\u8edf\u9ad4\u4f86\u505a buffer \/ upload \u4e4b\u985e\u7684\uff0c\u90fd\u53ef\u4ee5\u8003\u616e\u9019\u500b\u65b9\u6cd5\u3002 \u9996\u5148\uff0c\u5efa\u7acb\u4e00\u500b\u6620\u50cf\u6a94 \u6211\u5011\u7b2c\u4e00\u4ef6\u4e8b\u60c5\u8981\u505a\u7684\u5c31\u662f\u5efa\u7acb\u4e00\u500b\u56fa\u5b9a\u5927\u5c0f\u7684\u6620\u50cf\u6a94\u3002\u4ee5\u6211\u9019\u88e1\u70ba\u4f8b\uff0c\u6211\u5efa\u7acb\u4e86\u4e00\u500b 64MB \u7684\u6620\u50cf\u6a94\u4f86\u6a21\u64ec\u4e00\u500b\u786c\u789f partition\u3002 bs \u662f block size\uff0c\u5c31\u662f\u7cfb\u7d71\u6703 buffer \u591a\u5c11 data \u624d\u6703\u771f\u6b63\u5beb\u9032\u53bb\u9019\u500b\uff08block \uff09device\uff0c\u9019\u88e1\u7528\u7684\u662f 4MB\u3002 count \u662f\u9019\u500b\u865b\u64ec\u786c\u789f\u88e1\u6709\u591a\u5c11\u500b block\uff0c16 \u500b 4MB \u7684 block \u52a0\u8d77\u4f86\u5c31\u662f [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[104,3],"tags":[],"class_list":["post-1157","post","type-post","status-publish","format-standard","hentry","category-bug-tips","category-instructions-and-information"],"_links":{"self":[{"href":"https:\/\/imuslab.com\/wordpress\/wp-json\/wp\/v2\/posts\/1157","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/imuslab.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/imuslab.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/imuslab.com\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/imuslab.com\/wordpress\/wp-json\/wp\/v2\/comments?post=1157"}],"version-history":[{"count":2,"href":"https:\/\/imuslab.com\/wordpress\/wp-json\/wp\/v2\/posts\/1157\/revisions"}],"predecessor-version":[{"id":1159,"href":"https:\/\/imuslab.com\/wordpress\/wp-json\/wp\/v2\/posts\/1157\/revisions\/1159"}],"wp:attachment":[{"href":"https:\/\/imuslab.com\/wordpress\/wp-json\/wp\/v2\/media?parent=1157"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/imuslab.com\/wordpress\/wp-json\/wp\/v2\/categories?post=1157"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/imuslab.com\/wordpress\/wp-json\/wp\/v2\/tags?post=1157"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}