{"id":101036,"date":"2024-07-24T14:35:03","date_gmt":"2024-07-24T06:35:03","guid":{"rendered":"https:\/\/gulass.cn\/?p=101036"},"modified":"2024-07-24T14:35:03","modified_gmt":"2024-07-24T06:35:03","slug":"linux-fdisk","status":"publish","type":"post","link":"https:\/\/gulass.cn\/linux-fdisk.html","title":{"rendered":"linux \u7cfb\u7edf\u5206\u533a \u683c\u5f0f\u5316\u53ca\u6302\u8f7d\u78c1\u76d8"},"content":{"rendered":"

\u670d\u52a1\u5668\u5b89\u88c5centos\u7684\u65f6\u5019\uff0c\u901a\u5e38linux\u7cfb\u7edf\u5206\u533a\u9ed8\u8ba4\u4e3a3\u4e2a\u5206\u533a\uff0c\u4e3b\u5206\u533a\u6700\u591a4\u4e2a\uff0c\u5176\u4ed6\u53ef\u6839\u636e\u81ea\u5df1\u7684\u9700\u8981\u6302\u8f7d\u3002<\/p>\n

\"\"<\/p>\n

\/ \u6839\u5206\u533a\uff0c\u901a\u5e3810-100G\u5de6\u53f3\uff08\u6839\u636e\u603b\u78c1\u76d8\u5927\u5c0f\u60c5\u51b5\uff09<\/p>\n

\/boot \u7cfb\u7edf\u64cd\u4f5c\u5206\u533a \uff08100-500MB \u8db3\u77e3\uff09<\/p>\n

\/swap \u865a\u62df\u5185\u5b58\u6682\u5b58\u5206\u533a\uff08\u901a\u5e38\u662f\u5185\u5b58\u76842\u500d\uff09<\/p>\n

\u5982\u679c\u6709\u5269\u4e0b\u7684\u78c1\u76d8\u5c31\u4fdd\u7559\uff0c\u540e\u671f\u518d\u6302\u8f7d\u3002\u5b89\u88c5\u5b8c\u7cfb\u7edf\u540e\u5c31\u5f00\u59cb\u683c\u5f0f\u5316\u5269\u4e0b\u7684\u5206\u533a\uff0c\u5e76\u6302\u8f7d\u6307\u6d3e\u51fa\u6765\u3002<\/p>\n

1\u3001\u9996\u5148\u67e5\u770b\u672a\u6307\u6d3e\u7684\u5206\u533a\u540d\u79f0\uff0c\u6709\u7684\u4e0d\u4e00\u6837\uff0c\u6211\u7684\u5206\u522b\u662f\/dev\/sda\u548c\/dev\/sdb\uff0csda\u662f\u7cfb\u7edf\u5206\u533a\uff0csdb\u662f\u5b58\u50a8\u6570\u636e\u5206\u533a\u3002<\/p>\n

\r\n# fdisk -l\r\nDisk \/dev\/sda: 10.7 GB, 10737418240 bytes, 20971520 sectors\r\nUnits = sectors of 1 * 512 = 512 bytes\r\nSector size (logical\/physical): 512 bytes \/ 4096 bytes\r\nI\/O size (minimum\/optimal): 4096 bytes \/ 4096 bytes\r\nDisk label type: dos\r\nDisk identifier: 0x00043041\r\n\r\nDevice Boot Start End Blocks Id System\r\n\/dev\/sda1 * 2048 2099199 1048576 83 Linux\r\n\/dev\/sda2 2099200 20971519 9436160 8e Linux LVM\r\n\r\nDisk \/dev\/sdb: 10.7 GB, 10737418240 bytes, 20971520 sectors\r\nUnits = sectors of 1 * 512 = 512 bytes\r\nSector size (logical\/physical): 512 bytes \/ 4096 bytes\r\nI\/O size (minimum\/optimal): 4096 bytes \/ 4096 bytes\r\nDisk \/dev\/mapper\/cl-root: 8585 MB, 8585740288 bytes, 16769024 sectors\r\nUnits = sectors of 1 * 512 = 512 bytes\r\nSector size (logical\/physical): 512 bytes \/ 4096 bytes\r\nI\/O size (minimum\/optimal): 4096 bytes \/ 4096 bytes\r\nDisk \/dev\/mapper\/cl-swap: 1073 MB, 1073741824 bytes, 2097152 sectors\r\nUnits = sectors of 1 * 512 = 512 bytes\r\nSector size (logical\/physical): 512 bytes \/ 4096 bytes\r\nI\/O size (minimum\/optimal): 4096 bytes \/ 4096 bytes\r\n<\/pre>\n

2\u3001\u53ef\u4ee5\u770b\u5230\u7ea2\u8272\u6807\u6ce8\u7684\u662f10G\u7684\u6570\u636e\u78c1\u76d8\uff0c\u6211\u4eec\u73b0\u5728\u6267\u884c\u5206\u533a\uff0c\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n

\r\n# fdisk -S 56 \/dev\/sdb\r\n\r\nWelcome to fdisk (util-linux 2.23.2).\r\n\r\nChanges will remain in memory only, until you decide to write them.\r\nBe careful before using the write command.\r\n\r\nDevice does not contain a recognized partition table\r\nBuilding a new DOS disklabel with disk identifier 0x52d681d6.\r\n\r\nThe device presents a logical sector size that is smaller than\r\nthe physical sector size. Aligning to a physical sector (or optimal\r\nI\/O) size boundary is recommended, or performance may be impacted.\r\n\r\nCommand (m for help):\u3010\u8f93\u5165n\u56de\u8f66\uff0c\u6dfb\u52a0\u65b0\u5206\u533a\uff0c\u5982\u679c\u9700\u8981\u66f4\u591a\uff0c\u8bf7\u8f93\u5165m\u56de\u8f66\u770b\u5e2e\u52a9\u3011\r\n\r\nPartition type:\r\np primary (0 primary, 0 extended, 4 free)\r\ne extended\r\nSelect (default p):\u3010\u8f93\u5165p\u56de\u8f66\uff0cP\u7684\u610f\u601d\u662f\u4e3b\u5206\u533a\u3011\r\nPartition number (1-4, default 1):\u3010\u8f93\u5165\u6570\u5b571\u56de\u8f66\uff0c\u5206\u533a\u6570\u91cf\u3011\r\nFirst sector (2048-20971519, default 2048):\u3010\u9ed8\u8ba4\u56de\u8f66\u3011\r\nUsing default value 2048\r\nLast sector, +sectors or +size{K,M,G} (2048-20971519, default 20971519):\u3010\u9ed8\u8ba4\u56de\u8f66\u3011\r\nUsing default value 20971519\r\nPartition 1 of type Linux and of size 10 GiB is set\r\n\r\nCommand (m for help):\u3010\u8f93\u5165wq\u4fdd\u5b58\u3011\r\n\r\nThe partition table has been altered!\r\n\r\nCalling ioctl() to re-read partition table.\r\nSyncing disks.\r\n<\/pre>\n

3\u3001\u5206\u533a\u5b8c\u6210\u3002\u8f93\u5165fdisk -l\u67e5\u770b\u4fe1\u606f<\/p>\n

\r\nDisk \/dev\/sda: 10.7 GB, 10737418240 bytes, 20971520 sectors\r\nUnits = sectors of 1 * 512 = 512 bytes\r\nSector size (logical\/physical): 512 bytes \/ 4096 bytes\r\nI\/O size (minimum\/optimal): 4096 bytes \/ 4096 bytes\r\nDisk label type: dos\r\nDisk identifier: 0x00043041\r\n\r\nDevice Boot Start End Blocks Id System\r\n\/dev\/sda1 * 2048 2099199 1048576 83 Linux\r\n\/dev\/sda2 2099200 20971519 9436160 8e Linux LVM\r\n\r\nDisk \/dev\/sdb: 10.7 GB, 10737418240 bytes, 20971520 sectors\r\nUnits = sectors of 1 * 512 = 512 bytes\r\nSector size (logical\/physical): 512 bytes \/ 4096 bytes\r\nI\/O size (minimum\/optimal): 4096 bytes \/ 4096 bytes\r\nDisk label type: dos\r\nDisk identifier: 0x52d681d6\r\n\r\nDevice Boot Start End Blocks Id System\r\n\/dev\/sdb1 2048 20971519 10484736 83 Linux\r\n\r\nDisk \/dev\/mapper\/cl-root: 8585 MB, 8585740288 bytes, 16769024 sectors\r\nUnits = sectors of 1 * 512 = 512 bytes\r\nSector size (logical\/physical): 512 bytes \/ 4096 bytes\r\nI\/O size (minimum\/optimal): 4096 bytes \/ 4096 bytes\r\nDisk \/dev\/mapper\/cl-swap: 1073 MB, 1073741824 bytes, 2097152 sectors\r\nUnits = sectors of 1 * 512 = 512 bytes\r\nSector size (logical\/physical): 512 bytes \/ 4096 bytes\r\nI\/O size (minimum\/optimal): 4096 bytes \/ 4096 bytes\r\n<\/pre>\n

4\u3001\u53ef\u4ee5\u67e5\u770b\/dev\/sdb1\u5df2\u7ecf\u88ab\u9ed8\u8ba4\u5206\u533a\uff0c\u73b0\u5728\u5f00\u59cb\u683c\u5f0f\u5316\u6b64\u5206\u533a\u3002<\/p>\n

\u6ce8\u610f\uff1a\u4ee5\u4e0b\u6709\u51e0\u79cd\u5e38\u7528\u78c1\u76d8\u683c\u5f0f\uff0c\u5982\u679c\u4f60\u60f3\u683c\u5f0f\u5316ext3\u683c\u5f0f,\u4ee3\u7801\u5982\u4e0b;<\/p>\n

\r\n# mkfs.ext3 \/dev\/sdb1\r\n\r\n\u683c\u5f0f\u5316ext4\u683c\u5f0f\uff0c\u4ee3\u7801\u5982\u4e0b\uff1b\r\n\r\n# mkfs.ext4 \/dev\/sdb1\r\n\r\n\u6211\u8fd9\u91cc\u91c7\u7528\u7684\u662fxfs\u78c1\u76d8\u683c\u5f0f\uff1b\u4ee3\u7801\u5982\u4e0b\uff1b\r\n\r\n# mkfs.xfs -f \/dev\/sdb1\r\n\r\nmeta-data=\/dev\/sdb1 isize=512 agcount=4, agsize=655296 blks\r\n= sectsz=4096 attr=2, projid32bit=1\r\n= crc=1 finobt=0, sparse=0\r\ndata = bsize=4096 blocks=2621184, imaxpct=25\r\n= sunit=0 swidth=0 blks\r\nnaming =version 2 bsize=4096 ascii-ci=0 ftype=1\r\nlog =internal log bsize=4096 blocks=2560, version=2\r\n= sectsz=4096 sunit=1 blks, lazy-count=1\r\nrealtime =none extsz=4096 blocks=0, rtextents=0\r\n<\/pre>\n

5\u3001\u5df2\u7ecf\u683c\u5f0f\u5316\u6210\u529f\u3002\u5c06\u78c1\u76d8\u6302\u8f7d\u4fe1\u606f\u5199\u5165\u5230\u7cfb\u7edf\u914d\u7f6e\u6587\u4ef6\u4e2d\uff0c\u4e0d\u7136\u5f00\u673a\u4e0d\u4f1a\u81ea\u52a8\u6302\u8f7d\uff0c\u4ee3\u7801\u5982\u4e0b\uff1b<\/p>\n

\r\n# echo \u2018\/dev\/sdb1 \/www xfs defaults 0 0\u2019 >> \/etc\/fstab\r\n# mkdir \/www \/\/\u65b0\u5efa\u6302\u8f7d\u76ee\u5f55\r\n# mount -a \/\/\u6302\u8f7d\u78c1\u76d8\r\n# df -h \/\/\u67e5\u770b\u6302\u8f7d\u662f\u5426\u6210\u529f\r\n\r\nFilesystem Size Used Avail Use% Mounted on\r\n\/dev\/mapper\/cl-root 8.0G 3.1G 5.0G 39% \/\r\ndevtmpfs 906M 0 906M 0% \/dev\r\ntmpfs 916M 0 916M 0% \/dev\/shm\r\ntmpfs 916M 8.3M 908M 1% \/run\r\ntmpfs 916M 0 916M 0% \/sys\/fs\/cgroup\r\n\/dev\/sda1 1014M 138M 877M 14% \/boot\r\ntmpfs 184M 0 184M 0% \/run\/user\/0\r\n\/dev\/sdb1 10G 33M 10G 1% \/www\r\n<\/pre>\n

6\u3001\u53ef\u4ee5\u770b\u5230www\u76ee\u5f55\u5df2\u7ecf\u6302\u8f7d\u6210\u529f\u3002<\/p>\n

\u6269\u5c55\u9605\u8bfb\uff0cfdisk -S 56 \/dev\/sdb\u7684\u65f6\u5019\u8f93\u5165m\u6709\u5e2e\u52a9\u4fe1\u606f\uff0c\u4e0b\u9762\u5c31\u5217\u4e3e\u8bf4\u660e\uff1a<\/p>\n

\r\na\u3001toggle a bootable flag \/\/\u5207\u6362\u4e00\u4e2a\u53ef\u542f\u52a8\u7684\u6807\u5fd7\r\nb\u3001 edit bsd disklabel \/\/\u7f16\u8f91bsd disklabel\r\nc\u3001 toggle the dos compatibility flag \/\/\u5207\u6362dos\u517c\u5bb9\u6027\u6a21\u5f0f\r\nd\u3001 delete a partition \/\/\u5220\u9664\u4e00\u4e2a\u5206\u533a\r\ng\u3001 create a new empty GPT partition table \/\/\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u7a7aGPT\u5206\u533a\u8868\r\nG \u3001create an IRIX (SGI) partition table \/\/\u521b\u5efa\u4e00\u4e2aIRIX\uff08SGI\uff09\u5206\u533a\u8868\r\nl \u3001list known partition types \/\/\u5217\u51fa\u5df2\u77e5\u7684\u5206\u533a\u7c7b\u578b\r\nm\u3001 print this menu \/\/\u6253\u5370\u6b64\u83dc\u5355\r\nn\u3001 add a new partition \/\/\u6dfb\u52a0\u4e00\u4e2a\u65b0\u7684\u5206\u533a\r\no\u3001 create a new empty DOS partition table \/\/\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u7a7aDOS\u5206\u533a\u8868\r\np\u3001 print the partition table \/\/\u6253\u5370\u5206\u533a\u8868\r\nq\u3001 quit without saving changes \/\/\u9000\u51fa\u800c\u4e0d\u4fdd\u5b58\u66f4\u6539\r\ns\u3001 create a new empty Sun disklabel \/\/\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u7a7a\u7684Sun\u78c1\u76d8\u6807\u7b7e\r\nt\u3001 change a partition\u2019s system id \/\/\u66f4\u6539\u5206\u533a\u7684\u7cfb\u7edfID\r\nu\u3001 change display\/entry units \/\/\u66f4\u6539\u663e\u793a\/\u8f93\u5165\u5355\u4f4d\r\nv\u3001 verify the partition table \/\/\u9a8c\u8bc1\u5206\u533a\u8868\r\nw\u3001 write table to disk and exit \/\/\u5c06\u8868\u5199\u5165\u78c1\u76d8\u4fdd\u5b58\u5e76\u9000\u51fa\r\nx\u3001extra functionality (experts only) \/\/\u9ad8\u7ea7\u529f\u80fd\uff08\u4ec5\u9650\u4e13\u5bb6\uff09\r\n<\/pre>\n
\n

\u539f\u6587\u6765\u81ea\uff1ahttps:\/\/renwole.com\/archives\/82<\/a><\/p>\n

\u672c\u6587\u5730\u5740\uff1ahttps:\/\/gulass.cn\/linux-fdisk.html<\/a>\u7f16\u8f91\uff1a\u738b\u6bc5\uff0c\u5ba1\u6838\u5458\uff1a\u9004\u589e\u5b9d<\/span><\/p>\n<\/blockquote>\n","protected":false},"excerpt":{"rendered":"

\u670d\u52a1\u5668\u5b89\u88c5centos\u7684\u65f6\u5019\uff0c\u901a\u5e38linux\u7cfb\u7edf\u5206\u533a\u9ed8\u8ba4\u4e3a3\u4e2a\u5206\u533a\uff0c\u4e3b\u5206\u533a\u6700\u591a4\u4e2a\uff0c\u5176\u4ed6\u53ef\u6839\u636e\u81ea\u5df1\u7684\u9700\u8981\u6302\u8f7d\u3002 […]<\/p>\n","protected":false},"author":564,"featured_media":101040,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-101036","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts\/101036","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\/564"}],"replies":[{"embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/comments?post=101036"}],"version-history":[{"count":4,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts\/101036\/revisions"}],"predecessor-version":[{"id":292382,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts\/101036\/revisions\/292382"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/media\/101040"}],"wp:attachment":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/media?parent=101036"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/categories?post=101036"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/tags?post=101036"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}