Linux下使用LVM动态扩展磁盘空间_第1页
Linux下使用LVM动态扩展磁盘空间_第2页
Linux下使用LVM动态扩展磁盘空间_第3页
全文预览已结束

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、1.查看磁盘信息: rootlg-centos # df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/vg_lgcentos-lv_root 16G 9.8G 5.4G 65% / tmpfs 948M 72K 948M 1% /dev/shm /dev/sda1 485M 61M 399M 14% /boot rootlg-centos # fdisk -l Disk /dev/sda: 21.5 GB, 21474836480 bytes 255 heads, 63 sectors/track, 2610 cylind

2、ers 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: 0x000402bd Device Boot Start End Blocks Id System /dev/sda1 * 1 64 512000 83 Linux Partition 1 does not end on cylinder boundary

3、. /dev/sda2 64 2611 20458496 8e Linux LVM Disk /dev/sdb: 32.2 GB, 32212254720 bytes 255 heads, 63 sectors/track, 3916 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: 0x00

4、000000 Disk /dev/mapper/vg_lgcentos-lv_root: 16.7 GB, 166* bytes 255 heads, 63 sectors/track, 2028 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/ma

5、pper/vg_lgcentos-lv_swap: 4261 MB, 4261412864 bytes 255 heads, 63 sectors/track, 518 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 2.给/dev/sdb添加分区/dev/sdb1 2

6、.1 fdisk /dev/sdb m 查看帮助 n 添加新分区 t 修改分区类型为:8e=>Linux LVM p 查看分区 w 写入分区表并退出 q 不保存分区表并退出 3.扩展逻辑卷/dev/mapper/vg_lgcentos-lv_root的大小 3.1输入lvm,进入LVM管理器(此步骤可省略,直接进行下面的操作,效果完全一样 3.2将分区转换为物理卷,此步骤可省略:当将分区直接添加到卷组时,LVM会自动将分区转换为物理卷组。这里跳过这一步 lvm> pvcreate /dev/sdb1 Physical volume "/dev/sdb1" suc

7、cessfully created 相反过程:将物理卷还原为普通分区 lvm> pvremove /dev/sdb1 Labels on physical volume "/dev/sdb1" successfully wiped 3.3将物理卷添加到现有卷组 lvm> vgextend vg_lgcentos /dev/sdb1 No physical volume label read from /dev/sdb1 Physical volume "/dev/sdb1" successfully created Volume group

8、"vg_lgcentos" successfully extended 相反过程,将物理卷移除卷组 lvm> vgreduce vg_lgcentos /dev/sdb1 Removed "/dev/sdb1" from volume group "vg_lgcentos" 3.4使用pvscan命令查看所有物理卷及所属分组 lvm> pvscan PV /dev/sda2 VG vg_lgcentos lvm2 19.51 GiB / 0 free PV /dev/sdb1 VG vg_lgcentos lvm2 30.

9、00 GiB / 30.00 GiB free Total: 2 49.50 GiB / in use: 2 49.50 GiB / in no VG: 0 0 3.5查看所有逻辑卷 lvm> lvscan ACTIVE '/dev/vg_lgcentos/lv_root' 15.54 GiB inherit ACTIVE '/dev/vg_lgcentos/lv_swap' 3.97 GiB inherit 3.6扩展逻辑卷大小 lvm> lvextend -L +30G /dev/vg_lgcentos/lv_root Extending log

10、ical volume lv_root to 45.54 GiB Insufficient free space: 7680 extents needed, but only 7679 available 注意:上面虽然显示物理卷/dev/sdb1有30.00 GiB空闲,但是这里不能全部使用,29.99G是可以的. lvm> lvextend -L +29.99G /dev/vg_lgcentos/lv_root Rounding size to boundary between physical extents: 29.99 GiB Extending logical volume

11、lv_root to 45.54 GiB Logical volume lv_root successfully resized 相反过程:减小逻辑卷的大小 lvm> lvreduce -L -7697 /dev/vg_lgcentos/lv_root Rounding size to boundary between physical extents: 7.52 GiB WARNING: Reducing active and open logical volume to 15.54 GiB THIS MAY DESTROY YOUR DATA (filesystem etc. Do

12、you really want to reduce lv_root? y/n: y Reducing logical volume lv_root to 15.54 GiB Logical volume lv_root successfully resized 3.7查看物理卷和逻辑卷 lvm> lvscan ACTIVE '/dev/vg_lgcentos/lv_root' 45.54 GiB inherit ACTIVE '/dev/vg_lgcentos/lv_swap' 3.97 GiB inherit lvm> pvscan PV /dev

13、/sda2 VG vg_lgcentos lvm2 19.51 GiB / 0 free PV /dev/sdb1 VG vg_lgcentos lvm2 30.00 GiB / 0 free Total: 2 49.50 GiB / in use: 2 49.50 GiB / in no VG: 0 0 3.8虽然这里显示已经将物理卷的空间添加到了逻辑卷上,但是使用df -h命令查看逻辑卷还是没有变化,fdisk -l缺已经生效了,因为还差最后一步激活 rootlg-centos # df -h Filesystem Size Used Avail Use% Mounted on /dev/

14、mapper/vg_lgcentos-lv_root 16G 9.8G 5.4G 65% / tmpfs 948M 72K 948M 1% /dev/shm /dev/sda1 485M 61M 399M 14% /boot rootlg-centos # 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/physic

15、al: 512 bytes / 512 bytes I/O size (minimum/optimal: 512 bytes / 512 bytes Disk identifier: 0x000402bd 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: 32.2 GB, 32212254720 bytes 255 heads, 63 sectors/track, 3916 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physic

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论