現在的硬盤很多都大於2T,但是linux自帶的fdisk 工具無法格式化大於2T的磁盤,需要使用第三方工具parted,我們來看如何使用parted格式硬盤
1,可以先使用fdisk -l查看系統當前的硬盤,可以看到該系統中掛載了1個12T的硬盤,分別是/dev/sdb
[root@test-01 /]# fdisk -l Disk /dev/sda: 299.4 GB, 299439751168 bytes, 584843264 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk label type: dos Disk identifier: 0x000b73fd Device Boot Start End Blocks Id System /dev/sda1 * 2048 2099199 1048576 83 Linux /dev/sda2 2099200 584843263 291372032 8e Linux LVM Disk /dev/sdb: 12000.7 GB, 12000675495936 bytes, 23438819328 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes
其他 省略。。。。
2,開始格式化,執行命令parted /dev/sdb 是需要格式化的磁盤,這里一定要注意別選擇錯了,否則數據會丟失。
#print #查看下實際可使用磁盤空間數
[root@test-01 /]# parted /dev/sdb GNU Parted 3.1 Using /dev/sdb Welcome to GNU Parted! Type 'help' to view a list of commands. (parted) print Error: /dev/sdb: unrecognised disk label Model: DELL PERC H730 Mini (scsi) Disk /dev/sdb: 12.0TB Sector size (logical/physical): 512B/512B Partition Table: unknown Disk Flags:
#mklabel gpt #將MBR磁盤轉換為GPT
#print #查看下實際可使用磁盤空間數
(parted) mklabel gpt (parted) print Model: DELL PERC H730 Mini (scsi) Disk /dev/sdb: 12.0TB Sector size (logical/physical): 512B/512B Partition Table: gpt Disk Flags: Number Start End Size File system Name Flags
#mkpart primary 0 12.0TB #創建主分區,空間為從0 gb到12.0TB全部空間
#print #打印當前分區情況
(parted) mkpart primay 0 12.0TB Warning: The resulting partition is not properly aligned for best performance. Ignore/Cancel? Ignore (parted) print Model: DELL PERC H730 Mini (scsi) Disk /dev/sdb: 12.0TB Sector size (logical/physical): 512B/512B Partition Table: gpt Disk Flags: Number Start End Size File system Name Flags 1 17.4kB 12.0TB 12.0TB primay (parted) quit Information: You may need to update /etc/fstab.
#quit #退出parted工具
至此,格式化大於2T硬盤成功完成,后面可以繼續格式化磁盤,掛載磁盤
#mkfs.ext4 /dev/sdb1 格式化磁盤
[root@test-01 /]# fdisk -l Disk /dev/sda: 299.4 GB, 299439751168 bytes, 584843264 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk label type: dos Disk identifier: 0x000b73fd Device Boot Start End Blocks Id System /dev/sda1 * 2048 2099199 1048576 83 Linux /dev/sda2 2099200 584843263 291372032 8e Linux LVM WARNING: fdisk GPT support is currently new, and therefore in an experimental phase. Use at your own discretion. Disk /dev/sdb: 12000.7 GB, 12000675495936 bytes, 23438819328 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk label type: gpt Disk identifier: 91AD0A00-FD37-4A33-8E6A-B8477287685C [root@test-01 /]# mkfs.ext4 /dev/sdb1 mke2fs 1.42.9 (28-Dec-2013) Filesystem label= OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) Stride=0 blocks, Stripe width=0 blocks 366231552 inodes, 2929852407 blocks 146492620 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=4294967296 89412 block groups 32768 blocks per group, 32768 fragments per group 4096 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968, 102400000, 214990848, 512000000, 550731776, 644972544, 1934917632, 2560000000 Allocating group tables: done Writing inode tables: done Creating journal (32768 blocks): done Writing superblocks and filesystem accounting information: done
#mount /dev/sdb1 /data 掛載磁盤到/data目錄
mount /dev/sdb1 /data
#將/dev/sdb1開機自動掛載到/data1目錄
echo '/dev/sdb1 /data ext4 defaults 0 0' >> /etc/fstab