日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

CentOS6.5下lv调整空间大小

發(fā)布時(shí)間:2024/8/1 编程问答 33 豆豆
生活随笔 收集整理的這篇文章主要介紹了 CentOS6.5下lv调整空间大小 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.


轉(zhuǎn)自:http://blog.csdn.net/andy_yf/article/details/7831482

一、目的

在使用CentOS6.3版本linux系統(tǒng)的時(shí)候,發(fā)現(xiàn)根目錄(/)的空間不是很充足,而其他目錄空間有很大的空閑,所以本文主要是針對(duì)現(xiàn)在已有的空間進(jìn)行調(diào)整。首先,先來查看一下系統(tǒng)的空間分配情況:

[plain] view plaincopyprint?
  • [root@CentOS-78?/]#?df?-h??
  • Filesystem????????????Size??Used?Avail?Use%?Mounted?on??
  • /dev/mapper/vg_centos-lv_root??
  • ???????????????????????50G???14G???34G??30%?/??
  • tmpfs?????????????????1.9G?????0??1.9G???0%?/dev/shm??
  • /dev/sda1?????????????485M???37M??423M???8%?/boot??
  • /dev/mapper/vg_centos-lv_home??
  • ??????????????????????404G??670M??382G???1%?/home??
  • [root@CentOS-78 /]# df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/vg_centos-lv_root50G 14G 34G 30% / tmpfs 1.9G 0 1.9G 0% /dev/shm /dev/sda1 485M 37M 423M 8% /boot /dev/mapper/vg_centos-lv_home404G 670M 382G 1% /home 下面的詳細(xì)步驟部分將從vg_centos-lv_home分區(qū)下取出100G的空間添加到/vg_centos-lv_root分區(qū)上去。

    二、詳細(xì)步驟

    1、卸載vg_centos-lv_home分區(qū)

    [plain] view plaincopyprint?
  • [root@CentOS-78?/]#?umount?/home??
  • [root@CentOS-78 /]# umount /home此時(shí)在用df命令查看將會(huì)發(fā)現(xiàn)/home目錄已經(jīng)看不見了,如下所示:

    [plain] view plaincopyprint?
  • [root@CentOS-78?/]#?df?-h??
  • Filesystem????????????Size??Used?Avail?Use%?Mounted?on??
  • /dev/mapper/vg_centos-lv_root??
  • ???????????????????????50G???14G???34G??30%?/??
  • tmpfs?????????????????1.9G?????0??1.9G???0%?/dev/shm??
  • /dev/sda1?????????????485M???37M??423M???8%?/boot??
  • [root@CentOS-78 /]# df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/vg_centos-lv_root50G 14G 34G 30% / tmpfs 1.9G 0 1.9G 0% /dev/shm /dev/sda1 485M 37M 423M 8% /boot

    2、從新設(shè)定vg_home-lv_home的大小

    [plain] view plaincopyprint?
  • [root@CentOS-78?/]#?resize2fs?-p?/dev/mapper/vg_centos-lv_home?282G??
  • resize2fs?1.41.12?(17-May-2010)??
  • Please?run?'e2fsck?-f?/dev/mapper/vg_centos-lv_home'?first.??
  • [root@CentOS-78 /]# resize2fs -p /dev/mapper/vg_centos-lv_home 282G resize2fs 1.41.12 (17-May-2010) Please run 'e2fsck -f /dev/mapper/vg_centos-lv_home' first.這一步設(shè)定vg_home-lv_home大小沒有成功,系統(tǒng)提示我們先運(yùn)行下面的命令,操作如下:

    [plain] view plaincopyprint?
  • [root@CentOS-78?/]#?e2fsck?-f?/dev/mapper/vg_centos-lv_home??
  • e2fsck?1.41.12?(17-May-2010)??
  • 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/vg_centos-lv_home:?1386/26836992?files?(0.9%?non-contiguous),?1855856/107344896?blocks??
  • [root@CentOS-78 /]# e2fsck -f /dev/mapper/vg_centos-lv_home e2fsck 1.41.12 (17-May-2010) 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/vg_centos-lv_home: 1386/26836992 files (0.9% non-contiguous), 1855856/107344896 blocks從新設(shè)定vg_home-lv_home的大小:

    [plain] view plaincopyprint?
  • [root@CentOS-78?/]#?resize2fs?-p?/dev/mapper/vg_centos-lv_home?282G??
  • resize2fs?1.41.12?(17-May-2010)??
  • Resizing?the?filesystem?on?/dev/mapper/vg_centos-lv_home?to?73924608?(4k)?blocks.??
  • Begin?pass?2?(max?=?43)??
  • Relocating?blocks?????????????XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX??
  • Begin?pass?3?(max?=?3276)??
  • Scanning?inode?table??????????XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX??
  • Begin?pass?4?(max?=?266)??
  • Updating?inode?references?????XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX??
  • The?filesystem?on?/dev/mapper/vg_centos-lv_home?is?now?73924608?blocks?long.??
  • [root@CentOS-78 /]# resize2fs -p /dev/mapper/vg_centos-lv_home 282G resize2fs 1.41.12 (17-May-2010) Resizing the filesystem on /dev/mapper/vg_centos-lv_home to 73924608 (4k) blocks. Begin pass 2 (max = 43) Relocating blocks XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX Begin pass 3 (max = 3276) Scanning inode table XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX Begin pass 4 (max = 266) Updating inode references XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX The filesystem on /dev/mapper/vg_centos-lv_home is now 73924608 blocks long.檢查是否成功:

    [plain] view plaincopyprint?
  • [root@CentOS-78?/]#?mount?/home??
  • [root@CentOS-78?/]#??
  • [root@CentOS-78?/]#?df?-h??
  • Filesystem????????????Size??Used?Avail?Use%?Mounted?on??
  • /dev/mapper/vg_centos-lv_root??
  • ???????????????????????50G???14G???34G??30%?/??
  • tmpfs?????????????????1.9G?????0??1.9G???0%?/dev/shm??
  • /dev/sda1?????????????485M???37M??423M???8%?/boot??
  • /dev/mapper/vg_centos-lv_home??
  • ??????????????????????278G??663M??263G???1%?/home??
  • [root@CentOS-78?/]#??
  • [root@CentOS-78 /]# mount /home [root@CentOS-78 /]# [root@CentOS-78 /]# df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/vg_centos-lv_root50G 14G 34G 30% / tmpfs 1.9G 0 1.9G 0% /dev/shm /dev/sda1 485M 37M 423M 8% /boot /dev/mapper/vg_centos-lv_home278G 663M 263G 1% /home [root@CentOS-78 /]#3、將lv_home邏輯分區(qū)減小到指定大小

    [plain] view plaincopyprint?
  • [root@CentOS-78?/]#?lvreduce?-L?282G?/dev/mapper/vg_centos-lv_home??
  • ??WARNING:?Reducing?active?and?open?logical?volume?to?282.00?GiB??
  • ??THIS?MAY?DESTROY?YOUR?DATA?(filesystem?etc.)??
  • Do?you?really?want?to?reduce?lv_home??[y/n]:?y??
  • ??Reducing?logical?volume?lv_home?to?282.00?GiB??
  • ??Logical?volume?lv_home?successfully?resized??
  • [root@CentOS-78?/]#??
  • [root@CentOS-78 /]# lvreduce -L 282G /dev/mapper/vg_centos-lv_homeWARNING: Reducing active and open logical volume to 282.00 GiBTHIS MAY DESTROY YOUR DATA (filesystem etc.) Do you really want to reduce lv_home? [y/n]: yReducing logical volume lv_home to 282.00 GiBLogical volume lv_home successfully resized [root@CentOS-78 /]#我認(rèn)為這個(gè)命令是將已經(jīng)減少的100G空間拿到系統(tǒng)公共的區(qū)域,可以被其他分區(qū)加載和利用。

    查詢卷組的信息:

    [plain] view plaincopyprint?
  • [root@CentOS-78?/]#?vgdisplay??
  • ??---?Volume?group?---??
  • ??VG?Name???????????????vg_centos??
  • ??System?ID??
  • ??Format????????????????lvm2??
  • ??Metadata?Areas????????1??
  • ??Metadata?Sequence?No??5??
  • ??VG?Access?????????????read/write??
  • ??VG?Status?????????????resizable??
  • ??MAX?LV????????????????0??
  • ??Cur?LV????????????????3??
  • ??Open?LV???????????????3??
  • ??Max?PV????????????????0??
  • ??Cur?PV????????????????1??
  • ??Act?PV????????????????1??
  • ??VG?Size???????????????465.27?GiB??
  • ??PE?Size???????????????4.00?MiB??
  • ??Total?PE??????????????119109??
  • ??Alloc?PE?/?Size???????86472?/?337.78?GiB??
  • ??Free??PE?/?Size???????32637?/?127.49?GiB??
  • ??VG?UUID???????????????1k4ooN-RFV9-uyf1-uMYf-aERG-YaGs-ZNoSD6??
  • [root@CentOS-78 /]# vgdisplay--- Volume group ---VG Name vg_centosSystem IDFormat lvm2Metadata Areas 1Metadata Sequence No 5VG Access read/writeVG Status resizableMAX LV 0Cur LV 3Open LV 3Max PV 0Cur PV 1Act PV 1VG Size 465.27 GiBPE Size 4.00 MiBTotal PE 119109Alloc PE / Size 86472 / 337.78 GiBFree PE / Size 32637 / 127.49 GiBVG UUID 1k4ooN-RFV9-uyf1-uMYf-aERG-YaGs-ZNoSD6

    Free PE / Size指定的應(yīng)該是現(xiàn)在可在分配的空間。

    4、增加vg_centos-lv_root分區(qū)的大小

    將可用的空間添加到vg_centos-lv_root分區(qū)上面:

    [plain] view plaincopyprint?
  • [root@CentOS-78?/]#?lvextend?-L?+127.40G?/dev/mapper/vg_centos-lv_root??
  • ??Rounding?up?size?to?full?physical?extent?127.40?GiB??
  • ??Extending?logical?volume?lv_root?to?177.40?GiB??
  • ??Logical?volume?lv_root?successfully?resized??
  • [root@CentOS-78?/]#??
  • [root@CentOS-78 /]# lvextend -L +127.40G /dev/mapper/vg_centos-lv_rootRounding up size to full physical extent 127.40 GiBExtending logical volume lv_root to 177.40 GiBLogical volume lv_root successfully resized [root@CentOS-78 /]#從新設(shè)定該分區(qū)的大小:
    [plain] view plaincopyprint?
  • [root@CentOS-78?/]#?resize2fs?-p?/dev/mapper/vg_centos-lv_root??
  • resize2fs?1.41.12?(17-May-2010)??
  • Filesystem?at?/dev/mapper/vg_centos-lv_root?is?mounted?on?/;?on-line?resizing?required??
  • old?desc_blocks?=?4,?new_desc_blocks?=?12??
  • Performing?an?on-line?resize?of?/dev/mapper/vg_centos-lv_root?to?46504960?(4k)?blocks.??
  • The?filesystem?on?/dev/mapper/vg_centos-lv_root?is?now?46504960?blocks?long.??
  • [root@CentOS-78 /]# resize2fs -p /dev/mapper/vg_centos-lv_root resize2fs 1.41.12 (17-May-2010) Filesystem at /dev/mapper/vg_centos-lv_root is mounted on /; on-line resizing required old desc_blocks = 4, new_desc_blocks = 12 Performing an on-line resize of /dev/mapper/vg_centos-lv_root to 46504960 (4k) blocks. The filesystem on /dev/mapper/vg_centos-lv_root is now 46504960 blocks long.5、再次查看分區(qū)大小

    [plain] view plaincopyprint?
  • [root@CentOS-78?/]#?df?-h??
  • Filesystem????????????Size??Used?Avail?Use%?Mounted?on??
  • /dev/mapper/vg_centos-lv_root??
  • ??????????????????????175G???14G??153G???9%?/??
  • tmpfs?????????????????1.9G?????0??1.9G???0%?/dev/shm??
  • /dev/sda1?????????????485M???37M??423M???8%?/boot??
  • /dev/mapper/vg_centos-lv_home??
  • ??????????????????????278G??663M??263G???1%?/home??
  • [root@CentOS-78 /]# df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/vg_centos-lv_root175G 14G 153G 9% / tmpfs 1.9G 0 1.9G 0% /dev/shm /dev/sda1 485M 37M 423M 8% /boot /dev/mapper/vg_centos-lv_home278G 663M 263G 1% /home我們發(fā)現(xiàn)vg_centos-lv_root分區(qū)的空間已經(jīng)增加了125G,之所以比lv_home減少的空間要多25G主要是由于我們把系統(tǒng)所有的可用的空間都加在了lv_root分區(qū)。

    三、所遇到的問題

    1、在卸載/home目錄的時(shí)候失敗

    可先執(zhí)行如下fuser命令,然后再umount即可:

    [plain] view plaincopyprint?
  • [root@CentOS-78?/]#?fuser?-m?/home??
  • [root@CentOS-78?/]#??
  • [root@CentOS-78 /]# fuser -m /home [root@CentOS-78 /]#2、設(shè)定完lv_home的大小,再次mount該分區(qū)時(shí),發(fā)現(xiàn)用df命令無法看到給分區(qū),此時(shí)只要在mount一次即可

    3、在設(shè)定lv_root的大小時(shí),不要把Free PE / Size的空間全部都用上,這很可能會(huì)出現(xiàn)Free PE空間不足的現(xiàn)象,建議保留一點(diǎn)Free PE的空間。


    ==================================================================

    參考:

    http://hi.baidu.com/%B7%E7%B6%C0/blog/item/c4aa9a81b204dbc89023d956.html

    http://qianxunniao.iteye.com/blog/1393726


    總結(jié)

    以上是生活随笔為你收集整理的CentOS6.5下lv调整空间大小的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。