Centos给根目录扩容教程

这篇具有很好参考价值的文章主要介绍了Centos给根目录扩容教程。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

一、问题与目的

今天在使用nacos服务时发现怎么操作都会报错,原因是磁盘空间已满,正好有时间,研究一下怎么对Centos进行扩容

二、解决方法

1、首先,通过命令df -h 观察磁盘占用情况

centos 根目录扩容,centos,linux,运维

可以发现根目录已经被写满了,这会导致所有写操作都无法进行

2、先关闭虚拟机,然后在VMware的设置中选择添加一块新的硬盘(一直点下一步就可以了)

centos 根目录扩容,centos,linux,运维

我选择了扩容40G

3、重启虚拟机后通过命令lsblk可以发现多了一个分区sdb(原来只有sda)

centos 根目录扩容,centos,linux,运维

所以接下来对sdb进行分区操作

4、对sdb进行分区操作

[root@itcast ~]# 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.

Device does not contain a recognized partition table
Building a new DOS disklabel with disk identifier 0xdeeb604b.

Command (m for help): m
Command action
   a   toggle a bootable flag
   b   edit bsd disklabel
   c   toggle the dos compatibility flag
   d   delete a partition
   g   create a new empty GPT partition table
   G   create an IRIX (SGI) partition table
   l   list known partition types
   m   print this menu
   n   add a new partition
   o   create a new empty DOS partition table
   p   print the partition table
   q   quit without saving changes
   s   create a new empty Sun disklabel
   t   change a partition's system id
   u   change display/entry units
   v   verify the partition table
   w   write table to disk and exit
   x   extra functionality (experts only)

Command (m for help): n                                #输入n新建一个分区
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p): p                                   #输入p,将分区创建为主分区
Partition number (1-4, default 1): 1    
First sector (2048-83886079, default 2048):             #默认     
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-83886079, default 83886079): 
Using default value 83886079
Partition 1 of type Linux and of size 40 GiB is set

Command (m for help): t                                #输入t改变分区类型
Selected partition 1
Hex code (type L to list all codes): 8e                #输入8e对应LVM
Changed type of partition 'Linux' to 'Linux LVM'

Command (m for help): w                                #保存
The partition table has been altered!

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

再次观察发现有了sdb1分区

[root@itcast ~]# lsblk
NAME            MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda               8:0    0   40G  0 disk 
├─sda1            8:1    0  200M  0 part /boot
└─sda2            8:2    0 39.8G  0 part 
  ├─centos-root 253:0    0   30G  0 lvm  /
  └─centos-swap 253:1    0  9.8G  0 lvm  [SWAP]
sdb               8:16   0   40G  0 disk 
└─sdb1            8:17   0   40G  0 part 
sr0              11:0    1 1024M  0 rom  

5、查看根分区的文件系统类型

centos 根目录扩容,centos,linux,运维

6、格式化sdb1

[root@itcast ~]# mkfs.xfs /dev/sdb1
meta-data=/dev/sdb1              isize=512    agcount=4, agsize=2621376 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=0, sparse=0
data     =                       bsize=4096   blocks=10485504, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
log      =internal log           bsize=4096   blocks=5119, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0

7、查看卷组信息(记住LV Path 和 VG Name)

centos 根目录扩容,centos,linux,运维

8、开始扩容

[root@itcast ~]# pvcreate /dev/sdb1    #将sdb1分区变为pv
WARNING: xfs signature detected on /dev/sdb1 at offset 0. Wipe it? [y/n]: y
  Wiping xfs signature on /dev/sdb1.
  Physical volume "/dev/sdb1" successfully created.
[root@itcast ~]# vgextend centos /dev/sdb1    #将/dev/sdc1卷加入根目录所在的卷组名centos
  Couldn't create temporary archive name. ##报错啦!

发现报错了,"Couldn't create temporary archive name" 错误通常与 Logical Volume Manager (LVM) 中的缺少或损坏的临时文件有关。所以我们清理一下/tmp目录

执行 rm -rf /tmp/*

[root@itcast ~]# vgextend centos /dev/sdb1
  Volume group "centos" successfully extended

成功了

接着查看卷组信息 (记住Free PE)

centos 根目录扩容,centos,linux,运维

把所有空间分配给根分区

[root@itcast ~]# lvextend -l +10239 /dev/centos/root    #10239=free pe
  Size of logical volume centos/root changed from 30.00 GiB (7680 extents) to <70.00 GiB (17919 extents).
  Logical volume centos/root successfully resized.

最后是文件系统的扩容

[root@itcast ~]# xfs_growfs /dev/centos/root
meta-data=/dev/mapper/centos-root isize=512    agcount=4, agsize=1966080 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=0 spinodes=0
data     =                       bsize=4096   blocks=7864320, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
log      =internal               bsize=4096   blocks=3840, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
data blocks changed from 7864320 to 18349056

Done!

centos 根目录扩容,centos,linux,运维文章来源地址https://www.toymoban.com/news/detail-853169.html

到了这里,关于Centos给根目录扩容教程的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • centos7 根目录扩容

    需求         将测试环境根目录扩容到47G 具体操作 1.添加一块硬盘 我们新添加了一块30G的硬盘 2.查看本机磁盘环境 lsblk 我们可以看到根目录总容量为17G,新添加的设备sdb为30G  添加磁盘分区 fdisk /dev/sdb 创建分区: 查看分区信息是否创建:   可以看见sdb1分区已创建。

    2023年04月26日
    浏览(44)
  • 动态扩容Linux根目录 (解决/dev/mapper/centos-root 占用了过高问题)

    $ sudo df -h 可以看到,这里home目录空闲的空间还很大,因此,我们将home的空间分给根目录一些。 2. 扩容根目录的思路如下: 将/home文件夹备份,删除/home文件系统所在的逻辑卷,增大/文件系统所在的逻辑卷,增大/文件系统大小,最后新建/home目录,并恢复/home文件夹下的内容

    2024年02月14日
    浏览(40)
  • centos 根目录逻辑卷扩容/home -> /

    最后检查一下/etc/fstab,在#/dev/mapper/centos-home /home,取消开机挂载/home。

    2024年02月08日
    浏览(30)
  • CentOS系统/root根目录扩容(扩展逻辑卷)

    具体操作步骤 1、查看本机磁盘环境挂载情况 2、添加磁盘分区 3、开始扩容 4、同步到文件系统 1、查看本机磁盘环境挂载情况 2、添加磁盘分区 fdisk是一个用于磁盘分区的命令行工具,它可以帮助我们在CentOS系统中创建、删除、修改和查看磁盘分区。 /dev/sda是路径 linux中dev的

    2024年02月03日
    浏览(37)
  • Linux 根目录爆满 解决(/dev/mapper/centos-root 100%问题)

    首先df -h 发现/dev/mapper/centos-root 为100%。 会导致数据库sys登不上去。 提示: ORA-09945: Unable to initialize the audit trail file Linux-x86_64 Error: 28: No space left on device 然后需要查看哪个目录占用过高,对于过高目录中的内容适当删减腾出一些空间 du -h -x --max-depth=1 将该两个文件夹下不需要

    2024年02月12日
    浏览(31)
  • linux系统根目录动态扩容

    前提:虚拟机系统根目录占用40GB,创建vm时磁盘大小给120GB 1. 将剩余空间分区 2. 创建pv 3.vg(centos)扩容

    2024年02月07日
    浏览(49)
  • Linux之硬盘的根目录扩容、新建分区、删除分区,挂载分区

    一、新建分区、删除分区、挂载分区: root权限下操作:  二、对根目录进行扩容 #虚拟机扩展硬盘后,系统本身无法识别这些多出来的空间,此时就需要对硬盘进行扩容。 root权限下操作:   开始扩容:   示例图:  

    2024年02月15日
    浏览(44)
  • ubuntu20根目录扩容

    ubuntu根目录/ 或者 /home文件夹有时出现空间满了的情况,可以用gparted工具进行空间的重新分配。 首先,如果你是双系统,需要从windows系统下磁盘压缩分配一部分未使用的空间给ubuntu,注意压缩的空间要邻接ubuntu所在盘的位置。 如果仅仅是把/home文件夹的空间分给/ ,则不需要

    2024年01月25日
    浏览(33)
  • 【详细】双系统 Ubuntu 如何给根目录扩容

    这一步我直接利用windows系统自带的“创建并格式化硬盘分区”功能进行的。 如图,在想要切割出来一部分空间的卷上右键,选择压缩卷选项,之后输入空间大小即可在该卷的后面得到一块未分配空间。 首先解释为什么需要用U盘来启动一个新系统进而调整原Ubuntu系统的磁盘容

    2024年01月25日
    浏览(77)
  • Ubuntu20.04根目录/home目录扩容(双系统,亲测有效)

    sudo apt update   sudo apt install gparted         安装完成后输入: sudo gparted         如图所示:         1. 找到你要扩容的根目录/home目录(会发现名称右边有个钥匙,表示现在无法对其进行操作)         2. 扩容要求1:只能将待扩容磁盘相邻的空间扩容给他 (如果不相邻

    2024年02月03日
    浏览(34)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包