有一篇文章写的很好
https://blog.csdn.net/qq_28364071/article/details/85945616?ops_request_misc=&request_id=&biz_id=102&utm_term=%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F%E5%92%8C%E5%88%86%E5%8C%BA&utm_medium=distribute.pc_search_result.none-task-blog-2~all~sobaiduweb~default-2-.pc_search_result_before_js&spm=1018.2226.3001.4187
网址我放这里了
1.磁盘的分区

  1. 基本的分区操作
  2. gdisk 来给GPT分区表 分区 MBR 分区表使用fdisk命令 这两个一样
  3. [root@ds ~]# lsblk #列出系统上所有磁盘列表
  4. NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
  5. vda 253:0 0 40G 0 disk
  6. └─vda1 253:1 0 40G 0 part /
  7. [root@ds ~]# blkid #列出设备的UUID
  8. /dev/vda1: UUID="1114fe9e-2309-4580-b183-d778e6d97397" TYPE="ext4"
  9. [root@ds ~]# parted /dev/vda1 print #查看这块磁盘的的相关信息
  10. Model: Virtio Block Device (virtblk)
  11. Disk /dev/vda1: 42.9GB
  12. Sector size (logical/physical): 512B/512B
  13. Partition Table: loop #f分区表的格式
  14. 3
  15. Disk Flags:
  16. Number Start End Size File system Flags
  17. 1 0.00B 42.9GB 42.9GB ext4
  18. [root@ds ~]# gdisk /dev/vda1 #分区
  19. GPT fdisk (gdisk) version 0.8.10
  20. Command (? for help): p
  21. Command (? for help): n
  22. Partition number (1-128, default 1):
  23. First sector (34-83873283, default = 2048) or {+-}size{KMGTP}:
  24. Last sector (2048-83873283, default = 83873283) or {+-}size{KMGTP}: +2G
  25. Current type is 'Linux filesystem'
  26. Hex code or GUID (L to show codes, Enter = 8300):
  27. Changed type of partition to 'Linux filesystem'
  28. Command (? for help): p
  29. Disk /dev/vda1: 83873317 sectors, 40.0 GiB
  30. Logical sector size: 512 bytes
  31. Disk identifier (GUID): 42B07C7C-1C05-4AE4-A687-5CE54B0E66E3
  32. Partition table holds up to 128 entries
  33. First usable sector is 34, last usable sector is 83873283
  34. Partitions will be aligned on 2048-sector boundaries
  35. Total free space is 79678946 sectors (38.0 GiB)
  36. Number Start (sector) End (sector) Size Code Name
  37. 1 2048 4196351 2.0 GiB 8300 Linux filesystem
  38. Command (? for help): w #保存
  39. Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
  40. PARTITIONS!!
  41. Do you want to proceed? (Y/N): y
  42. OK; writing new GUID partition table (GPT) to /dev/vda1.
  43. Warning: The kernel is still using the old partition table.
  44. The new table will be used at the next reboot.
  45. The operation has completed successfully.

第二种
无论是gpt还是Mbr 我们都可以使用 parted命令来分区

命令格式  parted  [设备] { 命令 [参数] }
parted /dev/vda1 mkpart ds  xfs 10.0GB 20.0GB
分区 起始位置是10g到20g  名字是ds 
parted  /dev/vda   print
#打印 这个分区的详细信息
parted  /dev/vda   rm ds
删除分区 
partprobe 
#修改分区表

分区之后按下w保存之后 我们的修改并没有同步到磁盘中
我们可以通过两个方式来出来 第一种 重新启动
第二种使用 partprobe 这个命令来更新ilnxu 内核的分区表信息

[root@ds ~]# partprobe -s
/dev/vda: msdos partitions 1

分区之后的查看

[root@ds ~]# cat /proc/partitions            #如果分区完了之后这就会有显示
major minor  #blocks  name

 253        0   41943040 vda
 253        1   41936658 vda1

2.磁盘的格式化(创建文件系统)
创建xfs文件系统
有两个命令可以使用
mkfs.xfs 和 mkfs
第一个命令只能格式化为xfs类型的 第二种是一个综合命令
也是调用的 mkfs.xfs
mkfs.xfs 这个命令的参数比较多 我们使用默认的就行
想了解的 回来看鸟哥 P238

格式化为xfs
mkfs.xfs /dev/vda1
mkfs -t   xfs  /dev/ada1
格式化为 etx4
mkfx.ext4  /dev/vda1
mkfs -t ext4 /dev/vda1

3.挂载
tips1.

mount [-t 文件系统]  设备名字 挂载目录

我们可以不用指定文件系统就能挂载成功
linxu 这么做到的呢
我们的linxu 通过超级区块中的内容去测试挂载 一个一个尝试
tips2.
/etc/fastab 是启动是的配置文件 mount -a 是挂载这个文件中的 未挂载的设备
时间文件系统的挂载是记录在 /etc/mtab 和 /proc/mounts 中的
如果我们这个文件出错 进入单人维护模式 根目录是以只读方式
挂载的 根本写入不了数据
我就就可以使用

mount  -n  -o remount,rw  /

-n 就是不写入配置文件 -o 特殊选项 以只读方式挂载
mount 可以挂载目录 可以挂载设备 还有很多附加的参数
详情 见鸟哥 P249