Linux之磁盘扩容系列
2020-06-14 本文已影响0人
杀死一只喵
[root@jenkins-test ~]# fdisk -l
磁盘 /dev/sda:53.7 GB, 53687091200 字节,104857600 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘标签类型:dos
磁盘标识符:0x00073f58
设备 Boot Start (启动) End (终止) Blocks (容量) Id System
/dev/sda1 * 2048 411647 204800 83 Linux
/dev/sda2 411648 8800255 4194304 82 Linux swap / Solaris
/dev/sda3 8800256 104857599 48028672 83 Linux
-
新添加一块20G 的硬盘
image.png -
执行 fdisk -l 就会有一块/dev/sdb2 的磁盘
image.png - 给/dev/sdb 进行分区
fdisk创建磁盘分区表 分区
image.pngp print 显示分区信息
n new 创建分区
d delete 删除分区
w write 保存退出
q quit 不保存退出
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p (创建主分区)
Partition number (1-4): 1
First sector (2048-417791, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-417791, default 417791): +10M
Command (m for help): n
Command action
e extended
p primary partition (1-4)
e ) (扩展分区)
Partition number (1-4): 2
First sector (22528-417791, default 22528):
Using default value 22528
Last sector, +sectors or +size{K,M,G} (22528-417791, default 417791):
Using default value 417791
Command (m for help): n
Command action
l logical (5 or over)
p primary partition (1-4)
l (逻辑分区)
First sector (24576-417791, default 24576):
Using default value 24576
Last sector, +sectors or +size{K,M,G} (24576-417791, default 417791): +50M
- 告诉系统磁盘空间变了
partprobe /dev/sdb
- 格式化磁盘分区
mkfs.ext4 /dev/sdb1
- 关闭磁盘分区的自我检查功能
tune2fs -i 0 -c 0 /dev/sdb1
- 挂载磁盘
7.1 临时挂载
mount /dev/sdb1 /var/lib/docker
7.2 永久挂载、开机自动挂载
7.2.1 在/etc/rc.local加入
/bin/mount /dev/sdb1 /var/lib/docker
7.2.2
[root@jenkins-test ~]# vi /etc/fstab
#
# /etc/fstab
# Created by anaconda on Wed Jul 17 14:07:03 2019
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
UUID=0254aef3-8ca4-44e2-953e-f38eca08c942 / xfs defaults 0 0
UUID=9b9a3465-d6c0-4549-9cd6-07704cef1603 /boot xfs defaults 0 0
UUID=d6770cd1-61de-4e8a-af92-f711d33ca4f1 swap swap defaults 0 0
/dev/sdb1 /var/lib/docker ext4 defaults 0 0