1.磁盘分区
Changes will remain in memory only, until you decide to write them.
你进行的修改默认存放在内存中,直到你决定保存这些修改的时候.
:wq
Be careful before using the write command.
保存之前小心点!
Device does not contain a recognized partition table
设备 没有 包含 磁盘分区表。
Building a new DOS disklabel with disk identifier 0x6df46197.
DPT= disk partition table 磁盘分区表
Invalid partition type `e'
mkfs.xfs /dev/sdb1
mkfs.xfs: /dev/sdb1 appears to contain an existing filesystem (ext4).
这个磁盘分区中 已经包含了1个文件系统(已经格式化过了)
mkfs.xfs: Use the -f option to force overwrite.
如果强制格式化使用-f
[root@cuihua ~]# mount /dev/sdb1 /mnt
mount: /dev/sdb1 is write-protected, mounting read-only
mount: unknown filesystem type '(null)'
未知的文件系统(没有格式化)
5.```
[root@guanggege ~]# mount /dev/sdb1 /mnt/
mount: special device /dev/sdb1 does not exist
特殊文件(设备文件) 不存在
6.
[root@oldboyedu59 ~]# mkfs.xfs /dev/sdb1
mkfs.xfs: /dev/sdb1 contains a mounted filesystem
sdb1磁盘分区 包含 1个已经挂载的文件系统 (磁盘分区已经挂载)
Usage: mkfs.xfs
/* blocksize */ [-b log=n|size=num]
/* metadata */ [-m crc=0|1,finobt=0|1,uuid=xxx]
/* data subvol */ [-d agcount=n,agsize=n,file,name=xxx,size=num,
(sunit=value,swidth=value|su=num,sw=num|noalign),
sectlog=n|sectsize=num
/* force overwrite */ [-f]
/* inode size */ [-i log=n|perblock=n|size=num,maxpct=n,attr=0|1|2,
projid32bit=0|1]
/* no discard */ [-K]
/* log subvol */ [-l agnum=n,internal,size=num,logdev=xxx,version=n
sunit=value|su=num,sectlog=n|sectsize=num,
lazy-count=0|1]
/* label */ [-L label (maximum 12 characters)]
/* naming */ [-n log=n|size=num,version=2|ci,ftype=0|1]
/* no-op info only */ [-N]
/* prototype file */ [-p fname]
/* quiet */ [-q]
/* realtime subvol */ [-r extsize=num,size=num,rtdev=xxx]
/* sectorsize */ [-s log=n|size=num]
/* version */ [-V]
devicename
is required unless -d name=xxx is given.
is xxx (bytes), xxxs (sectors), xxxb (fs blocks), xxxk (xxx KiB),
xxxm (xxx MiB), xxxg (xxx GiB), xxxt (xxx TiB) or xxxp (xxx PiB).
is xxx (512 byte blocks).
7. [root@oldboy ~]# mkfs.xfs /dev/sdb1 -f
agsize (2560 blocks) too small, need at least 4096 blocks
磁盘分区太小了 无法格式化
Usage: mkfs.xfs
[root@oldboyedu ~]# mount /dev/sdb1 /mnt/
mount: /dev/sdb1 is already mounted or /mnt busy
磁盘分区 已经 挂载或/mnt正在使用中
/dev/sdb1 is already mounted on /mnt
Command (m for help): p
Disk /dev/sdb: 106 MB, 106954752 bytes, 208896 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: 0x6df46197
Device Boot Start End Blocks Id System
Command (m for help): n
Partition type:
p primary (0 primary, 0 extended, 4 free)
主分区
e extended、
扩展分区
Select (default p):
默认就是 p
Partition number (1-4, default 1):
分区号 默认
First sector (2048-208895, default 2048):
磁盘分区中第1个扇区(从哪里开始) 默认
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-208895, default 208895):
磁盘分区中最后1个扇区
Last sector, +sectors or +size{K,M,G} (2048-208895, default 208895): +10M
Partition 1 of type Linux and of size 10 MiB is set
创建了分区号是1的 10MB的分区
Command (m for help): p
Disk /dev/sdb: 106 MB, 106954752 bytes, 208896 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: 0x6df46197
Device Boot Start End Blocks Id System
/dev/sdb1 2048 22527 10240 83 Linux
10MB
Command (m for help): n
Partition type:
p primary (1 primary, 0 extended, 3 free)
e extended
Select (default p): e
Partition number (2-4, default 2):
First sector (22528-208895, default 22528):
Using default value 22528
Last sector, +sectors or +size{K,M,G} (22528-208895, default 208895):
Using default value 208895
Partition 2 of type Extended and of size 91 MiB is set
Command (m for help): n
Partition type:
p primary (1 primary, 1 extended, 2 free)
l logical (numbered from 5)
Select (default p): e
Invalid partition type `e'
Command (m for help): n
Partition type:
p primary (1 primary, 1 extended, 2 free)
l logical (numbered from 5)
Select (default p): l
Adding logical partition 5
First sector (24576-208895, default 24576):
Using default value 24576
Last sector, +sectors or +size{K,M,G} (24576-208895, default 208895): +20M
Partition 5 of type Linux and of size 20 MiB is set
Command (m for help): p
Disk /dev/sdb: 106 MB, 106954752 bytes, 208896 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: 0x6df46197
Device Boot Start End Blocks Id System
/dev/sdb1 2048 22527 10240 83 Linux
/dev/sdb2 22528 208895 93184 5 Extended
/dev/sdb5 24576 65535 20480 83 Linux
创建2个分区 1个10MB的主分区 创建1个使用所有剩余空间的扩展 分区 1个20MB的逻辑分区
第1个里程碑-创建分区
Command (m for help): p
Disk /dev/sdb: 106 MB, 106954752 bytes, 208896 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: 0x6df46197
Device Boot Start End Blocks Id System
Command (m for help): n
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p):
Using default response p
Partition number (1-4, default 1):
First sector (2048-208895, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-208895, default 208895):
Using default value 208895
Partition 1 of type Linux and of size 101 MiB is set
第2个里程碑-格式化 创建文件系统 mkfs make filesystem
[root@oldboyedu59 ~]# mkfs.xfs /dev/sdb1
meta-data=/dev/sdb1 isize=512 agcount=4, agsize=6464 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=0, sparse=0
data = bsize=4096 blocks=25856, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal log bsize=4096 blocks=855, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
第3个里程碑-挂载
[root@oldboyedu59 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 99G 1.8G 97G 2% /
devtmpfs 980M 0 980M 0% /dev
tmpfs 991M 0 991M 0% /dev/shm
tmpfs 991M 9.6M 981M 1% /run
tmpfs 991M 0 991M 0% /sys/fs/cgroup
/dev/sda1 197M 105M 93M 54% /boot
tmpfs 199M 0 199M 0% /run/user/0
[root@oldboyedu59 ~]# mount /dev/sdb1 /mnt/
[root@oldboyedu59 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 99G 1.8G 97G 2% /
devtmpfs 980M 0 980M 0% /dev
tmpfs 991M 0 991M 0% /dev/shm
tmpfs 991M 9.6M 981M 1% /run
tmpfs 991M 0 991M 0% /sys/fs/cgroup
/dev/sda1 197M 105M 93M 54% /boot
tmpfs 199M 0 199M 0% /run/user/0
/dev/sdb1 98M 5.3M 93M 6% /mnt
第4个里程碑-永久挂载
#1./etc/rc.local
#2./etc/fstab
[root@oldboyedu59 ~]# cat /etc/fstab
UUID=1e827748-cc43-4b1d-8bbc-9a85c239782d / xfs defaults 0 0
UUID=29a4ef75-7502-48df-b31c-c7c10264a7c8 /boot xfs defaults 0 0
UUID=60c45f5e-c78d-41fe-aa92-93d10de6def3 swap swap defaults 0 0
第1列:UUID或设备名称 第2列 第3列 第4列 第5列 第6列
查询系统的磁盘与对应的uuid 挂载点(入口) 文件系统类型 挂载参数 是否进行备份 是否开机自动检查
[root@oldboyedu59 ~]# tail -1 /etc/fstab
/dev/sdb1 /data xfs defaults 0 0
Welcome to emergency mode 欢迎进入紧急模式/维护模式
磁盘故障或/etc/fstab
Give root password for manintenance
给出root密码进入维护模式
(或按ctrl +d 继续 )
field 列 字段 域
failed 失败
CentOS7 默认的是xfs
CentOS6 5 默认 ext系列
fdisk parted
共同 磁盘分区 磁盘分区
区别 支持2TB以内硬盘 大于2TB磁盘
支持MBR分区表 MBR GPT(支持更大的硬盘和更多的主分区)
parted (实时生效)
p print 显示磁盘信息
mktable mklabel make partition table 创建磁盘分区表 MBR GPT
mkpart make partition 创建磁盘分区
rm 删除磁盘分区
q quit 退出磁盘分区
创建1个主分区 10M
(parted) p
Error: /dev/sdc: unrecognised disk label #无法识别的
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sdc: 107MB
Sector size (logical/physical): 512B/512B
Partition Table: unknown #未知
Disk Flags:
(parted) mktable gpt
(parted) p
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sdc: 107MB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
(parted) mkpart primary 0 10
Warning: The resulting partition is not properly aligned for best performance.
Ignore/Cancel? i
(parted) p
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sdc: 107MB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
1 17.4kB 10.0MB 9983kB primary
primary 主分区
extended 扩展分区
logical 逻辑分区
partition 分区
partition table 分区表