Linux怎样支持2T以上大硬盘分区

Linux怎样支持2T以上大硬盘分区,第1张

Linux在Ext2文件系统的时候就支持2T以上的硬盘分区了,如果Ext2的data block大小是1KB时支持最大2T的分区总容量大小,当Ext2的data block是2KB时则支持最大8T的分区总容量,而当Ext2的data block是4KB时分区最大总容量更是达到了16T。后来的Ext3、Ext4更要比Ext2文件系统支持更大的硬盘分区容量。

Linux上还有一个parted命令,用于支持在硬盘上建立分区时,能够划分出高于2T以上的分区,因为传统的fdisk命令不支持划分2T以上的硬盘分区,所以现在的Linux发行版加入了parted命令来支持2T以上分区的划分。

linux版本:root@HWPKI-TEST-97:~# lsb_release -a No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 14.04.5 LTS Release: 14.04 Codename: trusty挂载硬盘:root@HWPKI-TEST-96:~# fdisk -l Disk /dev/sda: 3000.6 GB, 3000592982016 bytes 90 heads, 3 sectors/track, 21705678 cylinders, total 5860533168 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 4096 bytes I/O size (minimum/optimal): 4096 bytes / 4096 bytes Disk identifier: 0x54a892f2 Device Boot Start End Blocks Id System /dev/sda1 2048 4294967294 2147482623+ 83 Linux该硬盘共有5860533168 sectors,但是使用fdisk分区时,只识别到4294967294 sectors 这个时候如果仍使用fdisk进行分区,会有如下提示:root@HWPKI-TEST-96:~# fdisk /dev/sda WARNING: The size of this disk is 3.0 TB (3000592982016 bytes). DOS partition table format can not be used on drives for volumes larger than (2199023255040 bytes) for 512-byte sectors. Use parted(1) and GUID partition table format (GPT). The device presents a logical sector size that is smaller than the physical sector size. Aligning to a physical sector (or optimal I/O) size boundary is recommended, or performance may be impacted.意思大概是说DOS格式分区表不能用于容量大于2 199 023 255 040 bytes(2T,粗略计算),对于扇区为512-byte。 此外,它还推荐使用parted(1)来进行GPT格式分区,关于 GUID Partition Table ,翻墙可查看。最后一段说逻辑扇区小于物理扇区,你需要将其与物理扇区对齐,否则表现就会不完美(美式汉语),了解一下,一会使用parted有个步骤需要对齐,原理并不懂。 这里我先忽略警告,将已经错误分区损失1T(均价400RMB)的分区删除,方法参考fdisk里的d命令,删除之后需要w保存,下面是结果:Command (m for help): d Selected partition 1 Command (m for help): d No partition is defined yet! Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. WARNING: Re-reading the partition table failed with error 16: Device or resource busy. The kernel still uses the old table. The new table will be used at the next reboot or after you run partprobe(8) or kpartx(8) Syncing disks.附上fdisk命令:Command action a toggle a bootable flag b edit bsd disklabel c toggle the dos compatibility flag d delete a partition l list known partition types m print this menu n add a new partition o create a new empty DOS partition table p print the partition table q quit without saving changes s create a new empty Sun disklabel t change a partition's system id u change display/entry units v verify the partition table w write table to disk and exit x extra functionality (experts only)写入分区需要通知,删除同理: partprobe需要让内核知道,结果并不如我意root@HWPKI-TEST-96:~# partprobe Error: Partition(s) 1 on /dev/sda have been written, but we have been unable to inform the kernel of the change, probably because it/they are in use. As a result, the old partition(s) will remain in use. You should reboot now before making further changes.linux告诉我它并不能通知内核这样做,在/dev/sda上的第一分区已经使用过,这种情况在现实中我也是能理解的,原理不懂。 不想重启,所以就直接将分区卸载:oot@HWPKI-TEST-96:~# umount /mnt接下来的步骤按照网上的流程走,参考 DOS Partitions (fdisk) and the 2TB Limit 和parted手册 GNU Parted User Manual,这里我们按照自己的环境 *** 作一遍:root@HWPKI-TEST-96:~# parted GNU Parted 2.3 Using /dev/sda Welcome to GNU Parted! Type 'help' to view a list of commands.出现欢迎布拉布拉,输入help(救命啊!!)(parted) help align-check TYPE N check partition N for TYPE(min|opt) alignment check NUMBER do a simple check on the file system cp [FROM-DEVICE] FROM-NUMBER TO-NUMBER copy file system to another partition help [COMMAND] print general help, or help on COMMAND mklabel,mktable LABEL-TYPE create a new disklabel (partition table) mkfs NUMBER FS-TYPE make a FS-TYPE file system on partition NUMBER mkpart PART-TYPE [FS-TYPE] START END make a partition mkpartfs PART-TYPE FS-TYPE START END make a partition with a file system resizepart NUMBER END resize partition NUMBER move NUMBER START END move partition NUMBER name NUMBER NAME name partition NUMBER as NAME print [devices|free|list,all|NUMBER] display the partition table, available devices, free space, all found partitions, or a particular partition quit exit program rescue START END rescue a lost partition near START and END resize NUMBER START END resize partition NUMBER and its file system rm NUMBER delete partition NUMBER select DEVICE choose the device to edit set NUMBER FLAG STATE change the FLAG on partition NUMBER toggle [NUMBER [FLAG]] toggle the state of FLAG on partition NUMBER unit UNIT set the default unit to UNIT version display the version number and copyright information of GNU Parted以上是parted的用法,敬请参考。 在分区以前,介绍一下步骤:


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/yw/8703525.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-20
下一篇 2023-04-20

发表评论

登录后才能评论

评论列表(0条)

保存