基本的分区操作gdisk 来给GPT分区表 分区 MBR 分区表使用fdisk命令 这两个一样[root@ds ~]# lsblk #列出系统上所有磁盘列表NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTvda 253:0 0 40G 0 disk└─vda1 253:1 0 40G 0 part /[root@ds ~]# blkid #列出设备的UUID/dev/vda1: UUID="1114fe9e-2309-4580-b183-d778e6d97397" TYPE="ext4"[root@ds ~]# parted /dev/vda1 print #查看这块磁盘的的相关信息Model: Virtio Block Device (virtblk)Disk /dev/vda1: 42.9GBSector size (logical/physical): 512B/512BPartition Table: loop #f分区表的格式3Disk Flags:Number Start End Size File system Flags1 0.00B 42.9GB 42.9GB ext4[root@ds ~]# gdisk /dev/vda1 #分区GPT fdisk (gdisk) version 0.8.10Command (? for help): pCommand (? for help): nPartition number (1-128, default 1):First sector (34-83873283, default = 2048) or {+-}size{KMGTP}:Last sector (2048-83873283, default = 83873283) or {+-}size{KMGTP}: +2GCurrent type is 'Linux filesystem'Hex code or GUID (L to show codes, Enter = 8300):Changed type of partition to 'Linux filesystem'Command (? for help): pDisk /dev/vda1: 83873317 sectors, 40.0 GiBLogical sector size: 512 bytesDisk identifier (GUID): 42B07C7C-1C05-4AE4-A687-5CE54B0E66E3Partition table holds up to 128 entriesFirst usable sector is 34, last usable sector is 83873283Partitions will be aligned on 2048-sector boundariesTotal free space is 79678946 sectors (38.0 GiB)Number Start (sector) End (sector) Size Code Name1 2048 4196351 2.0 GiB 8300 Linux filesystemCommand (? for help): w #保存Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTINGPARTITIONS!!Do you want to proceed? (Y/N): yOK; writing new GUID partition table (GPT) to /dev/vda1.Warning: The kernel is still using the old partition table.The new table will be used at the next reboot.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 /
