Centos7调整XFS格式的LVM大小

原文地址:http://www.eussi.top/view/25

查看容量
[root@app1 ~]# df -h
Filesystem               Size  Used Avail Use% Mounted on
/dev/mapper/centos-root  8.0G  7.0G 1020M  88% /
devtmpfs                 607M     0  607M   0% /dev
tmpfs                    616M     0  616M   0% /dev/shm
tmpfs                    616M  8.6M  608M   2% /run
tmpfs                    616M     0  616M   0% /sys/fs/cgroup
/dev/mapper/centos-home  9.0G   36M  9.0G   1% /home
/dev/sda2               1014M  131M  884M  13% /boot
备份
[root@app1 ~]# xfsdump -f /home.xfsdump /home
xfsdump: using file dump (drive_simple) strategy
xfsdump: version 3.1.4 (dump format 3.0) - type ^C for status and control

 ============================= dump label dialog ==============================

please enter label for this dump session (timeout in 300 sec)
 -> home
session label entered: "home"

 --------------------------------- end dialog ---------------------------------

xfsdump: level 0 dump of app1:/home
xfsdump: dump date: Fri Apr 19 22:33:38 2019
xfsdump: session id: 160d605b-10f5-4f0d-bd81-326cc4965552
xfsdump: session label: "home"
xfsdump: ino map phase 1: constructing initial dump list
xfsdump: ino map phase 2: skipping (no pruning necessary)
xfsdump: ino map phase 3: skipping (only one dump stream)
xfsdump: ino map construction complete
xfsdump: estimated dump size: 3792064 bytes
xfsdump: /var/lib/xfsdump/inventory created

 ============================= media label dialog =============================

please enter label for media in drive 0 (timeout in 300 sec)
 -> home
media label entered: "home"

 --------------------------------- end dialog ---------------------------------

xfsdump: creating dump session media file 0 (media 0, file 0)
xfsdump: dumping ino map
xfsdump: dumping directories
xfsdump: dumping non-directory files
xfsdump: ending media file
xfsdump: media file size 3707936 bytes
xfsdump: dump size (non-dir files) : 3588432 bytes
xfsdump: dump complete: 8 seconds elapsed
xfsdump: Dump Summary:
xfsdump:   stream 0 /home.xfsdump OK (success)
xfsdump: Dump Status: SUCCESS
卸载
[root@app1 ~]# umount /home
缩减容量
[root@app1 ~]# lvreduce -L 3G /dev/mapper/centos-home
  WARNING: Reducing active logical volume to 3.00 GiB
  THIS MAY DESTROY YOUR DATA (filesystem etc.)
Do you really want to reduce home? [y/n]: y
  Size of logical volume centos/home changed from 9.00 GiB (2303 extents) to 3.00 GiB (768 extents).
  Logical volume home successfully resized
增加容量
[root@app1 ~]# lvextend -l +100%FREE /dev/centos/root
  Size of logical volume centos/root changed from 8.00 GiB (2048 extents) to 14.00 GiB (3583 extents).
  Logical volume root successfully resized
延展 xfs 空间
[root@app1 ~]# xfs_growfs /dev/centos/root
meta-data=/dev/mapper/centos-root isize=256    agcount=4, agsize=524288 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=0        finobt=0
data     =                       bsize=4096   blocks=2097152, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=0
log      =internal               bsize=4096   blocks=2560, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
data blocks changed from 2097152 to 3668992
恢复Home
[root@app1 ~]# mkfs.xfs -f /dev/mapper/centos-home
meta-data=/dev/mapper/centos-home isize=256    agcount=4, agsize=196608 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=0        finobt=0
data     =                       bsize=4096   blocks=786432, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=0
log      =internal log           bsize=4096   blocks=2560, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
挂载Home
[root@app1 ~]# mount /home
还原备份资料到 Home
[root@app1 ~]# xfsrestore -f /home.xfsdump /home
xfsrestore: using file dump (drive_simple) strategy
xfsrestore: version 3.1.4 (dump format 3.0) - type ^C for status and control
xfsrestore: searching media for dump
xfsrestore: examining media file 0
xfsrestore: dump description: 
xfsrestore: hostname: app1
xfsrestore: mount point: /home
xfsrestore: volume: /dev/mapper/centos-home
xfsrestore: session time: Fri Apr 19 22:33:38 2019
xfsrestore: level: 0
xfsrestore: session label: "home"
xfsrestore: media label: "home"
xfsrestore: file system id: 46bdf91e-8c28-4344-a238-6e3a9793b223
xfsrestore: session id: 160d605b-10f5-4f0d-bd81-326cc4965552
xfsrestore: media id: 652f30e4-eff9-4708-b5f6-adc4498a0dbf
xfsrestore: using online session inventory
xfsrestore: searching media for directory dump
xfsrestore: reading directories
xfsrestore: 90 directories and 150 entries processed
xfsrestore: directory post-processing
xfsrestore: restoring non-directory files
xfsrestore: restore complete: 0 seconds elapsed
xfsrestore: Restore Summary:
xfsrestore:   stream 0 /home.xfsdump OK (success)
xfsrestore: Restore Status: SUCCESS
查看调整后容量
[root@app1 ~]# df -h
Filesystem               Size  Used Avail Use% Mounted on
/dev/mapper/centos-root   14G  7.0G  7.0G  51% /
devtmpfs                 607M     0  607M   0% /dev
tmpfs                    616M     0  616M   0% /dev/shm
tmpfs                    616M  8.6M  608M   2% /run
tmpfs                    616M     0  616M   0% /sys/fs/cgroup
/dev/sda2               1014M  131M  884M  13% /boot
/dev/mapper/centos-home  3.0G   36M  3.0G   2% /home
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值