• linux下大于2T硬盘格式化方法


    现在的硬盘很多都大于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   
  • 相关阅读:
    架构师的成长之路初片~ntp时间同步
    架构师的成长之路初片~水晶头的颜色排序
    架构师的成长之路初片~Python-邮件(smtplib)、requests模块、API接口调用
    架构师成长之路之~调优思维
    架构师的成长之路初片~python~调整背景及滚轮+各种快捷键
    架构师成长之路之~Node.js安装篇
    微服务技术栈
    C#资源释放(托管资源、非托管资源)
    Beyond Compare 4 密匙
    MySql批量导入 .netcore命名空间完全相同问题
  • 原文地址:https://www.cnblogs.com/xzlive/p/15522239.html
Copyright © 2020-2023  润新知