{"id":5,"date":"2022-03-23T09:42:50","date_gmt":"2022-03-23T02:42:50","guid":{"rendered":"http:\/\/wp-demo.upfile.vn\/?p=5"},"modified":"2023-05-30T09:18:33","modified_gmt":"2023-05-30T02:18:33","slug":"inode-trong-linux","status":"publish","type":"post","link":"https:\/\/longvan.net\/cong-dong\/inode-trong-linux\/","title":{"rendered":"Inode trong linux"},"content":{"rendered":"\n<h5 class=\"wp-block-heading\" id=\"bkmrk-i.-inode-l%C3%A0-g%C3%AC.\"><strong>I. Inode l\u00e0 g\u00ec.<\/strong><\/h5>\n\n\n\n<p id=\"bkmrk-inode-l%C3%A0-m%E1%BB%99t-c%E1%BA%A5u-tr%C3%BA\">Inode l\u00e0 m\u1ed9t c\u1ea5u tr\u00fac d\u1eef li\u1ec7u trong h\u1ec7 th\u1ed1ng Unix. Inode \u0111\u01b0\u1ee3c c\u1ea5p ph\u00e1t cho m\u1ecdi t\u1eadp tin v\u00e0 th\u01b0 m\u1ee5c trong h\u1ec7 th\u1ed1ng. Inode kh\u00f4ng l\u01b0u d\u1eef li\u1ec7u th\u1ef1c t\u1ebf. Thay v\u00e0o \u0111\u00f3, n\u00f3 s\u1ebd ch\u1ec9 l\u01b0u si\u00eau d\u1eef li\u1ec7u (metadata) c\u1ee7a t\u1eadp tin v\u00e0 th\u01b0 m\u1ee5c.<\/p>\n\n\n\n<p id=\"bkmrk-m%E1%BB%97i-inode-trong-linu\">M\u1ed7i Inode trong Linux l\u00e0 m\u1ed9t s\u1ed1 x\u00e1c \u0111\u1ecbnh duy nh\u1ea5t. N\u00f3 c\u00f2n \u0111\u01b0\u1ee3c g\u1ecdi l\u00e0 s\u1ed1 ch\u1ec9 m\u1ee5c v\u00e0 bao g\u1ed3m c\u00e1c thu\u1ed9c t\u00ednh sau:<\/p>\n\n\n\n<ul id=\"bkmrk-k%C3%ADch-th%C6%B0%E1%BB%9Bc-quy%E1%BB%81n-s%E1%BB%9F-\" class=\"has-small-font-size wp-block-list\"><li>K\u00edch th\u01b0\u1edbc<\/li><li>Quy\u1ec1n s\u1edf h\u1eefu (owner)<\/li><li>Date\/time<\/li><li>Quy\u1ec1n v\u00e0 ki\u1ec3m so\u00e1t truy c\u00e2p (access control).<\/li><li>V\u1ecb tr\u00ed tr\u00ean Disk<\/li><li>Lo\u1ea1i file<\/li><li>S\u1ed1 l\u01b0\u1ee3ng li\u00ean k\u1ebft.<\/li><li>Metadata c\u1ee7a file<\/li><\/ul>\n\n\n\n<p class=\"has-small-font-size\" id=\"bkmrk-s%E1%BB%91-l%C6%B0%E1%BB%A3ng-inode-gi%E1%BB%9Bi-\">S\u1ed1 l\u01b0\u1ee3ng Inode gi\u1edbi h\u1ea1n t\u1ed5ng s\u1ed1 file v\u00e0 th\u01b0 m\u1ee5c c\u00f3 th\u1ec3 \u0111\u01b0\u1ee3c l\u01b0u tr\u1eef trong h\u1ec7 th\u1ed1ng (linux).<\/p>\n\n\n\n<h5 class=\"wp-block-heading\" id=\"bkmrk-ii.-ki%E1%BB%83m-tra-inode%3A\"><strong>II. Ki\u1ec3m tra Inode:<\/strong><\/h5>\n\n\n\n<ol class=\"has-small-font-size wp-block-list\"><li>Ki\u1ec3m tra s\u1ed1 inode c\u1ee7a m\u1ed9t file ho\u1eb7c folder: c\u00f3 th\u1ec3 s\u1eed d\u1ee5ng m\u1ed9t trong hai l\u1ec7nh sau \u0111\u00e2y<br><code><em># stat [file-name]<\/em><\/code><br><code><em># ls -i [file-name]<\/em><\/code><em><br><\/em><br><\/li><li>Ki\u1ec3m tra s\u1ed1 inode tr\u00ean h\u1ec7 th\u1ed1ng:<br>S\u1eed d\u1ee5ng l\u1ec7nh\u00a0<strong><em>df -i<\/em><\/strong>\u00a0\u0111\u1ec3 xem s\u1ed1 inode tr\u00ean h\u1ec7 th\u1ed1ng.<br>Trong h\u00ecnh d\u01b0\u1edbi, t\u1ed5ng s\u1ed1 inode tr\u00ean\u00a0<strong>\/dev\/mapper\/centos-root<\/strong>\u00a0l\u00e0 3654400, s\u00f4 inode \u0111\u00e3 s\u1eed d\u1ee5ng l\u00e0 62285, s\u1ed1 inode c\u00f2n l\u1ea1i l\u00e0 23592115.<br><img loading=\"lazy\" decoding=\"async\" width=\"600\" height=\"117\" class=\"wp-image-8\" style=\"width: 600px;\" src=\"http:\/\/wp-demo.upfile.vn\/wp-content\/uploads\/2022\/03\/image-1635319963654.png\" alt=\"\" srcset=\"https:\/\/longvan.net\/cong-dong\/wp-content\/uploads\/2022\/03\/image-1635319963654.png 720w, https:\/\/longvan.net\/cong-dong\/wp-content\/uploads\/2022\/03\/image-1635319963654-300x58.png 300w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><br>\u00a0<a rel=\"noreferrer noopener\" href=\"https:\/\/docs.longvan.net\/uploads\/images\/gallery\/2021-10\/image-1635319963654.png\" target=\"_blank\"><\/a><br>Ngo\u00e0i ra c\u00f3 th\u1ec3 th\u00eam t\u00f9y ch\u1ecdn h trong l\u1ec7nh tr\u00ean \u0111\u1ec3 hi\u1ec3n th\u1ecb k\u1ebft qu\u1ea3 t\u1ed5ng qu\u00e1t d\u1ec3 nh\u00ecn h\u01a1n:\u00a0<strong><em>df -ih<\/em><\/strong><\/li><\/ol>\n\n\n\n<h5 class=\"wp-block-heading\" id=\"bkmrk-ii.-t%C3%ACnh-tr%E1%BA%A1ng-full-\"><strong>II. T\u00ecnh tr\u1ea1ng full inode:<\/strong><\/h5>\n\n\n\n<ul id=\"bkmrk-trong-h%E1%BA%A7u-h%E1%BA%BFt-c%C3%A1c-tr\" class=\"has-small-font-size wp-block-list\"><li>Trong h\u1ea7u h\u1ebft c\u00e1c tr\u01b0\u1eddng h\u1ee3p, s\u1ed1 inode m\u1eb7c \u0111\u1ecbnh l\u00e0 d\u01b0 th\u1eeba cho nhu c\u1ea7u s\u1eed d\u1ee5ng th\u00f4ng th\u01b0\u1eddng.<\/li><li>Khi s\u1ed1 inode s\u1eed d\u1ee5ng h\u1ebft (100%), h\u1ec7 th\u1ed1ng linux s\u1ebd kh\u00f4ng th\u1ec3 t\u1ea1o th\u00eam file ho\u1eb7c th\u01b0 m\u1ee5c.<\/li><li>\u0110\u1ec3 ki\u1ec3m tra nh\u1eefng th\u01b0 m\u1ee5c \u0111ang s\u1eed d\u1ee5ng nhi\u1ec1u inode, c\u00f3 th\u1ec3 th\u1ef1c hi\u1ec7n l\u1ec7nh sau:<br><code><em># find \/ -xdev -printf '%h\\n' | sort | uniq -c | sort -k 1 -n<\/em><\/code><\/li><\/ul>\n\n\n\n<h5 class=\"wp-block-heading\" id=\"bkmrk-iv.-t%C4%83ng-s%E1%BB%91-l%C6%B0%E1%BB%A3ng-in\"><strong>IV. T\u0103ng s\u1ed1 l\u01b0\u1ee3ng inode tr\u00ean server Linux:<\/strong><\/h5>\n\n\n\n<ol class=\"has-small-font-size wp-block-list\"><li>C\u00e1c th\u00f4ng s\u1ed1 c\u1ea7n l\u01b0u \u00fd:<ul><li>K\u00edch th\u01b0\u1edbc c\u1ee7a m\u1ed9t inode (<strong>inode size<\/strong>) m\u1eb7c \u0111\u1ecbnh l\u00e0 256B, s\u1ed1 l\u01b0\u1ee3ng Inode t\u0103ng th\u00ec kh\u00f4ng gian \u0111\u1ec3 l\u01b0u tr\u1eef inode c\u0169ng t\u0103ng theo, kh\u00f4ng gian n\u00e0y s\u1ebd kh\u00f4ng hi\u1ec3n th\u1ecb trong systemfile. N\u00ean c\u00e1c l\u1ec7nh show th\u00f4ng tin systemfile nh\u01b0&nbsp;<em><strong>df -h<\/strong><\/em>&nbsp;s\u1ebd hi\u1ec3n th\u1ecb kh\u00f4ng \u0111\u1ea7y \u0111\u1ee7 kh\u00f4ng gian c\u1ee7a partition.<\/li><li>Th\u00f4ng s\u1ed1&nbsp;<strong>byte-per-inode<\/strong>&nbsp;(t\u1ef7 l\u1ec7 inode tr\u00ean dung l\u01b0\u1ee3ng t\u00ednh b\u1eb1ng byte) s\u1ebd \u1ea3nh h\u01b0\u1edfng \u0111\u1ebfn s\u1ed1 l\u01b0\u1ee3ng inode tr\u00ean m\u1ed9t partition. Th\u00f4ng s\u1ed1 n\u00e0y \u0111\u01b0\u1ee3c thi\u1ebft l\u1eadp khi t\u1ea1o systemfile cho partition v\u00e0 s\u1ebd kh\u00f4ng thay \u0111\u1ed5i \u0111\u01b0\u1ee3c. M\u1eb7c \u0111\u1ecbnh v\u1edbi ext4 l\u00e0 16 kB.<br><\/li><\/ul><\/li><li>T\u0103ng s\u1ed1 inode: c\u00f3 th\u1ec3 th\u1ef1c hi\u1ec7n m\u1ed9t trong 2 c\u00e1ch sau:<ul><li>Format l\u1ea1i partition k\u00e8m theo thi\u1ebft l\u1eadp th\u00f4ng s\u1ed1 byte-per-inode.<br><code>mkfs.ext4 -i [bype-per-inode] \/dev\/[parition]<\/code><br>V\u00ed d\u1ee5:&nbsp;&nbsp;&nbsp;&nbsp;<br><code>mkfs.ext4 -i 1024 \/dev\/sdb<\/code><br>V\u1edbi byte-per-inode l\u00e0 1024 B = 1 kB<br><strong>L\u01b0u \u00fd:<\/strong><ul><li>C\u00e1ch n\u00e0y s\u1ebd format l\u1ea1i partition, \u0111\u1ed3ng ngh\u0129a v\u1edbi vi\u1ec7c to\u00e0n b\u1ed9 d\u1eef li\u1ec7u tr\u00ean parition s\u1ebd b\u1ecb m\u1ea5t.<\/li><li>Long V\u00e2n khuy\u1ebfn c\u00e1o kh\u00e1ch h\u00e0ng c\u00f3 nhu c\u1ea7u n\u00ean th\u1ef1c hi\u1ec7n t\u1eeb partition\/disk th\u1ee9 2 tr\u1edf \u0111i (partition\/disk \u0111\u1ea7u ch\u1ee9a h\u1ec7 \u0111i\u1ec1u h\u00e0nh).<\/li><\/ul><\/li><li>T\u0103ng dung l\u01b0\u1ee3ng partition.<\/li><\/ul><\/li><\/ol>\n","protected":false},"excerpt":{"rendered":"<p>I. Inode l\u00e0 g\u00ec. Inode l\u00e0 m\u1ed9t c\u1ea5u tr\u00fac d\u1eef li\u1ec7u trong h\u1ec7 th\u1ed1ng Unix. Inode \u0111\u01b0\u1ee3c c\u1ea5p ph\u00e1t cho m\u1ecdi t\u1eadp tin v\u00e0 th\u01b0 m\u1ee5c trong h\u1ec7 th\u1ed1ng. Inode kh\u00f4ng l\u01b0u d\u1eef li\u1ec7u th\u1ef1c t\u1ebf. Thay v\u00e0o \u0111\u00f3, n\u00f3 s\u1ebd ch\u1ec9 l\u01b0u si\u00eau d\u1eef li\u1ec7u (metadata) c\u1ee7a t\u1eadp tin v\u00e0 th\u01b0 m\u1ee5c. M\u1ed7i Inode [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_oasis_is_in_workflow":0,"_oasis_original":0,"footnotes":""},"categories":[3,4],"tags":[8,6,5,7],"class_list":["post-5","post","type-post","status-publish","format-standard","hentry","category-he-dieu-hanh","category-linux","tag-full-inode","tag-inode","tag-linux","tag-linux-partition"],"_links":{"self":[{"href":"https:\/\/longvan.net\/cong-dong\/wp-json\/wp\/v2\/posts\/5","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/longvan.net\/cong-dong\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/longvan.net\/cong-dong\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/longvan.net\/cong-dong\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/longvan.net\/cong-dong\/wp-json\/wp\/v2\/comments?post=5"}],"version-history":[{"count":9,"href":"https:\/\/longvan.net\/cong-dong\/wp-json\/wp\/v2\/posts\/5\/revisions"}],"predecessor-version":[{"id":2327,"href":"https:\/\/longvan.net\/cong-dong\/wp-json\/wp\/v2\/posts\/5\/revisions\/2327"}],"wp:attachment":[{"href":"https:\/\/longvan.net\/cong-dong\/wp-json\/wp\/v2\/media?parent=5"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/longvan.net\/cong-dong\/wp-json\/wp\/v2\/categories?post=5"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/longvan.net\/cong-dong\/wp-json\/wp\/v2\/tags?post=5"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}