本文介绍下,在ubuntu中扩展LVM磁盘的具体方法,有需要的朋友参考下吧。

当LV空间利用率较大即将耗尽LV空间时,可以将一块新的磁盘或一块磁盘上的/空间加入LV中。

现在/ 空间如下:

代码示例:
root@ubuntu :~# df -h
文件系统            容量  已用 可用 已用% 挂载点
/dev/mapper/ubuntu-root
4.5G  792M  3.5G  19% /
none                  244M  224K  243M   1% /dev
none                  249M  4.0K  249M   1% /dev/shm
none                  249M   36K  249M   1% /var/run
none                  249M     0  249M   0% /var/lock
none                  249M     0  249M   0% /lib/init/rw
/dev/sda1             228M   19M  198M   9% /boot

查看磁盘状态:

代码示例:

root@ubuntu :~# fdisk -l
Disk /dev/sda: 5368 MB, 5368709120 bytes
255 heads, 63 sectors/track, 652 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: 0x0000d2ec

Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          32      248832   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2              32         653     4990977    5  Extended
Partition 2 does not end on cylinder boundary.
/dev/sda5              32         653     4990976   8e  Linux LVM

Disk /dev/sdb: 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: 0×00000000

Disk /dev/sdb doesn’t contain a valid partition table

1. 新建LVM类型分区:

代码示例:

root@ubuntu :~# fdisk /dev/sdb  \\对硬盘sdb进行分区

Command (m for help): n  \\创建新的分区
Command action
e   extended
p   primary partition (1-4)
p                 \\创建主分区
Partition number (1-4): 1
First cylinder (1-522, default 1):  \\默认值
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-522, default 522):  \\默认值
Using default value 522

Command (m for help): p        //查看当前分区

Disk /dev/sdb: 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: 0x542e4b15

Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1         522     4192933+  83  Linux

Command (m for help): t  \\改变分区类型
Selected partition 1
Hex code (type L to list codes): 8e  \\更改为LVM类型分区
Changed system type of partition 1 to 8e (Linux LVM)

Command (m for help): w   \\ 保持退出
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

2.创建新的PV

代码示例:

root@ubuntu :~# partprobe  \\使用partprobe指令更新内核的中硬盘分区表
root@ubuntu :~# pvcreate /dev/sdb1  \\创建新的PV
Physical volume “/dev/sdb1″ successfully created

root@ubuntu :~# pvscan    \\新创建的PV但是尚未加入任何VG组
PV /dev/sda5   VG ubuntu          lvm2 [4.76 GiB / 12.00 MiB free]
PV /dev/sdb1                      lvm2 [4.00 GiB]
Total: 2 [8.76 GiB] / in use: 1 [4.76 GiB] / in no VG: 1 [4.00 GiB]

3. 将PV加入VG组中

代码示例:

root@ubuntu :~# vgdisplay   //查看VG组的详细信息
— Volume group —
VG Name               ubuntu
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               4.76 GiB
PE Size               4.00 MiB
Total PE              1218
Alloc PE / Size       1215 / 4.75 GiB
Free  PE / Size       3 / 12.00 MiB
VG UUID               jeRoTV-fYcT-e5qf-N2rk-m6Ky-eH1W-NSRm1s

root@ubuntu :~# vgextend ubuntu /dev/sdb1  //添加磁盘到VG组
Volume group “ubuntu” successfully extended

root@ubuntu :~# pvscan  // /dev/sdb1加入到ubuntu组中
PV /dev/sda5   VG ubuntu   lvm2 [4.76 GiB / 12.00 MiB free]
PV /dev/sdb1   VG ubuntu   lvm2 [4.00 GiB / 4.00 GiB free]
Total: 2 [8.75 GiB] / in use: 2 [8.75 GiB] / in no VG: 0 [0   ]

4.将VG组中的free空间划出4G到/分区所在的LV

代码示例:

root@ubuntu :~# lvdisplay  //查看LV Name
— Logical volume —
LV Name                /dev/ubuntu/root
VG Name                ubuntu
LV UUID                ig0Es7-8tMQ-Uyiq-szHY-V8b0-pnC1-1lFyKn
LV Write Access        read/write
LV Status              available
# open                 1
LV Size                4.49 GiB
Current LE             1149

root@ubuntu :~# lvextend -L +4G  /dev/ubuntu/root // 将VG组中的free空间4G加到/分区所在的LV
Extending logical volume root to 8.49 GiB
Logical volume root successfully resized

5. 使用resizefs2命令重新加载逻辑卷的大小才能生效

代码示例:
root@ubuntu :~# resize2fs /dev/ubuntu/root
resize2fs 1.41.11 (14-Mar-2010)
Filesystem at /dev/ubuntu/root is mounted on /; on-line resizing required
old desc_blocks = 1, new_desc_blocks = 1
Performing an on-line resize of /dev/ubuntu/root to 2225152 (4k) blocks.
The filesystem on /dev/ubuntu/root is now 2225152 blocks long.

6.查看增加空间后的/空间

代码示例:
root@ubuntu :~# df -h
文件系统            容量  已用 可用 已用% 挂载点
/dev/mapper/ubuntu-root
8.4G  793M  7.2G  10% /
none                  244M  228K  243M   1% /dev
none                  249M  4.0K  249M   1% /dev/shm
none                  249M   36K  249M   1% /var/run
none                  249M     0  249M   0% /var/lock
none                  249M     0  249M   0% /lib/init/rw
/dev/sda1             228M   19M  198M   9% /boot

现在发现/ 分区已变大。

以上介绍了,在ubuntu下对即将用尽的LVM磁盘扩容的方法,希望对大家有所帮助。

原文:http://www.jbxue.com/LINUXjishu/10305.html

ubuntu LVM的更多相关文章

  1. ubuntu lvm模式进行扩容

    ubuntu的16.04 18.04有lvm的功能(安装的时候的选项),能在磁盘空间用完的时候,无缝增加一个磁盘进去.因为linux系统只有一个盘,所以是非常方便,不会有windows加1个磁盘要进行 ...

  2. 如何给VirtualBox虚拟机的ubuntu LVM分区扩容

    我在VirtualBox安装的ubuntu里安装Cloud Foundry时遇到错误信息,磁盘空间不够了: 使用这三个命令做了清理之后,结果依然不够理想: (1) sudo apt-get autoc ...

  3. 【Storage】Ubuntu LVM 安装配置

    参考资料: https://www.centos.bz/2012/02/installation-and-usage-of-lvm/ http://blog.chinaunix.net/uid-206 ...

  4. remove ubuntu lvm

    sudo vgdisplay sudo vgremove groupname

  5. Logical Volume Manager (LVM)

    LVM 是一种可用在Linux内核的逻辑分卷管理器:可用于管理磁盘驱动器或其他类似的大容量存储设备. 本文提供如何在 Arch Linux 中配置和使用 Logical Volume Manager ...

  6. Ubuntu raid5+lvm实验

    首先说一下本次实验的环境:VMware12+Ubuntu (虚拟硬盘+mdadm) 本次实验参照http://allenyu.blog.51cto.com/193668/162067中的流程,下面总结 ...

  7. Ubuntu下创建XFS文件系统的LVM

    以前在Linux下面玩LVM,一般都是选择ext3.ext4格式的文件系统,最近在Ubuntu 16.04.5下安装配置一个MySQL数据库服务器,遂测试了一下XFS文件系统的LVM,其实仔细对比下来 ...

  8. LVM方式安装Ubuntu 系统

    重装Ubuntu系统,使用LVM管理磁盘,最好不要使用默认的LVM安装方式,而应挂载U盘启动盘,进行物理磁盘分区,创建物理卷.卷组.虚卷(即创建LVM系列操作),在安装系统时将虚卷挂载到文件目录上.将 ...

  9. 使用LVM方式安装Ubuntu 16.04

    --- By 小甘丶 注: 这里只讲解如何配置LVM,其他不再陈述! 这个方法,通用的!只要操作系统支持LVM即可!(个人推测,尚未证实) 配置好虚拟机后,开始安装,先进入Ubuntu使用界面,对磁盘 ...

随机推荐

  1. Gliffy Diagrams 好用的流程图工具

    很好用!加上百度脑图!good!

  2. List排序的两种简便方式

    using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace List ...

  3. MoreLinq和Linq

    MoreLinq里的Batch和Partition不知道什么区别. var ints =Enumerable.Range(1,10); var result = ints.Batch(3); var ...

  4. UVa 11019 (AC自动机 二维模式串匹配) Matrix Matcher

    就向书上说得那样,如果模式串P的第i行出现在文本串T的第r行第c列,则cnt[r-i][c]++; 还有个很棘手的问题就是模式串中可能会有相同的串,所以用repr[i]来记录第i个模式串P[i]第一次 ...

  5. iOS 开发 中级:UIToolbar,UINavigationBar,UITabBar,UIBarButtonItem,UITabBarItem自定义方法总结

    原文:  http://blog.csdn.net/songrotek/article/details/8692866?utm_source=tuicool 对于UIToolbar,UINavigat ...

  6. WebForm页面生命周期及asp.net运行机制

    1.先上几张原理图着重理解: 现在针对第四副图原理进行解析: 流程: 1.浏览器发送请求 2.服务器软件(IIS)接收,它最终的目的就是为了向客户输出它请求的动态页面生成的html代码. 3.服务器不 ...

  7. BZOJ 1803 Query on a tree III

    树上主席树. 我靠这是第k小吧..... #include<iostream> #include<cstdio> #include<cstring> #includ ...

  8. BPMN2新规范与Activiti5

    上世纪九十年代以后,随着WfMC联盟的成立,BPM市场群雄逐鹿如火如荼,工作流技术得到了突飞猛进的发展,其中IBM.Oracle等大型软件厂商在工作流领域各扯大旗割据一方.2011年BPMN2.0新规 ...

  9. USACO 2013 Nov Silver Pogo-Cow

    最近因为闲的蛋疼(停课了),所以开始做一些 USACO 的银组题.被完虐啊 TAT 貌似 Pogo-Cow 这题是 2013 Nov Silver 唯一一道可说的题目? Pogo-Cow Descri ...

  10. 10g中HASH GROUP BY引起的临时表空间不足

    原本在9i上可以顺利完成的CTAS脚本,迁移到10g后运行总是报“ORA-1652: unable to extend temp segment by 128 in tablespace TS_HQY ...