Chinaunix首页 | 论坛 | 博客
  • 博客访问: 829070
  • 博文数量: 203
  • 博客积分: 2433
  • 博客等级: 大尉
  • 技术积分: 2195
  • 用 户 组: 普通用户
  • 注册时间: 2011-04-05 13:32
文章分类

全部博文(203)

分类: LINUX

2017-08-05 20:09:54

关于xfs和ext4的区别,请自行度娘

centos7默认xfs为文件系统, xfs因为只能增大,不能减少,所以需要调整/home,增大/,需要安装xfsdump,步骤如下,做个记录:
yum install xfsdump -y

查看现有分区情况:
/dev/mapper/cl_hadoop-root   50G  3.1G   47G   7% /
devtmpfs                    7.7G     0  7.7G   0% /dev
tmpfs                       7.8G     0  7.8G   0% /dev/shm
tmpfs                       7.8G  8.4M  7.8G   1% /run
tmpfs                       7.8G     0  7.8G   0% /sys/fs/cgroup
/dev/mapper/cl_hadoop-home  142G  424M  141G   1% /home
/dev/vda1                  1014M  139M  876M  14% /boot
tmpfs                       1.6G     0  1.6G   0% /run/user/0

需要减少/home目录,增大/目录,先备份一下/home目录:
xfsdump -l 0 -L home -M home -f /opt/home.xfsdump /home

卸载/home目录:
umount /home

调整/home目录到5G:
lvreduce -L 5G /dev/mapper/cl_hadoop-home
  WARNING: Reducing active logical volume to 5.00 GiB.
  THIS MAY DESTROY YOUR DATA (filesystem etc.)
Do you really want to reduce cl_hadoop/home? [y/n]: y
  Size of logical volume cl_hadoop/home changed from 141.18 GiB (36142 extents) to 5.00 GiB (1280 extents).
  Logical volume cl_hadoop/home successfully resized.

增大/目录:
lvextend -l +100%FREE /dev/cl_hadoop/root
  Size of logical volume cl_hadoop/root changed from 50.00 GiB (12800 extents) to 186.18 GiB (47663 extents).
  Logical volume cl_hadoop/root successfully resized.

延伸/目录空间:
xfs_growfs /dev/cl_hadoop/root
meta-data=/dev/mapper/cl_hadoop-root isize=512    agcount=4, agsize=3276800 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=0 spinodes=0
data     =                       bsize=4096   blocks=13107200, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
log      =internal               bsize=4096   blocks=6400, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
data blocks changed from 13107200 to 48806912

重新格式化home分区:
mkfs.xfs -f /dev/mapper/cl_hadoop-home
meta-data=/dev/mapper/cl_hadoop-home isize=512    agcount=4, agsize=327680 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=0, sparse=0
data     =                       bsize=4096   blocks=1310720, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
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目录:
mount /home

还原备份文件到/home目录:
xfsrestore -f /opt/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: hadoop
xfsrestore: mount point: /home
xfsrestore: volume: /dev/mapper/cl_hadoop-home
xfsrestore: session time: Sat Aug  5 19:49:06 2017
xfsrestore: level: 0
xfsrestore: session label: "home"
xfsrestore: media label: "home"
xfsrestore: file system id: f716ff51-3556-491a-a324-de943e23277b
xfsrestore: session id: 47a21c87-c24e-47fe-a501-cd5f5565c6c5
xfsrestore: media id: 553706c1-917a-440a-9cd8-31779fa17089
xfsrestore: using online session inventory
xfsrestore: searching media for directory dump
xfsrestore: reading directories
xfsrestore: 4 directories and 14 entries processed
xfsrestore: directory post-processing
xfsrestore: restoring non-directory files
xfsrestore: restore complete: 1 seconds elapsed
xfsrestore: Restore Summary:
xfsrestore:   stream 0 /opt/home.xfsdump OK (success)
xfsrestore: Restore Status: SUCCESS

重新查看分区情况:
Filesystem                  Size  Used Avail Use% Mounted on
/dev/mapper/cl_hadoop-root  187G  3.1G  184G   2% /
devtmpfs                    7.7G     0  7.7G   0% /dev
tmpfs                       7.8G     0  7.8G   0% /dev/shm
tmpfs                       7.8G  8.4M  7.8G   1% /run
tmpfs                       7.8G     0  7.8G   0% /sys/fs/cgroup
/dev/vda1                  1014M  139M  876M  14% /boot
tmpfs                       1.6G     0  1.6G   0% /run/user/0
/dev/mapper/cl_hadoop-home  5.0G  424M  4.6G   9% /home

到此调整完成,以后再补充!
阅读(7815) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~