fdisk -l
Disk /dev/sda: 85.9 GB, 85899345920 bytes, 167772160 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: 0x000bea13
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 2099199 1048576 83 Linux
/dev/sda2 2099200 83886079 40893440 8e Linux LVM
Disk /dev/mapper/centos-root: 39.7 GB, 39720058880 bytes, 77578240
#分区大小
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 /dev/mapper/centos-swap: 2147 MB, 2147483648 bytes, 4194304 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
我这里默认两个sda1和sda2
fdisk /dev/sda
[root@code ~]# fdisk /dev/sda
欢迎使用 fdisk (util-linux 2.23.2)。
更改将停留在内存中,直到您决定将更改写入磁盘。
使用写入命令前请三思。
命令(输入 m 获取帮助):p
磁盘 /dev/sda:64.4 GB, 64424509440 字节,125829120 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘标签类型:dos
磁盘标识符:0x000a89c1
设备 Boot Start End Blocks Id System
/dev/sda1 * 2048 2099199 1048576 83 Linux
/dev/sda2 2099200 41943039 19921920 8e Linux LVM
命令(输入 m 获取帮助):n
Partition type:
p primary (2 primary, 0 extended, 2 free)
e extended
Select (default p): p
分区号 (3,4,默认 3):3
起始 扇区 (41943040-125829119,默认为 41943040):
将使用默认值 41943040
Last 扇区, +扇区 or +size{K,M,G} (41943040-125829119,默认为 125829119):
将使用默认值 125829119
分区 3 已设置为 Linux 类型,大小设为 40 GiB
命令(输入 m 获取帮助):t
分区号 (1-3,默认 3):3
Hex 代码(输入 L 列出所有代码):8e
已将分区“Linux”的类型更改为“Linux LVM”
命令(输入 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@code ~]#
就会看到新的分区sda3
[root@code ~]# fdisk -l
磁盘 /dev/sda:64.4 GB, 64424509440 字节,125829120 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘标签类型:dos
磁盘标识符:0x000a89c1
设备 Boot Start End Blocks Id System
/dev/sda1 * 2048 2099199 1048576 83 Linux
/dev/sda2 2099200 41943039 19921920 8e Linux LVM
/dev/sda3 41943040 125829119 41943040 8e Linux LVM
磁盘 /dev/mapper/cl-root:18.2 GB, 18249416704 字节,35643392 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘 /dev/mapper/cl-swap:2147 MB, 2147483648 字节,4194304 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
mkfs.ext3 /dev/sda3一直挂载的分区是sda3;#这个sda3根据你的新分区修改
lvm //进入lvm管理
lvm>pvcreate /dev/sda3
lvm>vgextend centos /dev/sda3 //将初始化过的分区加入到虚拟卷组centos
lvm>vgdisplay -v
lvm>lvextend -l+10239 /dev/mapper/centos-root //这里的centos-root也是vgdisplay -v中有,选择你的
lvm>pvdisplay //查看卷容量
lvm>quit
具体操作
[root@code ~]# 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> vgextend cl /dev/sda3
Volume group "cl" successfully extended
lvm> vgdisplay -v
--- Volume group ---
VG Name cl
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 58.99 GiB
PE Size 4.00 MiB
Total PE 15102
Alloc PE / Size 4863 / 19.00 GiB
Free PE / Size 10239 / 40.00 GiB
VG UUID on4380-dNuw-urE1-TJDY-35tA-4vfc-GpyR2G
--- Logical volume ---
LV Path /dev/cl/swap
LV Name swap
VG Name cl
LV UUID ZsoXDE-3M6U-G8y4-ciui-t4ZU-369P-LGDrfW
LV Write Access read/write
LV Creation host, time code, 2018-08-28 22:25:06 +0800
LV Status available
# open 2
LV Size 2.00 GiB
Current LE 512
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 253:1
--- Logical volume ---
LV Path /dev/cl/root
LV Name root
VG Name cl
LV UUID 6uJJVw-T2Ki-XTRF-ARJA-EkVl-3qz0-l86XMp
LV Write Access read/write
LV Creation host, time code, 2018-08-28 22:25:06 +0800
LV Status available
# open 1
LV Size 17.00 GiB
Current LE 4351
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 253:0
--- Physical volumes ---
PV Name /dev/sda2
PV UUID iFb3r2-umXf-IfjS-LCvb-pldM-x3Me-BHnhkJ
PV Status allocatable
Total PE / Free PE 4863 / 0
PV Name /dev/sda3
PV UUID WpJpn3-0ZO0-n52O-yLOo-I3Ki-f5SU-SQCKFY
PV Status allocatable
Total PE / Free PE 10239 / 10239
lvm> lvextend -l+1298 /dev/mapper/cl-root
Size of logical volume cl/root changed from 17.00 GiB (4351 extents) to 22.07 GiB (5649 extents).
Logical volume cl/root successfully resized.
lvm> vgdisplay -v
--- Volume group ---
VG Name cl
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 58.99 GiB
PE Size 4.00 MiB
Total PE 15102
Alloc PE / Size 6161 / 24.07 GiB
Free PE / Size 8941 / 34.93 GiB
VG UUID on4380-dNuw-urE1-TJDY-35tA-4vfc-GpyR2G
--- Logical volume ---
LV Path /dev/cl/swap
LV Name swap
VG Name cl
LV UUID ZsoXDE-3M6U-G8y4-ciui-t4ZU-369P-LGDrfW
LV Write Access read/write
LV Creation host, time code, 2018-08-28 22:25:06 +0800
LV Status available
# open 2
LV Size 2.00 GiB
Current LE 512
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 253:1
--- Logical volume ---
LV Path /dev/cl/root
LV Name root
VG Name cl
LV UUID 6uJJVw-T2Ki-XTRF-ARJA-EkVl-3qz0-l86XMp
LV Write Access read/write
LV Creation host, time code, 2018-08-28 22:25:06 +0800
LV Status available
# open 1
LV Size 22.07 GiB
Current LE 5649
Segments 2
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 253:0
--- Physical volumes ---
PV Name /dev/sda2
PV UUID iFb3r2-umXf-IfjS-LCvb-pldM-x3Me-BHnhkJ
PV Status allocatable
Total PE / Free PE 4863 / 0
PV Name /dev/sda3
PV UUID WpJpn3-0ZO0-n52O-yLOo-I3Ki-f5SU-SQCKFY
PV Status allocatable
Total PE / Free PE 10239 / 8941
lvm> lvextend -l+8941 /dev/mapper/cl-root
Size of logical volume cl/root changed from 22.07 GiB (5649 extents) to 56.99 GiB (14590 extents).
Logical volume cl/root successfully resized.
lvm> pvdisplay
--- Physical volume ---
PV Name /dev/sda2
VG Name cl
PV Size 19.00 GiB / not usable 3.00 MiB
Allocatable yes (but full)
PE Size 4.00 MiB
Total PE 4863
Free PE 0
Allocated PE 4863
PV UUID iFb3r2-umXf-IfjS-LCvb-pldM-x3Me-BHnhkJ
--- Physical volume ---
PV Name /dev/sda3
VG Name cl
PV Size 40.00 GiB / not usable 4.00 MiB
Allocatable yes (but full)
PE Size 4.00 MiB
Total PE 10239
Free PE 0
Allocated PE 10239
PV UUID WpJpn3-0ZO0-n52O-yLOo-I3Ki-f5SU-SQCKFY
lvm> quit
Exiting.
[root@code ~]#
fdisk -l #展示所有磁盘情况,
fdisk /dev/sdb
Command (m for help): d
--输入删除指令
Partition number (1-7): 1 #这里选择你要删除第几个分区
--输入删除的分区号
Command (m for help): p #打印分区表
Command (m for help): w #保存操作
--保存退出
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
fdisk -l #展示所有磁盘情况,可以看删除成功没
#Centos安装Oracle时遇到的磁盘空间不足问题,需要扩充磁盘,本文学习笔记,并非原创