關於xfs和ext4的區別,請自行度娘node
centos7默認xfs爲文件系統, xfs由於只能增大,不能減小,因此須要調整/home,增大/,須要安裝xfsdump,步驟以下,作個記錄:
yum install xfsdump -ycentos
查看現有分區狀況:
/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/0session
須要減小/home目錄,增大/目錄,先備份一下/home目錄:
xfsdump -l 0 -L home -M home -f /opt/home.xfsdump /homeapp
卸載/home目錄:
umount /homeide
調整/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.oop
增大/目錄:
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.post
延伸/目錄空間:
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 48806912centos7
從新格式化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=0spa
掛在home目錄:
mount /homerest
還原備份文件到/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
到此調整完成,之後再補充!