因为要安装oracle11g的docker版本,空间不够,所以增加10G空间
进入linux系统
df -h发现跟原来一样没有增加,需要进行操作
按下面操作,主要是fdisk /dev/sda
[root@localhost ~]# fdisk /dev/sda
欢迎使用 fdisk (util-linux 2.23.2)。
更改将停留在内存中,直到您决定将更改写入磁盘。
使用写入命令前请三思。
命令(输入 m 获取帮助):p
磁盘 /dev/sda:32.2 GB, 32212254720 字节,62914560 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘标签类型:dos
磁盘标识符:0x000a1c7a
设备 Boot Start End Blocks Id System
/dev/sda1 * 2048 1026047 512000 83 Linux
/dev/sda2 1026048 41943039 20458496 8e Linux LVM
命令(输入 m 获取帮助):n
Partition type:
p primary (2 primary, 0 extended, 2 free)
e extended
Select (default p): p
分区号 (3,4,默认 3):
起始 扇区 (41943040-62914559,默认为 41943040):
将使用默认值 41943040
Last 扇区, +扇区 or +size{K,M,G} (41943040-62914559,默认为 62914559):
将使用默认值 62914559
分区 3 已设置为 Linux 类型,大小设为 10 GiB
命令(输入 m 获取帮助):w
The partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: Re-reading the partition table failed with error 16: 设备或资源忙.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
正在同步磁盘。
[root@localhost ~]#
这里需要重启机器了 shutdown -Fr now 这步很重要,否则mkfs.ext3 /dev/sda3不认识
下面进行格式化这个盘
[root@localhost /]# mkfs.ext3 /dev/sda3
mke2fs 1.42.9 (28-Dec-2013)
文件系统标签=
OS type: Linux
块大小=4096 (log=2)
分块大小=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
655360 inodes, 2621440 blocks
131072 blocks (5.00%) reserved for the super user
第一个数据块=0
Maximum filesystem blocks=2684354560
80 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632
Allocating group tables: 完成
正在写入inode表: 完成
Creating journal (32768 blocks): 完成
Writing superblocks and filesystem accounting information: 完成
[root@localhost /]#
下面增加卷空间
[root@localhost /]# lvm
lvm> pvcreate /dev/sda3
WARNING: ext3 signature detected on /dev/sda3 at offset 1080. Wipe it? [y/n]: y
Wiping ext3 signature on /dev/sda3.
Physical volume "/dev/sda3" successfully created
lvm> vgdisplay
--- Volume group ---
VG Name centos
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 3
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV 2
Max PV 0
Cur PV 1
Act PV 1
VG Size 19.51 GiB
PE Size 4.00 MiB
Total PE 4994
Alloc PE / Size 4984 / 19.47 GiB
Free PE / Size 10 / 40.00 MiB
VG UUID tC2r01-W0pk-ZNCJ-HRuG-RmBN-yqpx-kEXnAz
lvm> vgextend centos /dev/sda3
Volume group "centos" successfully extended
lvm> vgdisplay
--- Volume group ---
VG Name centos
System ID
Format lvm2
Metadata Areas 2
Metadata Sequence No 4
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV 2
Max PV 0
Cur PV 2
Act PV 2
VG Size 29.50 GiB
PE Size 4.00 MiB
Total PE 7553
Alloc PE / Size 4984 / 19.47 GiB
Free PE / Size 2569 / 10.04 GiB
VG UUID tC2r01-W0pk-ZNCJ-HRuG-RmBN-yqpx-kEXnAz
lvm> lvextend -l+2569 /dev/mapper/centos-root
Size of logical volume centos/root changed from 17.47 GiB (4472 extents) to 27.50 GiB (7041 extents).
Logical volume root successfully resized.
lvm> vgdisplay
--- Volume group ---
VG Name centos
System ID
Format lvm2
Metadata Areas 2
Metadata Sequence No 5
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV 2
Max PV 0
Cur PV 2
Act PV 2
VG Size 29.50 GiB
PE Size 4.00 MiB
Total PE 7553
Alloc PE / Size 7553 / 29.50 GiB
Free PE / Size 0 / 0
VG UUID tC2r01-W0pk-ZNCJ-HRuG-RmBN-yqpx-kEXnAz
lvm> pvdisplay
--- Physical volume ---
PV Name /dev/sda2
VG Name centos
PV Size 19.51 GiB / not usable 3.00 MiB
Allocatable yes (but full)
PE Size 4.00 MiB
Total PE 4994
Free PE 0
Allocated PE 4994
PV UUID Q8FFNH-5sxK-gPFg-1cTe-yHvG-iy3i-yuS3qq
--- Physical volume ---
PV Name /dev/sda3
VG Name centos
PV Size 10.00 GiB / not usable 4.00 MiB
Allocatable yes (but full)
PE Size 4.00 MiB
Total PE 2559
Free PE 0
Allocated PE 2559
PV UUID D4mYQF-bFZO-eyMH-VMXk-MoTV-O18G-CkE9Ew
lvm> quit
Exiting.
[root@localhost /]#
以上只是卷扩容了,下面是文件系统的真正扩容,输入以下命令:
[root@localhost /]# resize2fs /dev/mapper/centos-root
resize2fs 1.42.9 (28-Dec-2013)
resize2fs: Bad magic number in super-block 当尝试打开 /dev/mapper/centos-root 时
找不到有效的文件系统超级块.
因为我的centos7的某些分区用的是xfs的文件系统(使用df -T查看即可知道)
[root@localhost /]# df -T
文件系统 类型 1K-块 已用 可用 已用% 挂载点
/dev/mapper/centos-root xfs 18307072 12803868 5503204 70% /
devtmpfs devtmpfs 1923032 0 1923032 0% /dev
tmpfs tmpfs 1933472 0 1933472 0% /dev/shm
tmpfs tmpfs 1933472 9068 1924404 1% /run
tmpfs tmpfs 1933472 0 1933472 0% /sys/fs/cgroup
/dev/sda1 xfs 508588 127132 381456 25% /boot
overlay overlay 18307072 12803868 5503204 70% /var/lib/docker/overlay2/4155e9f83900ed0659abb8a0012394d70a18616680b663a9579fa2e843953dd8/merged
overlay overlay 18307072 12803868 5503204 70% /var/lib/docker/overlay2/c25966fad93283903b6c306ab8ca297b21b3543bd854d71ace80d36ec5794dcf/merged
shm tmpfs 65536 0 65536 0% /var/lib/docker/containers/ce140b6e96769451ede69837486a9161a219a2a17b90153615bb3e5e5ce2847b/shm
shm tmpfs 65536 0 65536 0% /var/lib/docker/containers/21492a3d8488b5267ebc5649388662729ea4a10fc417891cf00230782e937b52/shm
tmpfs tmpfs 386696 0 386696 0% /run/user/0
将resize2fs替换为xfs_growfs,重新执行一遍即可,如下:
[root@localhost /]# xfs_growfs /dev/mapper/centos-root
meta-data=/dev/mapper/centos-root isize=256 agcount=4, agsize=1144832 blks
= sectsz=512 attr=2, projid32bit=1
= crc=0 finobt=0
data = bsize=4096 blocks=4579328, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=0
log =internal bsize=4096 blocks=2560, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
data blocks changed from 4579328 to 7209984
[root@localhost /]# df -h
文件系统 容量 已用 可用 已用% 挂载点
/dev/mapper/centos-root 28G 13G 16G 45% /
devtmpfs 1.9G 0 1.9G 0% /dev
tmpfs 1.9G 0 1.9G 0% /dev/shm
tmpfs 1.9G 8.9M 1.9G 1% /run
tmpfs 1.9G 0 1.9G 0% /sys/fs/cgroup
/dev/sda1 497M 125M 373M 25% /boot
overlay 28G 13G 16G 45% /var/lib/docker/overlay2/4155e9f83900ed0659abb8a0012394d70a18616680b663a9579fa2e843953dd8/merged
overlay 28G 13G 16G 45% /var/lib/docker/overlay2/c25966fad93283903b6c306ab8ca297b21b3543bd854d71ace80d36ec5794dcf/merged
shm 64M 0 64M 0% /var/lib/docker/containers/ce140b6e96769451ede69837486a9161a219a2a17b90153615bb3e5e5ce2847b/shm
shm 64M 0 64M 0% /var/lib/docker/containers/21492a3d8488b5267ebc5649388662729ea4a10fc417891cf00230782e937b52/shm
tmpfs 378M 0 378M 0% /run/user/0
[root@localhost /]#
标签:PV,虚拟机,0%,10G,dev,centos7,PE,root,Size From: https://blog.51cto.com/u_15070324/6088379