linux6.9中调整/home分区增大其他

需求:Home逻辑区划大了,格式化一部分给opt逻辑区。【原本opt只有7g,结果会增到10g】

环境:oracle_linux6.9

[root@localhost ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root
                      4.7G  3.3G  1.3G  73% /
tmpfs                 492M   76K  492M   1% /dev/shm
/dev/sda1             477M   77M  371M  18% /boot
/dev/mapper/VolGroup-LogVol02
                      4.7G  9.8M  4.5G   1% /home
/dev/mapper/VolGroup-LogVol03
                      7.6G   18M  7.2G   1% /opt
[root@localhost ~]# umount /home/
[root@localhost ~]# resizze2fs -p /dev/mapper/
control            VolGroup-LogVol02  VolGroup-LogVol03  VolGroup-lv_root   VolGroup-lv_swap   
[root@localhost ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root
                      4.7G  3.3G  1.3G  73% /
tmpfs                 492M   76K  492M   1% /dev/shm
/dev/sda1             477M   77M  371M  18% /boot
/dev/mapper/VolGroup-LogVol03
                      7.6G   18M  7.2G   1% /opt

 

[root@localhost ~]# resize2fs -p /dev/mapper/VolGroup-LogVol02 4G
resize2fs 1.43-WIP (20-Jun-2013)
Please run 'e2fsck -f /dev/mapper/VolGroup-LogVol02' first.

[root@localhost ~]# e2fsck -f /dev/mapper/VolGroup-LogVol02 
e2fsck 1.43-WIP (20-Jun-2013)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/mapper/VolGroup-LogVol02: 11/320000 files (0.0% non-contiguous), 55366/1280000 blocks

[root@localhost ~]# resize2fs -p /dev/mapper/VolGroup-LogVol02_home 4G  [这里我故意放报错的看看,格式化时我加上路径Home是不对的,要看自己的卷组是什么名字才用什么名字。]
resize2fs 1.43-WIP (20-Jun-2013)
open: No such file or directory while opening /dev/mapper/VolGroup-LogVol02_home

[root@localhost ~]# resize2fs -p /dev/mapper/VolGroup-LogVol02 4G
resize2fs 1.43-WIP (20-Jun-2013)
Resizing the filesystem on /dev/mapper/VolGroup-LogVol02 to 1048576 (4k) blocks.
Begin pass 3 (max = 40)
Scanning inode table          XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
The filesystem on /dev/mapper/VolGroup-LogVol02 is now 1048576 blocks long.

[root@localhost ~]# mount /home/
[root@localhost ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root
                      4.7G  3.4G  1.1G  76% /
tmpfs                 492M   76K  492M   1% /dev/shm
/dev/sda1             477M   77M  371M  18% /boot
/dev/mapper/VolGroup-LogVol03
                      7.6G   18M  7.2G   1% /opt
/dev/mapper/VolGroup-LogVol02
                      3.9G  9.8M  3.6G   1% /home

[root@localhost ~]# lvreduce -L 4G /dev/mapper/VolGroup-LogVol02 
  WARNING: Reducing active and open logical volume to 4.00 GiB.
  THIS MAY DESTROY YOUR DATA (filesystem etc.)
Do you really want to reduce VolGroup/LogVol02? [y/n]: y
  Size of logical volume VolGroup/LogVol02 changed from 4.88 GiB (1250 extents) to 4.00 GiB (1024 extents).
  Logical volume LogVol02 successfully resized.

[root@localhost ~]# vgdisplay 
  --- Volume group ---
  VG Name               VolGroup
  System ID             
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  6
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                4
  Open LV               4
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               19.51 GiB
  PE Size               4.00 MiB
  Total PE              4994
  Alloc PE / Size       4768 / 18.62 GiB
  Free  PE / Size       226 / 904.00 MiB
  VG UUID               Hrires-m0qh-Savz-JPHu-mJ9W-aA4W-Mjrngg
   
[root@localhost ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root
                      4.7G  3.5G  1.1G  78% /
tmpfs                 492M   76K  492M   1% /dev/shm
/dev/sda1             477M   77M  371M  18% /boot
/dev/mapper/VolGroup-LogVol03
                      7.6G   18M  7.2G   1% /opt
/dev/mapper/VolGroup-LogVol02
                      3.9G  9.8M  3.6G   1% /home

[root@localhost ~]# lvextend -L 900M /dev/mapper/VolGroup-LogVol03  【这里报错是没有加参数+在900前面】
  New size given (225 extents) not larger than existing size (1998 extents)
  Run `lvextend --help' for more information.

[root@localhost ~]# lvextend -L +900M /dev/mapper/VolGroup-LogVol03 
  Size of logical volume VolGroup/LogVol03 changed from 7.80 GiB (1998 extents) to 8.68 GiB (2223 extents).
  Logical volume LogVol03 successfully resized.

[root@localhost ~]# resize2fs -p /dev/mapper/VolGroup-LogVol03 
resize2fs 1.43-WIP (20-Jun-2013)
Filesystem at /dev/mapper/VolGroup-LogVol03 is mounted on /opt; on-line resizing required
old_desc_blocks = 1, new_desc_blocks = 1
The filesystem on /dev/mapper/VolGroup-LogVol03 is now 2276352 blocks long.

[root@localhost ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root
                      4.7G  3.5G  978M  79% /
tmpfs                 492M   76K  492M   1% /dev/shm
/dev/sda1             477M   77M  371M  18% /boot
/dev/mapper/VolGroup-LogVol03
                      8.5G   18M  8.0G   1% /opt
/dev/mapper/VolGroup-LogVol02
                      3.9G  9.8M  3.6G   1% /home
[root@localhost ~]# umount /  【末尾我想试一试卸挂载的根目录,调整根目录大小,显示系统文件在进程中使用。】
umount: /: device is busy.
        (In some cases useful info about processes that use
         the device is found by lsof(8) or fuser(1))

结果对比:

调整前:

调整后:

总结:调整home操作不难。清楚自己操作步骤,和每一步指令就行。

扩展一下,如果想调整根目录大小,压缩出空闲空间在如何操作。有知道麻烦告知。

参考https://cloud.tencent.com/developer/article/1491957

发布了35 篇原创文章 · 获赞 34 · 访问量 16万+
展开阅读全文

没有更多推荐了,返回首页

©️2019 CSDN 皮肤主题: 技术黑板 设计师: CSDN官方博客

分享到微信朋友圈

×

扫一扫,手机浏览