记录一次安装软件的报错

                                                                  ——1261065212@qq.com        

1.系统版本(VMware 虚拟机)

[root@ansible-admin ~]# cat /etc/redhat-release

CentOS Linux release 7.3.1611 (Core)

2.当执行yum安装软件时报如下错

Error: Error writing to file /var/cache/yum/x86_64/7/epel/gen/filelists_db.sqlite: [Errno 28] No space left on device

是由于磁盘空间不够,清除了部分无用日志之后再次安装

#yum install gitlab-ce -y

………………………………

Transaction Summary

=====================================================================================================================

Install  1 Package

Total download size: 378 M

Installed size: 378 M

Is this ok [y/d/N]: y

Downloading packages:

Error downloading packages:

gitlab-ce-9.5.2-ce.0.el7.x86_64: Insufficient space in download directory /var/cache/yum/x86_64/7/gitlab-ce/packages

* free   312 M

* needed 378 M

3.提示空间不足,剩余空间只有312M,查看磁盘使用空间发现根分区确实只剩313M了

[root@ansible-admin ~]# df -h

Filesystem           Size  Used Avail Use% Mounted on

/dev/mapper/cl-root  6.2G  5.9G  313M  96% /  #扩容的对象

devtmpfs             482M     0  482M   0% /dev

tmpfs                493M     0  493M   0% /dev/shm

tmpfs                493M   50M  443M  11% /run

tmpfs                493M     0  493M   0% /sys/fs/cgroup

/dev/sda1           1014M  139M  876M  14% /boot

tmpfs                 99M     0   99M   0% /run/user/0

/dev/sr0             680M  680M     0 100% /mnt

[root@ansible-admin boot]# df -h /var (/var目录确实为312M)

Filesystem           Size  Used Avail Use% Mounted on

/dev/mapper/cl-root  6.2G  5.9G  312M  96% /

4.于是开始扩容根分区

 (1)添加磁盘

虚拟机——设置——添加——硬盘——下一步——选择磁盘类型——下一步——填写磁盘大小——完成

(2)查看磁盘

[root@ansible-admin boot]# fdisk -l

Disk /dev/sda: 8589 MB, 8589934592 bytes, 16777216 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: 0x000b9a5e

Device Boot      Start         End      Blocks   Id  System

/dev/sda1   *        2048     2099199     1048576   83  Linux

/dev/sda2         2099200    16777215     7339008   8e  Linux LVM

Disk /dev/sdb: 21.5 GB, 21474836480 bytes, 41943040 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: 0x4fddc909

Device Boot      Start         End      Blocks   Id  System

Disk /dev/mapper/cl-root: 6652 MB, 6652166144 bytes, 12992512 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 /dev/mapper/cl-swap: 859 MB, 859832320 bytes, 1679360 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

(3)为新磁盘创建分区

创建分区:

[root@ansible-admin boot]# 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.

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):  #默认为1(因为是新磁盘第一次创建分区)

First sector (2048-41943039, default 2048):

Using default value 2048

Last sector, +sectors or +size{K,M,G} (2048-41943039, default 41943039): #这里我只创建一个分区所以默认是使用所有空间

Using default value 41943039

Partition 1 of type Linux and of size 20 GiB is set

Command (m for help): w  #保存分区结果

The partition table has been altered!

Calling ioctl() to re-read partition table.

Syncing disks.

让系统重新读取分区表:

[root@ansible-admin boot]# partprobe

Warning: Unable to open /dev/sr0 read-write (Read-only file system).  /dev/sr0 has been opened read-only.

(4)扩容

由于sda已经为LVM所以可以直接为其扩容,无需再创建新的LVM

创建物理卷(PV):

使用pvcreate命令创建物理卷,pvdisplay查看物理卷信息:

创建物理卷:

[root@ansible-admin boot]# pvcreate /dev/sdb1

Physical volume "/dev/sdb1" successfully created.

查看物理卷信息:

[root@ansible-admin boot]# pvdisplay

--- Physical volume ---

PV Name               /dev/sda2

VG Name               cl   #原有盘上的PV

PV Size               7.00 GiB / not usable 3.00 MiB

Allocatable           yes (but full)

PE Size               4.00 MiB

Total PE              1791

Free PE               0

Allocated PE          1791

PV UUID               beyPTU-i2Ny-ltMw-0tfr-Me0b-Sz0Z-ybS4cy

"/dev/sdb1" is a new physical volume of "20.00 GiB"

--- NEW Physical volume ---

PV Name               /dev/sdb1

VG Name        #新建的PV的VG name是空的,下一步就是把PV加入VG

PV Size               20.00 GiB

Allocatable           NO

PE Size               0

Total PE              0

Free PE               0

Allocated PE          0

PV UUID               5N1q14-vf7Y-U1dm-1tkf-ZxAQ-16lE-pW2M5F

 

查看原VG的情况

[root@ansible-admin boot]# vgdisplay

--- Volume group ---

VG Name               cl  #注意记录此名字,扩容时将新的pv加入指定的名字

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               7.00 GiB

PE Size               4.00 MiB

Total PE              1791

Alloc PE / Size       1791 / 7.00 GiB

Free  PE / Size       0 / 0   #发现空闲空间为0(以G计算)

VG UUID               l4mGeJ-090j-NZ1U-UOhI-c56R-0mtM-xiBm9h

 

扩展卷组,将/dev/sdb物理卷添加到cl卷组中

再查看VG情况,可以看到VG大小变化,空余空间

将新的VG空间划入LV(扩容lv_root)

直接扩展10G给/root分区,不用umount,也不需要重启(扩张多大可根据添加的磁盘大小自由支配)

[root@ansible-admin boot]# lvextend -L +10G  /dev/mapper/cl-root

Size of logical volume cl/root changed from 6.20 GiB (1586 extents) to 16.20 GiB (4146 extents).

Logical volume cl/root successfully resized.

也可以使用命令

# lvextend -l +50%FREE /dev/mapper/cl-root(表示将剩余空间的50%划入LV)

使用xfs_growfs命令在线调整xfs格式文件系统大小(CentOS6使用resize2fs)

#xfs_growfs /dev/cl/root (因为CentOS7默认文件系统类型为xfs)

最后我们看到逻辑卷分区已经动态扩容到了11G:

至此一次CentOS7 根分区扩容顺利完成

若为非商业用途,转发请注明出处。

从yum提示空间不足到根分区扩容的更多相关文章

  1. Linux 分区扩容(根分区扩容,SWAP 分区扩容,挂载新分区为目录)

    请访问原文链接:https://sysin.org/blog/linux-partition-expansion/,查看最新版.原创作品,转载请保留出处. 作者:gc(at)sysin.org,主页: ...

  2. linux根分区扩容

    Linux 根分区扩容 1.fdisk –l  (红线部分为新添加的硬盘) 2.磁盘格式化 3. mkfs.ext3 -T largefile /dev/sde(格式化上面的分区) 4. vgdisp ...

  3. 如何为根分区扩容(centos7为例)

    linux系统所有的文件都是存放在根分区中的,如果根分区容量即将耗尽,我们就需要给根分区扩容,我们可以使用lsblk命令来查看,系统的根分区实际是逻辑卷,所以想要扩展根分区只要将逻辑卷扩容就可以了.此 ...

  4. LVM 管理减少swap分区空间增加到根分区

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

  5. CentOS7,非LVM根分区扩容步骤:

    1.查看现有的分区大小 非LVM分区,目前磁盘大小为40G,根分区总容量为40G,(是自定义分区安装的) 2.关机增加磁盘大小至100G 如果你们是vmwaer虚拟软件安装的那如下入扩容: 3.查看磁 ...

  6. centos7 根分区扩容

    系统安装时候使用的默认分区,根分区只分了50G,使用的是LVM 想把home分区分出来660G给根分区 先查了点资料开搞 由于xfs分区只支持增大,不支持缩小,所以home目前是xfs格式无法进行缩小 ...

  7. 如何在Virtualbox中对Ubuntu系统根分区扩容

    转载:             参见博客: https://blog.csdn.net/LEON1741/article/details/56494797 前在Virtualbox中安装了一个Ubun ...

  8. Linux 根分区扩容

    扩容分区之前,首先要保证当前有闲置空间 1. 查看当前现有分区情况 df -lah 可以看出当前根分区只剩 6.4 G 可用 2. 查看当前磁盘情况 fdisk -l 可以看出有 30G的未分配空间 ...

  9. 实战 | Linux根分区扩容

    一个执着于技术的公众号 一个执着于技术的公众号 前言 Linux系统作为服务器操作系统,经常遇到一个问题就是服务器分区磁盘空间不足需要扩容的情况.本文以linux系统最常见的发行版centos7系统为 ...

随机推荐

  1. thinkphp 面向切面编程-行为拓展

    thinkphp的CBD模式 核心保留了最关键的部分,并在重要位置设置了标签用以标记,其他功能都采用行为扩展和驱动的方式组合,开发人员可以根据自己的需要,对某个标签位置进行行为扩展或者替换,就可以方便 ...

  2. 使用xcrun打包iOS应用

    使用xcrun打包iOS应用 通常打包采用xcodebuild和xcrun两个命令,xcodebuild负责编译,xcrun负责将app打成ipa.   XCode 默认编译出来的是appName.a ...

  3. 手机摄像头扫描识别车牌号,移动端车牌识别sdk

    一.移动端车牌识别应用背景 (技术交流:18701686857  QQ:283870550) 随着经济水平的不断提高,汽车数量的不断激增为汽车管理带来了不小的难度.路边违章停车的现象越来越频繁.现在, ...

  4. SpringMVC源码情操陶冶-View视图渲染

    本节简单分析View视图对象的render方法 View接口 最重要的就是render()方法,具体源码如下 /** * Render the view given the specified mod ...

  5. 前端框架之bootstrap

    一.bootstrap按钮 1.按钮 <button class="btn btn-default">按钮</button><button class ...

  6. 机器学习 —— 类不平衡问题与SMOTE过采样算法

    在前段时间做本科毕业设计的时候,遇到了各个类别的样本量分布不均的问题——某些类别的样本数量极多,而有些类别的样本数量极少,也就是所谓的类不平衡(class-imbalance)问题. 本篇简述了以下内 ...

  7. ServletAPI的获取

    Action中获取ServletAPI,三种方式 (1)通过ActionContext获取(只是获取并操作了域空间,并不是真正的ServletAPI对象) 在struts2框架中,通过Action的执 ...

  8. Android百度地图开发-第一篇:申请、搭建百度地图

    一.前言 这是第一篇关于Android使用百度地图的学习记录,主要记录: 1.在百度地图开发者平台上申请API Key. 2.在自己的应用中加入百度地图的Android版SDK. 3.在自己的应用中显 ...

  9. centos7修改网卡名称

    [root@localhost ~]# cd /etc/sysconfig/network-scripts/[root@localhost network-scripts]# mv ifcfg-eno ...

  10. MyBatis String类型传递参数注意事项

    Mybatis查询sql传入一个字符串传参数,报There is no getter for property named 'ids' in 'class java.lang.String'. 后来改 ...