环境
名称
属性
CPU
x5650
内存
4G
磁盘
20G+4TB
这时候,我们假设服务器已经有如下东西:
- 安装好了Parted(yum install parted)
- 分区容量已经告捷,公司为服务器增加了一块4T硬盘用来增加容量!
- 除了/boot分区外,其余都为LVM 模式的扩展逻辑分区
软件安装与信息查看
首先查看软件是否安装:
[root@Candy ~]# rpm -qa | grep lvm lvm2-libs-2.02.118-2.el6.x86_64 lvm2-2.02.118-2.el6.x86_64 [root@Candy ~]# lv lvchange lvextend lvmdiskscan lvmsar lvresize lvconvert lvm lvmdump lvreduce lvs lvcreate lvmchange lvmetad lvremove lvscan lvdisplay lvmconf lvmsadc lvrename [root@Candy ~]# rpm -qa | grep parted parted-2.1-29.el6.x86_64
软件准备好后顺便查看下 VM 硬件:
[root@Candy ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/vg_candy-root 7.3G 231M 6.7G 4% / tmpfs 1.9G 0 1.9G 0% /dev/shm /dev/sda1 477M 30M 422M 7% /boot /dev/mapper/vg_candy-home 3.9G 8.0M 3.7G 1% /home /dev/mapper/vg_candy-usr 3.9G 382M 3.3G 11% /usr /dev/mapper/vg_candy-var 3.9G 63M 3.6G 2% /var [root@Candy ~]# fdisk -l Disk /dev/sda: 21.5 GB, 21474836480 bytes 255 heads, 63 sectors/track, 2610 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x0006e71c Device Boot Start End Blocks Id System /dev/sda1 * 1 64 512000 83 Linux Partition 1 does not end on cylinder boundary. /dev/sda2 64 2611 20458496 8e Linux LVM Disk /dev/sdb: 4398.0 GB, 4398046511104 bytes 255 heads, 63 sectors/track, 534698 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00000000 Disk /dev/mapper/vg_candy-root: 8061 MB, 8061452288 bytes 255 heads, 63 sectors/track, 980 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00000000 Disk /dev/mapper/vg_candy-usr: 4294 MB, 4294967296 bytes 255 heads, 63 sectors/track, 522 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00000000 Disk /dev/mapper/vg_candy-var: 4294 MB, 4294967296 bytes 255 heads, 63 sectors/track, 522 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00000000 Disk /dev/mapper/vg_candy-home: 4294 MB, 4294967296 bytes 255 heads, 63 sectors/track, 522 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00000000 [root@Candy ~]# ls /dev/sd* /dev/sda /dev/sda1 /dev/sda2 /dev/sdb
这时候我们看到,Centos 已经知道有个sdb的盘了,但是没挂载与分区。
使用Parted进行扩容前的分区
现在假设除了/boot 其余分区都满了! 我们需要先进行分区,将4T的硬盘用上(/dev/sdb).
[root@Candy ~]# parted /dev/sdb GNU Parted 2.1 使用 /dev/sdb Welcome to GNU Parted! Type 'help' to view a list of commands. (parted) mklabel 新的磁盘标签类型? gpt (parted) mkpart 分区名称? []"htmlcode">[root@Candy ~]# vgs VG #PV #LV #SN Attr VSize VFree vg_candy 1 4 0 wz--n- 19.51g 0 [root@Candy ~]# vgdisplay --- Volume group --- VG Name vg_candy System ID Format lvm2 Metadata Areas 1 Metadata Sequence No 5 VG Access read/write VG Status resizable MAX LV 0 Cur LV 4 Open LV 4 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 4994 / 19.51 GiB Free PE / Size 0 / 0 VG UUID Gcm5Ml-fc88-Xk5q-xuPC-Kj7Y-alfK-i770Gc [root@Candy ~]# lvscan ACTIVE '/dev/vg_candy/usr' [4.00 GiB] inherit ACTIVE '/dev/vg_candy/var' [4.00 GiB] inherit ACTIVE '/dev/vg_candy/home' [4.00 GiB] inherit ACTIVE '/dev/vg_candy/root' [7.51 GiB] inherit [root@Candy ~]#知道lvm卷组叫 'vg_candy'了, 我们就使用vgextend来向lvm 'vg_candy' 卷组添加成员了.
[root@Candy ~]# vgextend vag_candy /dev/sdb1 Physical volume "/dev/sdb1" successfully created Volume group "vg_candy" successfully extended现在我们再用vgs命令看一下pv个数:
[root@Candy ~]# vgs VG #PV #LV #SN Attr VSize VFree vg_candy 2 4 0 wz--n- 4.02t 4.00t大家对比未添加时的vgs是否有看到PV个数从1变为2了!
现在让我们用vgdisplay看看现在分区的容量.
[root@Candy ~]# vgdisplay --- Volume group --- VG Name vg_candy System ID Format lvm2 Metadata Areas 2 Metadata Sequence No 6 VG Access read/write VG Status resizable MAX LV 0 Cur LV 4 Open LV 4 Max PV 0 Cur PV 2 Act PV 2 VG Size 4.02 TiB PE Size 4.00 MiB Total PE 1053569 Alloc PE / Size 4994 / 19.51 GiB Free PE / Size 1048575 / 4.00 TiB VG UUID Gcm5Ml-fc88-Xk5q-xuPC-Kj7Y-alfK-i770Gc再次对比未添加的vgdiplay命令发现,FreePE 的value 从 0 / 0 变为 1048575 / 4.00 TiB . 这样说明Candy已经成功将4TB的lvm 分区添加进入到vg_candy 逻辑卷组里了。
现在我们对所有逻辑分区进行扩容前,df -h 看看有哪些分区。
[root@Candy ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/vg_candy-root 7.3G 231M 6.7G 4% / tmpfs 1.9G 0 1.9G 0% /dev/shm /dev/sda1 477M 30M 422M 7% /boot /dev/mapper/vg_candy-home 3.9G 8.0M 3.7G 1% /home /dev/mapper/vg_candy-usr 3.9G 382M 3.3G 11% /usr /dev/mapper/vg_candy-var 3.9G 63M 3.6G 2% /var现在麻烦的事已经做完了,接下来就剩下为分区进行扩容了.
为磁盘进行扩容
假设:我们需要向 这些分区都添加500G容量:
/
、/home
、/usr
、/var
[root@Candy ~]# lvextend -L +500G /dev/mapper/vg_candy-root Size of logical volume vg_candy/root changed from 7.51 GiB (1922 extents) to 507.51 GiB (129922 extents). Logical volume root successfully resized [root@Candy ~]# lvextend -L +500G /dev/mapper/vg_candy-home Size of logical volume vg_candy/home changed from 4.00 GiB (1024 extents) to 504.00 GiB (129024 extents). Logical volume home successfully resized [root@Candy ~]# lvextend -L +500G /dev/mapper/vg_candy-usr Size of logical volume vg_candy/usr changed from 4.00 GiB (1024 extents) to 504.00 GiB (129024 extents). Logical volume usr successfully resized [root@Candy ~]# lvextend -L +500G /dev/mapper/vg_candy-var Size of logical volume vg_candy/var changed from 4.00 GiB (1024 extents) to 504.00 GiB (129024 extents). Logical volume var successfully resized大家注意,这一步操作时不可逆的! 如果输入了错误的分区名字还好! 如果添加到其它分区了,就得重复N遍来缩容,比较麻烦哦! 建议大家注仔细核对上面的FileSystem. 切记切记....
提示扩容成功! 让我们再次用上述命令查看LVM信息:
[root@Candy ~]# vgs VG #PV #LV #SN Attr VSize VFree vg_candy 2 4 0 wz--n- 4.02t 2.05t [root@Candy ~]# lvscan ACTIVE '/dev/vg_candy/usr' [504.00 GiB] inherit ACTIVE '/dev/vg_candy/var' [504.00 GiB] inherit ACTIVE '/dev/vg_candy/home' [504.00 GiB] inherit ACTIVE '/dev/vg_candy/root' [507.51 GiB] inherit [root@Candy ~]# vgdisplay --- Volume group --- VG Name vg_candy System ID Format lvm2 Metadata Areas 2 Metadata Sequence No 10 VG Access read/write VG Status resizable MAX LV 0 Cur LV 4 Open LV 4 Max PV 0 Cur PV 2 Act PV 2 VG Size 4.02 TiB PE Size 4.00 MiB Total PE 1053569 Alloc PE / Size 516994 / 1.97 TiB Free PE / Size 536575 / 2.05 TiB VG UUID Gcm5Ml-fc88-Xk5q-xuPC-Kj7Y-alfK-i770Gc [root@Candy ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/vg_candy-root 7.3G 231M 6.7G 4% / tmpfs 1.9G 0 1.9G 0% /dev/shm /dev/sda1 477M 30M 422M 7% /boot /dev/mapper/vg_candy-home 3.9G 8.0M 3.7G 1% /home /dev/mapper/vg_candy-usr 3.9G 382M 3.3G 11% /usr /dev/mapper/vg_candy-var 3.9G 63M 3.6G 2% /var看到这里大家可能奇怪! 为什么df -h 还没变呢"htmlcode">
[root@Candy ~]# resize2fs /dev//mapper/vg_candy-root resize2fs 1.41.12 (17-May-2010) Filesystem at /dev//mapper/vg_candy-root is mounted on /; on-line resizing required old desc_blocks = 1, new_desc_blocks = 32 Performing an on-line resize of /dev//mapper/vg_candy-root to 133040128 (4k) blocks. The filesystem on /dev//mapper/vg_candy-root is now 133040128 blocks long. [root@Candy ~]# resize2fs /dev//mapper/vg_candy-usr resize2fs 1.41.12 (17-May-2010) Filesystem at /dev//mapper/vg_candy-usr is mounted on /usr; on-line resizing required old desc_blocks = 1, new_desc_blocks = 32 Performing an on-line resize of /dev//mapper/vg_candy-usr to 132120576 (4k) blocks. The filesystem on /dev//mapper/vg_candy-usr is now 132120576 blocks long. [root@Candy ~]# resize2fs /dev//mapper/vg_candy-var resize2fs 1.41.12 (17-May-2010) Filesystem at /dev//mapper/vg_candy-var is mounted on /var; on-line resizing required old desc_blocks = 1, new_desc_blocks = 32 Performing an on-line resize of /dev//mapper/vg_candy-var to 132120576 (4k) blocks. The filesystem on /dev//mapper/vg_candy-var is now 132120576 blocks long. [root@Candy ~]# resize2fs /dev//mapper/vg_candy-home resize2fs 1.41.12 (17-May-2010) Filesystem at /dev//mapper/vg_candy-home is mounted on /home; on-line resizing required old desc_blocks = 1, new_desc_blocks = 32 Performing an on-line resize of /dev//mapper/vg_candy-home to 132120576 (4k) blocks. The filesystem on /dev//mapper/vg_candy-home is now 132120576 blocks long. [root@Candy ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/vg_candy-root 500G 245M 474G 1% / tmpfs 1.9G 0 1.9G 0% /dev/shm /dev/sda1 477M 30M 422M 7% /boot /dev/mapper/vg_candy-home 496G 16M 471G 1% /home /dev/mapper/vg_candy-usr 496G 390M 471G 1% /usr /dev/mapper/vg_candy-var 496G 71M 471G 1% /var结束语
顺便给大家晒一张重启后系统自动挂载的图!
Linux系统还是比较聪明的. 其实重启与不重启都能使用, 只是为大家演示重启后的效果.
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。
RTX 5090要首发 性能要翻倍!三星展示GDDR7显存
三星在GTC上展示了专为下一代游戏GPU设计的GDDR7内存。
首次推出的GDDR7内存模块密度为16GB,每个模块容量为2GB。其速度预设为32 Gbps(PAM3),但也可以降至28 Gbps,以提高产量和初始阶段的整体性能和成本效益。
据三星表示,GDDR7内存的能效将提高20%,同时工作电压仅为1.1V,低于标准的1.2V。通过采用更新的封装材料和优化的电路设计,使得在高速运行时的发热量降低,GDDR7的热阻比GDDR6降低了70%。
更新动态
- 凤飞飞《我们的主题曲》飞跃制作[正版原抓WAV+CUE]
- 刘嘉亮《亮情歌2》[WAV+CUE][1G]
- 红馆40·谭咏麟《歌者恋歌浓情30年演唱会》3CD[低速原抓WAV+CUE][1.8G]
- 刘纬武《睡眠宝宝竖琴童谣 吉卜力工作室 白噪音安抚》[320K/MP3][193.25MB]
- 【轻音乐】曼托凡尼乐团《精选辑》2CD.1998[FLAC+CUE整轨]
- 邝美云《心中有爱》1989年香港DMIJP版1MTO东芝首版[WAV+CUE]
- 群星《情叹-发烧女声DSD》天籁女声发烧碟[WAV+CUE]
- 刘纬武《睡眠宝宝竖琴童谣 吉卜力工作室 白噪音安抚》[FLAC/分轨][748.03MB]
- 理想混蛋《Origin Sessions》[320K/MP3][37.47MB]
- 公馆青少年《我其实一点都不酷》[320K/MP3][78.78MB]
- 群星《情叹-发烧男声DSD》最值得珍藏的完美男声[WAV+CUE]
- 群星《国韵飘香·贵妃醉酒HQCD黑胶王》2CD[WAV]
- 卫兰《DAUGHTER》【低速原抓WAV+CUE】
- 公馆青少年《我其实一点都不酷》[FLAC/分轨][398.22MB]
- ZWEI《迟暮的花 (Explicit)》[320K/MP3][57.16MB]