[centos7]——调整XFS格式的LVM大小

wangxm 7月前 ⋅ 190 阅读
查看容量
[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

    评论: