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的用法,敬请参考。 在分区以前,介绍一下步骤:Linux中进行
磁盘分区一般是用fdisk这个命令,但是fdisk命令无法支持大于2TB以上的分区,而parted命令却是用于2TB以上大小的磁盘分区的工具。parted命令的用法:
1. 列出磁盘分区的信息(这个可以看到接下来新建分区的起始点):
形式:parted 磁盘设备名称 print
例如:parted /dev/hdc print
2. 新建一个分区:
形式:parted 磁盘设备名称 mkpart logical 文件系统类型 新建分区起始位置 新建分区结束位置
例子:parted /dev/hdc mkpart logical ext3 20.3G 80.3G
说明:/dev/hdc是磁盘设备名称,mkpart是新建分区,logical表示是一个逻辑分区,ext3是文件系统类型,20.3G是分区起始位置,这个是查看分区信息的时候,显示的最末尾的那个分区End这一栏的,80.3G是结束位置,也就是说这个新建的分区有60G大小。
3. 删除一个分区:
形式:parted 磁盘设备名称 rm 设备Number
例子:parted /dev/hdc rm 7
说明:设备Number的那个数字是用parted列出的分区信息里面,有一列是Number号码,需要删除那个分区就对应那个数字。
1、由于MBR分区表只支持2T磁盘,所以大于2T的磁盘必须使用GPT分区表
2、fdisk -l 确定2T硬盘文件,例如/dev/sdb
3、parted /dev/sdb mklabel gpt
4、添加分区命令格式:
parted device mkpart part-type [fs-type] start end
parted /dev/sdb mkpart primary xfs 0 -0
5、格式化xfs分区:
mkfs.xfs -f /dev/sdb1
6、挂载xfs分区:
mount -t xfs /dev/sdb1 /data1
7、df -h检查
Filesystem Size Used Avail Use% Mounted on
/dev/sdb1 1.7T 335G 1.3T 21% /data1
8、为了重启系统自动mount新硬盘,编辑/etc/fstab,添加
/dev/sdb1 /data1 xfs defaults0 0
评论列表(0条)