linux-根目录添加内存
01,添加磁盘到服务器
02, 查看添加的内容
这个是新添加的
03, 创建新分区
[root@oracle01 ~]# fdisk /dev/sdb --格式化分析 Welcome to fdisk (util-linux 2.23.2). Changes will remain in memory only, until you decide to write them. Be careful before using the write command. Device does not contain a recognized partition table Building a new DOS disklabel with disk identifier 0x55166394. Command (m for help): p ---打印结果 Disk /dev/sdb: 53.7 GB, 53687091200 bytes, 104857600 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: 0x55166394 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-104857599, default 2048): Using default value 2048 Last sector, +sectors or +size{K,M,G} (2048-104857599, default 104857599): Using default value 104857599 Partition 1 of type Linux and of size 50 GiB is set Command (m for help): t ---设置格式为LVM格式 Selected partition 1 Hex code (type L to list all codes): 8e Changed type of partition 'Linux' to 'Linux LVM' Command (m for help): p Disk /dev/sdb: 53.7 GB, 53687091200 bytes, 104857600 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: 0x55166394
设备 启动 起点 终点 块数 Id 系统
Device Boot Start End Blocks Id System /dev/sdb1 2048 104857599 52427776 8e Linux LVM Command (m for help): w ---保存信息 The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks.
完成后重启下机器最好
04, 创建pV
[root@oracle01 ~]# pvcreate /dev/sdb1 创建pv Physical volume "/dev/sdb1" successfully created. (这个后面的为格式化的盘符标识)
[root@oracle01 ~]# pvdisplay ---查看pv物理卷和大小 --- Physical volume --- PV Name /dev/sda2 VG Name centos PV Size <49.00 GiB / not usable 3.00 MiB Allocatable yes (but full) PE Size 4.00 MiB Total PE 12543 Free PE 0 Allocated PE 12543 PV UUID VjyFas-6rml-bolo-Jt2V-1Nq9-U5Tm-7W7c1b "/dev/sdb1" is a new physical volume of "<50.00 GiB" --- NEW Physical volume --- PV Name /dev/sdb1 VG Name PV Size <50.00 GiB 出现一个新的就是刚刚船舰 Allocatable NO PE Size 0 Total PE 0 Free PE 0 Allocated PE 0 PV UUID xeXK3i-0XLh-WEn3-eTG8-bjGJ-Pq47-RVEgZB
05,查看vg
[root@oracle01 ~]# 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 <49.00 GiB PE Size 4.00 MiB Total PE 12543 Alloc PE / Size 12543 / <49.00 GiB Free PE / Size 0 / 0 VG UUID igaCVK-95JF-h8OF-4S9E-o4ay-u6Zq-RpCN2v
加入vg
[root@oracle01 ~]# vgextend centos /dev/sdb1
名字为上面VG的name Volume group "centos" successfully extended
[root@oracle01 ~]# 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 98.99 GiB PE Size 4.00 MiB Total PE 25342 Alloc PE / Size 12543 / <49.00 GiB Free PE / Size 12799 / <50.00 GiB ---这个就是了 VG UUID igaCVK-95JF-h8OF-4S9E-o4ay-u6Zq-RpCN2v 发现已经添加进去了
06,增加根目录空间
lvresize -L +11G /dev/mapper/centos-root 添加11G进去
添加所有的话:
lvextend /dev/centos/root /dev/sdb1
人生就像一滴水,非要落下才后悔!
--kingle