新之助meow

Kratos
专注于用户阅读体验的响应式博客主题
  1. 首页
  2. 未分类
  3. 正文

centos 7 文件系统 容量收缩和扩充

2018年11月18日 2133点热度 1人点赞 0条评论

默认是xfs文件系统
如果是xfs,收缩会损坏文件系统,导致文件丢失,要先备份。

mount 会报错 can't read superblock xfs
这时只能格式化了 mkfs.xfs -f /dev/mapper/centos-home

1、提前备份重要数据,xfs减小会导致数据丢失

备份可以用xfsdump,数据不大也可以备份到机器之外(此处略)

2、卸载卷/dev/mapper/cl-home

umount /home

3、减少卷/dev/mapper/cl-home大小(该步骤会导致数据丢失,请看第1点)

[root@localhost ~]# lvreduce -L 10G /dev/mapper/cl-home

WARNING: Reducing active logical volume to 10.00 GiB.
THIS MAY DESTROY YOUR DATA (filesystem etc.)
Do you really want to reduce cl/home? [y/n]:y
Size of logical volume cl/home changed from 178.25 GiB (45633 extents) to 10.00 GiB (2560 extents).
Logical volume cl/home successfully resized.

4、增加卷/dev/mapper/cl-root大小

[root@localhost ~]# lvextend -l +100%FREE /dev/mapper/cl-root
Size of logical volume cl/root changed from 50.00 GiB (12800 extents) to 218.26 GiB (55874 extents).
Logical volume cl/root successfully resized.

5、调整xfs文件系统大小

[root@localhost ~]# xfs_growfs /dev/mapper/cl-root

6、重新挂载、恢复数据

如果直接挂载会报错:

[root@localhost ~]# mount /dev/mapper/cl-home /home/
mount: /dev/mapper/cl-home: can't read superblock
需要先格式化

[root@localhost ~]# mkfs.xfs -f /dev/mapper/cl-home
格式化后挂载:

mount /dev/mapper/cl-home /home/
挂载后恢复数据
此步骤可以用xfsrestore,或者手动拷贝(参照第1点)

7、查看结果

[root@localhost ~]# df -h

参考

centos7下xfs格式的LVM卷空间伸缩实战
http://www.viper.im/archives/centos7-xfs-lvm-resize.html
CentOS 7扩展根分区
https://segmentfault.com/a/1190000007645451

如果某个fstab 中的文件系统故障,mount不上,启动会报错,进入维护模式

Error getting authority: Error initializing authority: Could not connect: No such file or directory (g-io-error-quark, 1)
可以 查看报错内容 journalctl -x | grep mount
手动mount 看报啥错
然后修复
或者改fstab注释掉错误的文件系统

还有一种可能是新增了硬盘或者u盘,导致硬盘序号发生变化

可以把磁盘名称更改为UUID。

# blkid 
/dev/sdc1: UUID="ab4c28b5-1708-483c-973a-40f91d320a9d" TYPE="ext4" 
...
# cat /etc/fstab 

#
# /etc/fstab
# Created by anaconda on Tue Aug  8 13:10:48 2017
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
/dev/mapper/cl-root     /                       xfs     defaults        0 0
UUID=a51fd6f8-a756-4e8f-ba44-5589fb99861e /boot                   xfs     defaults        0 0
UUID=7D74-6C54          /boot/efi               vfat    umask=0077,shortname=winnt 0 0
/dev/mapper/cl-swap     swap                    swap    defaults        0 0
UUID=ab4c28b5-1708-483c-973a-40f91d320a9d /data ext4 defaults 0 0

参考
系统启动报错:Error getting authority: Error initializing authority: Could not connect: No such file or directory (g-io-error-quark, 1)
https://www.jianshu.com/p/ea57fb7834f2

CentOS 7磁盘寻找不到,卡在sulogin,造成的开机失败问题--Error getting authority...
https://www.cnblogs.com/redheat/p/7477380.html

标签: 暂无
最后更新:2018年11月18日

tjccn_wx@hotmail.com

这个人很懒,什么都没留下

点赞
< 上一篇
下一篇 >

文章评论

razz evil exclaim smile redface biggrin eek confused idea lol mad twisted rolleyes wink cool arrow neutral cry mrgreen drooling persevering
取消回复

归档

  • 2026 年 10 月
  • 2024 年 2 月
  • 2023 年 7 月
  • 2023 年 1 月
  • 2022 年 10 月
  • 2022 年 9 月
  • 2022 年 6 月
  • 2022 年 4 月
  • 2022 年 3 月
  • 2022 年 2 月
  • 2021 年 11 月
  • 2021 年 10 月
  • 2021 年 9 月
  • 2021 年 1 月
  • 2020 年 12 月
  • 2020 年 11 月
  • 2020 年 10 月
  • 2020 年 9 月
  • 2020 年 7 月
  • 2020 年 6 月
  • 2020 年 5 月
  • 2020 年 4 月
  • 2020 年 3 月
  • 2020 年 2 月
  • 2019 年 10 月
  • 2019 年 8 月
  • 2019 年 7 月
  • 2019 年 4 月
  • 2019 年 3 月
  • 2018 年 12 月
  • 2018 年 11 月
  • 2018 年 10 月
  • 2018 年 6 月
  • 2018 年 5 月
  • 2018 年 4 月
  • 2018 年 3 月
  • 2018 年 2 月
  • 2018 年 1 月
  • 2017 年 12 月
  • 2017 年 11 月
  • 2017 年 10 月
  • 2017 年 9 月
  • 2017 年 8 月
  • 2017 年 7 月
  • 2017 年 6 月
  • 2017 年 5 月
  • 2017 年 4 月
  • 2017 年 3 月
  • 2017 年 2 月
  • 2017 年 1 月
  • 2016 年 12 月
  • 2016 年 11 月
  • 2016 年 10 月
  • 2016 年 9 月
  • 2016 年 8 月
  • 2016 年 7 月
  • 2016 年 6 月
  • 2016 年 5 月
  • 2016 年 4 月
  • 2016 年 3 月
  • 2015 年 12 月
  • 2015 年 8 月

分类

  • android
  • mysql
  • nethunter
  • proxmark
  • 未分类

COPYRIGHT © 2026 新之助meow. ALL RIGHTS RESERVED.

Theme Kratos Made By Seaton Jiang