摘要:
[root@localhost ~]# fdisk -l 查看磁盘信息[root@localhost ~]# fdisk /dev/sdb 给磁...
[root@localhost ~]# fdisk -l 查看磁盘信息
[root@localhost ~]# fdisk /dev/sdb 给磁盘分区
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition
g create a new empty GPT partition table
G create an IRIX (SGI) partition table
l list known partition types
m print this menu
n add a new partition
o create a new empty DOS partition table
p print the partition table
q quit without saving changes
s create a new empty Sun disklabel
t change a partition's system id
u change display/entry units
v verify the partition table
w write table to disk and exit
x extra functionality (experts only)
n p w d 比较常用
Command (m for help): n 输入n
Partition type:
p primary (1 primary, 0 extended, 3 free) 主分区
e extended 扩展分区
分区最多只能分四个主分区
Select (default p): p 输入p选择主分区
Partition number (1-4, default 1): 设置分区号
First sector (2048-41943039, default 2048): 默认分区从2048开始
Last sector, +sectors or +size{K,M,G} (2048-41943039, default 41943039): 设置分区大小,默认全部 如需指定大小可以用+2G 就是分2G的意思
Partition 1 of type Linux and of size 2 GiB is set
分了四个区后再想分会提示如下
If you want to create more than four partitions, you must replace a
primary partition with an extended partition first.
Command (m for help): d 删除分区
Partition number (1-4, default 4): 默认是从第四个开始删除
输错了可以ctrl+u 清空或者ctrl+back space 删除一个光标
Extended 扩展分区 id是83标准分区 5是扩展分区
删除一个逻辑分区,他的逻辑号是不会空的,比如你删除第5个分区,那么第6个分区就会变成第五个分区
q 退出再重新进入的话就会发现刚才的分区没有了
逻辑分区有个特点是从5开始
[root@localhost ~]# cat /etc/filesystems 查看支持什么文件格式
xfs是centos7系统默认的文件系统格式
mke2fs
-t 指定格式化什么格式的系统
-b 指定快大小
用法mke2fs -t ext4 -b 2048 /dev/sdb1
mkfs.ext4 ==mke2fs -t ext4
# mkfs.xfs -f /dev/sdb1 格式化成xfs的用法
# blkid /dev/sdb1
/dev/sdb1: UUID="8892c644-ec71-4edf-8044-a751e95f0629" TYPE="xfs" 查看为挂载分区文件什么系统
# mke2fs -m 修改指定预留空间大小
默认4个快对应一个inodes 一个快4kb
# mke2fs -i 指定几个快对应一个inodes
不分区也是可以直接格式化的
[root@localhost ~]# mount /dev/sdb /home
[root@localhost ~]# mount
umonut /dev/vdb 必须在磁盘外才能卸载不然会提示繁忙
umount -l 可以直接在磁盘里就卸载,懒人模式
mount -o ro 吧一个分区挂载为只读的
普通用户无法挂载磁盘
/etc/fstab 系统启动挂载什么分区都是有这个文件来决定的
第一列设备符号可以uid也可以符号,第二列挂载点,第三列文件格式,第四列按照默认的,最后一列设置优先级别
写法如图,不想检测就为0
也可以用uid挂载
[root@localhost ~]# blkid /dev/sdb
/dev/sdb: UUID="2b1b4b12-76f9-4650-b713-c571c71139f7" TYPE="ext4"
# mount UUID="2b1b4b12-76f9-4650-b713-c571c71139f7" /home