默认安装的CentOS6.3操作系统,使用lvm分区。root挂载了50G,home挂载了1.5T。

由于需求要求,现在需要把home的1.5T全部移动到root下。

使用archiso启动,查看lvm信息如下:

root@archiso ~ # pvdisplay
--- Physical volume ---
PV Name /dev/sdb2
VG Name vg_t185
PV Size 931.02 GiB / not usable 4.00 MiB
Allocatable yes (but full)
PE Size 4.00 MiB
Total PE
Free PE
Allocated PE
PV UUID cK8ZW2-Mtcv-ry1H-7WU0-kLeD-i0M4-jipmh8
root@archiso ~ # lvdisplay
--- Logical volume ---
LV Path /dev/vg_t185/lv_root
LV Name lv_root
VG Name vg_t185
LV UUID 7IU9S2-S0cY-WG6L-7yLK-sWle-Ogtg-3bPC5y
LV Write Access read/write
LV Creation host, time T185, -- :: +
LV Status available
# open
LV Size 50.00 GiB
Current LE
Segments
Allocation inherit
Read ahead sectors auto
- currently set to
Block device : --- Logical volume ---
LV Path /dev/vg_t185/lv_home
LV Name lv_home
VG Name vg_t185
LV UUID RhQnwT-Ol18-ERl3-d2oD-O63V-IzWq-f1eTxB
LV Write Access read/write
LV Creation host, time T185, -- :: +
LV Status available
# open
LV Size 849.51 GiB
Current LE
Segments
Allocation inherit
Read ahead sectors auto
- currently set to
Block device : --- Logical volume ---
LV Path /dev/vg_t185/lv_swap
LV Name lv_swap
VG Name vg_t185
LV UUID 5noJ0H-Sz1h-Kdo0-3elo-lhLw-HcRv-8dB8GY
LV Write Access read/write
LV Creation host, time T185, -- :: +
LV Status available
# open
LV Size 31.51 GiB
Current LE
Segments
Allocation inherit
Read ahead sectors auto
- currently set to
Block device :
root@archiso ~ # vgdisplay
--- Volume group ---
VG Name vg_t185
System ID
Format lvm2
Metadata Areas
Metadata Sequence No
VG Access read/write
VG Status resizable
MAX LV
Cur LV
Open LV
Max PV
Cur PV
Act PV
VG Size 931.02 GiB
PE Size 4.00 MiB
Total PE
Alloc PE / Size / 931.02 GiB
Free PE / Size /
VG UUID DKq4iJ-p00S-PMji-zkgc-nip2-Y7gY-extOPT

当前状态是一个pv sdb2, 一个vg vg_t185, 三个lv  lv_root, lv_swap, lv_home 。

思路就是: 1.  删掉lv_home.  2.  把分区添加到lv_root.  3.  在root下创建home目录。 4.  修改fstab

删除:

root@archiso ~ # lvremove vg_t185/lv_home
Do you really want to remove active logical volume vg_t185/lv_home? [y/n]: y
Logical volume "lv_home" successfully removed
root@archiso ~ #
root@archiso ~ # lvdisplay
--- Logical volume ---
LV Path /dev/vg_t185/lv_root
LV Name lv_root
VG Name vg_t185
LV UUID 7IU9S2-S0cY-WG6L-7yLK-sWle-Ogtg-3bPC5y
LV Write Access read/write
LV Creation host, time T185, -- :: +
LV Status available
# open
LV Size 50.00 GiB
Current LE
Segments
Allocation inherit
Read ahead sectors auto
- currently set to
Block device : --- Logical volume ---
LV Path /dev/vg_t185/lv_swap
LV Name lv_swap
VG Name vg_t185
LV UUID 5noJ0H-Sz1h-Kdo0-3elo-lhLw-HcRv-8dB8GY
LV Write Access read/write
LV Creation host, time T185, -- :: +
LV Status available
# open
LV Size 31.51 GiB
Current LE
Segments
Allocation inherit
Read ahead sectors auto
- currently set to
Block device : root@archiso ~ # vgdisplay
--- Volume group ---
VG Name vg_t185
System ID
Format lvm2
Metadata Areas
Metadata Sequence No
VG Access read/write
VG Status resizable
MAX LV
Cur LV
Open LV
Max PV
Cur PV
Act PV
VG Size 931.02 GiB
PE Size 4.00 MiB
Total PE
Alloc PE / Size / 81.51 GiB
Free PE / Size / 849.51 GiB
VG UUID DKq4iJ-p00S-PMji-zkgc-nip2-Y7gY-extOPT root@archiso ~ #

扩充:

root@archiso ~ # lvextend -l +%FREE -t /dev/vg_t185/lv_root /dev/sdb2
TEST MODE: Metadata will NOT be updated and volumes will not be (de)activated.
Size of logical volume vg_t185/lv_root changed from 50.00 GiB ( extents) to 899.51 GiB ( extents).
Logical volume lv_root successfully resized.
root@archiso ~ # lvextend -l +%FREE /dev/vg_t185/lv_root /dev/sdb2
Size of logical volume vg_t185/lv_root changed from 50.00 GiB ( extents) to 899.51 GiB ( extents).
Logical volume lv_root successfully resized.
root@archiso ~ #
root@archiso ~ # lvdisplay
--- Logical volume ---
LV Path /dev/vg_t185/lv_root
LV Name lv_root
VG Name vg_t185
LV UUID 7IU9S2-S0cY-WG6L-7yLK-sWle-Ogtg-3bPC5y
LV Write Access read/write
LV Creation host, time T185, -- :: +
LV Status available
# open
LV Size 899.51 GiB
Current LE
Segments
Allocation inherit
Read ahead sectors auto
- currently set to
Block device : --- Logical volume ---
LV Path /dev/vg_t185/lv_swap
LV Name lv_swap
VG Name vg_t185
LV UUID 5noJ0H-Sz1h-Kdo0-3elo-lhLw-HcRv-8dB8GY
LV Write Access read/write
LV Creation host, time T185, -- :: +
LV Status available
# open
LV Size 31.51 GiB
Current LE
Segments
Allocation inherit
Read ahead sectors auto
- currently set to
Block device : root@archiso ~ #

修改fstab

 root@archiso ~/mnt # diff etc/fstab fstab.bak
10a11
> /dev/mapper/vg_t185-lv_home /home ext4 defaults
root@archiso ~/mnt #

reboot

二, 新增一块硬盘来扩充。

为硬盘创建分区:

parted /dev/vdb
mklabel gpt
mkpart primary 1MiB %

创建物理卷

pvcreate /dev/vdb1

将新卷加入卷组

vgextend vg_t209 /dev/vdb1

逻辑卷扩充

lvextend -l +%FREE -t /dev/vg_t209/lv_root /dev/vdb1
lvextend -l +100%FREE /dev/vg_t209/lv_root /dev/vdb1

这是,在文件系统里是看不见大小变化的。

我用的是ext4文件系统,然后还应该resize ext4, 使用如下方法:

https://pubmem.wordpress.com/2010/09/16/how-to-resize-lvm-logical-volumes-with-ext4-as-filesystem/

resize2fs -f /dev/mapper/vg_t209-lv_root

[administrative][lvm] lvm 分区修改的更多相关文章

  1. centos7 lvm合并分区脚本初探-linux性能测试 -centos7修改网卡名字-jdk环境安装脚本-关键字查询文件-批量添加用户

    1.#!/bin/bash lvmdiskscan | grep centos > /root/a.txt a=`sed -n '1p' /root/a.txt` b=`sed -n '2p' ...

  2. Linux LVM 逻辑分区

    LVM是 Logical Volume Manager(逻辑卷管理)的简写,它是Linux环境下对磁盘分区进行管理的一种机制,它由Heinz Mauelshagen在Linux 2.4内核上实现.普通 ...

  3. Linux中利用LVM实现分区动态扩容

    使用命令: pvscan vgdisplay lvdisplay vgremove vgextend lvresize -l resize2fs 从物理磁盘,创建lvm逻辑分区 pvcreate vg ...

  4. LVM逻辑分区的优缺点与步骤

    一.LVM简介 1. 什么是LVM? LVM是 Logical Volume Manager(逻辑卷管理)的简写 2. 为什么使用LVM? LVM通常用于装备大量磁盘的系统,但它同样适于仅有一.两块硬 ...

  5. Linux:lvm磁盘分区,动态扩容

    一.lvm磁盘分区: 1,查看新增的磁盘,需要使用root权限 fdisk -l 看到有一个新增的100G磁盘 2,对磁盘进行分区 fdisk /dev/xvdb 1,输入:n 表示创建一个新的分区( ...

  6. cinder /etc/lvm/lvm.conf 注意点

    在cinder节点,cinder-volume使用的磁盘(/dev/sdb),需要在/etc/lvm/lvm.conf中配置: devices {...filter = [ "a/sdb/& ...

  7. Linux 磁盘分区修改与管理

    --Linux 磁盘分区修改与管理 -----------------------------2014/03/05 1. 目的,将磁盘卷/dev/cciss/c0d0p8修改成新的用途. 原: /de ...

  8. linux4.10.8 内核移植(二)---初步裁剪、分区修改和文件系统

    一.初步裁剪 在内核根目录下 执行: make menuconfig 1.1 system type裁剪 选择 SAMSUNG S3C24XX SoCs Support 进入其中,这里是配置我们的单板 ...

  9. CentOS下使用LVM进行分区(转)

    说明:为什么抄,因为这篇文章图文并茂,所有测试都在CentOS 6和7测试过. 许多Linux使用者安装操作系统时都会遇到这样的困境:如何精确评估和分配各个硬盘分区的容量,如果当初评估不准确,一旦系统 ...

随机推荐

  1. 解决百度云推送通知,不显示默认Notification

    问题:百度云推送通知,不显示默认Notification 描述:采用推送消息的方式,可以在onMessage方法里面获取到推送的消息.另外推送通知也有获取到内容,后台日志也有show private ...

  2. [转]ztree出现$.fn.zTree is undefined错误的解决办法。

    原文地址:https://blog.csdn.net/smallboy2011/article/details/20554269 问题描述,在一个界面使用ztree创建树,提示TypeError: $ ...

  3. 【iCore1S 双核心板_FPGA】例程七:基础逻辑门实验——逻辑门使用

    实验现象: 打开tool-->Netlist viewer-->RTL viewer可观察各个逻辑连接 核心代码: //-----------------Module_logic_gate ...

  4. 【WPF】ListBox GridViewColumn Header 文字换行、文字多行显示

    ListBox GridViewColumn Header 文字换行.文字多行显示,在Header中需要换行的地方写 <GridViewColumn Header="空间另存 为总量& ...

  5. Unity和Android混合开发

    通用的流程 https://blog.csdn.net/zhangdi2017/article/details/65629589 应用场景 Unity游戏中一些功能需要安卓系统的支持,如搜索wifi等 ...

  6. table给tbody设置滚动条

    table结构例子: <table class="layui-table"> <thead> <tr> <th> 贷款项目 < ...

  7. How to set asp.net Identity cookies expires time

    If IsPersistent property of AuthenticationProperties is set to false, then the cookie expiration tim ...

  8. [Converge] Gradient Descent - Several solvers

    solver : {‘newton-cg’, ‘lbfgs’, ‘liblinear’, ‘sag’}, default: ‘liblinear’ Algorithm to use in the op ...

  9. [Artoolkit] Can I Use LGPL code for commercial application

    这是一个比较普遍但又容易被忽略的问题. From: http://answers.google.com/answers/threadview/id/439136.html 假设背景: - want t ...

  10. 系统信号(signal)与其他(定时器,退出清理等)

    信号signal,可以用作进程线程通信,也可以用作接收中断后退出,退出时,清理资源,记录日志.python相关包为signa. linux信号表 root@server:~# kill -l ) SI ...