创建新硬盘分区命令参数:
    fdisk 可以用 m 命令来看 fdisk 命令的内部命令;
    a:命令指定启动分区;
    d:命令删除一个存在的分区;
    l:命令显示分区 ID 号的列表;
    m:查看 fdisk 命令帮助;
    n:命令创建一个新分区;
    p:命令显示分区列表;
    t:命令修改分区的类型 ID 号;
    w:命令是将对分区表的修改存盘让它发生作用

    1. [root@kiccleaf ~]# fdisk -l
    2. Disk /dev/sda: 1000 GiB, 1073741824000 bytes, 2097152000 sectors
    3. Units: sectors of 1 * 512 = 512 bytes
    4. Sector size (logical/physical): 512 bytes / 512 bytes
    5. I/O size (minimum/optimal): 512 bytes / 512 bytes
    6. Disklabel type: dos
    7. Disk identifier: 0x16aee8ac
    8. Device Boot Start End Sectors Size Id Type
    9. /dev/sda1 * 2048 2099199 2097152 1G 83 Linux
    10. /dev/sda2 2099200 2097151999 2095052800 999G 8e Linux LVM
    11. //新硬盘
    12. Disk /dev/sdb: 1000 GiB, 1073741824000 bytes, 2097152000 sectors
    13. Units: sectors of 1 * 512 = 512 bytes
    14. Sector size (logical/physical): 512 bytes / 512 bytes
    15. I/O size (minimum/optimal): 512 bytes / 512 bytes
    16. Disk /dev/mapper/cl-root: 50 GiB, 53687091200 bytes, 104857600 sectors
    17. Units: sectors of 1 * 512 = 512 bytes
    18. Sector size (logical/physical): 512 bytes / 512 bytes
    19. I/O size (minimum/optimal): 512 bytes / 512 bytes
    20. Disk /dev/mapper/cl-swap: 7.9 GiB, 8468299776 bytes, 16539648 sectors
    21. Units: sectors of 1 * 512 = 512 bytes
    22. Sector size (logical/physical): 512 bytes / 512 bytes
    23. I/O size (minimum/optimal): 512 bytes / 512 bytes
    24. Disk /dev/mapper/cl-home: 941.1 GiB, 1010508496896 bytes, 1973649408 sectors
    25. Units: sectors of 1 * 512 = 512 bytes
    26. Sector size (logical/physical): 512 bytes / 512 bytes
    27. I/O size (minimum/optimal): 512 bytes / 512 bytes
    28. [root@kiccleaf ~]# fdisk /dev/sdb
    29. Welcome to fdisk (util-linux 2.32.1).
    30. Changes will remain in memory only, until you decide to write them.
    31. Be careful before using the write command.
    32. Device does not contain a recognized partition table.
    33. Created a new DOS disklabel with disk identifier 0xa5c1ca20.
    34. Command (m for help): n
    35. Partition type
    36. //输入p分为主分区
    37. p primary (0 primary, 0 extended, 4 free)
    38. //输入e分为逻辑分区
    39. e extended (container for logical partitions)
    40. Select (default p): p
    41. //输入该主分区为第几个主分区,由于是新盘我们输入1来分第一个主分区
    42. Partition number (1-4, default 1): 1
    43. //First sector 是选择该分区的起始扇区,直接回车
    44. First sector (2048-2097151999, default 2048):
    45. //使用全部可用存储额,直接回车
    46. Last sector, +sectors or +size{K,M,G,T,P} (2048-2097151999, default 2097151999):
    47. Created a new partition 1 of type 'Linux' and of size 1000 GiB.
    48. //w保存
    49. Command (m for help): w
    50. The partition table has been altered.
    51. Calling ioctl() to re-read partition table.
    52. Syncing disks.
    53. //mkfs.xfs命令带-f强制格式化
    54. [root@kiccleaf ~]# mkfs.xfs -f /dev/sdb1
    55. meta-data=/dev/sdb1 isize=512 agcount=4, agsize=65535936 blks
    56. = sectsz=512 attr=2, projid32bit=1
    57. = crc=1 finobt=1, sparse=1, rmapbt=0
    58. = reflink=1
    59. data = bsize=4096 blocks=262143744, imaxpct=25
    60. = sunit=0 swidth=0 blks
    61. naming =version 2 bsize=4096 ascii-ci=0, ftype=1
    62. log =internal log bsize=4096 blocks=127999, version=2
    63. = sectsz=512 sunit=0 blks, lazy-count=1
    64. realtime =none extsz=4096 blocks=0, rtextents=0
    65. //用命令blkid 查看一下已是xfs格式
    66. [root@kiccleaf data]# blkid /dev/sdb1
    67. /dev/sdb1: UUID="813681bd-a154-43d8-88dc-27750eacfcc1" TYPE="xfs" PARTUUID="a5c1ca20-01"
    68. //创建挂载目录
    69. [root@kiccleaf ~]# mkdir /data
    70. //mount直接挂载硬盘至data
    71. [root@kiccleaf ~]# mount /dev/sdb1 /data
    72. //查看一下挂载的硬盘data已经有了
    73. [root@kiccleaf ~]# df -h
    74. Filesystem Size Used Avail Use% Mounted on
    75. devtmpfs 3.8G 0 3.8G 0% /dev
    76. tmpfs 3.9G 0 3.9G 0% /dev/shm
    77. tmpfs 3.9G 9.0M 3.8G 1% /run
    78. tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup
    79. /dev/mapper/cl-root 50G 6.3G 44G 13% /
    80. /dev/mapper/cl-home 941G 6.7G 935G 1% /home
    81. /dev/sda1 976M 198M 711M 22% /boot
    82. tmpfs 779M 0 779M 0% /run/user/0
    83. /dev/sdb1 984G 77M 934G 1% /data
    84. //系统重启自动挂载该分区对fstab进行编辑
    85. [root@kiccleaf ~]# vim /etc/fstab

    系统重启自动挂载该分区可修改 / etc/fstab 文件,在最后加入添加:/dev/sdb1 /data xfs defaults 0 0

    格式说明:/dev/sdb1 代表哪个分区, /data 是挂载目录, xfs 是该分区的格式,defaults 是挂载时所要设定的参数 (只读,读写,启用 quota 等),输入 defaults 包括的参数有 (rw、dev、exec、auto、nouser、async) ,1 是使用 dump 是否要记录,0 是不要。 2 是开机时检查的顺序,是 boot 系统文件就为 1,其他文件系统都为 2,如不要检查就为 0

    1. /dev/mapper/cl-root / xfs defaults 0 0
    2. UUID=86a7eaa3-61db-49cd-be3d-54b724f24878 /boot ext4 defaults 1 2
    3. /dev/mapper/cl-home /home xfs defaults 0 0
    4. /dev/mapper/cl-swap swap swap defaults 0 0
    5. /dev/sdb1 /data xfs defaults 0 0

    xfs 格式是一种非常优秀的日志文件系统,它是 SGI 公司设计的。xfs 被称为业界最先进的、最具可升级性的文件系统技术,xfs 是一个 64 位文件系统,最大支持 8EB 减 1 字节的单个文件系统,实际部署时取决于宿主操作系统的最大块限制。对于一个 32 位 Linux 系统,文件和文件系统的大小会被限制在 16TB
    xfs 在很多方面确实做的比 ext4 好,ext4 受限制于磁盘结构和兼容问题,可扩展性和 scalability 确实不如 xfs。具体详细的区别请自行了解,采用 df -T 命令查看系统硬盘的格式

    1. [root@kiccleaf ~]
    2. Filesystem Type 1K-blocks Used Available Use% Mounted on
    3. devtmpfs devtmpfs 3968364 0 3968364 0% /dev
    4. tmpfs tmpfs 3985404 0 3985404 0% /dev/shm
    5. tmpfs tmpfs 3985404 9176 3976228 1% /run
    6. tmpfs tmpfs 3985404 0 3985404 0% /sys/fs/cgroup
    7. /dev/mapper/cl-root xfs 52403200 6583040 45820160 13% /
    8. /dev/sdb1 xfs 1048062980 7340272 1040722708 1% /data
    9. /dev/sda1 ext4 999320 202436 728072 22% /boot
    10. /dev/mapper/cl-home xfs 986342856 6965148 979377708 1% /home
    11. tmpfs tmpfs 797080 0 797080 0% /run/user/0

    https://www.kiccleaf.com/?p=803