linux(centos 6)調整掛載分區大小

來源:互聯網
上載者:User

linux(centos 6)調整掛載分區大小 安裝centos6使用自動推薦分區,發現一個問題/home 分區過大。 目標:/home分20G,剩下添加給/目錄下 1.查看分區模式[root@localhost ~]# df -h檔案系統 容量 已用 可用 已用%% 掛載點/dev/mapper/VolGroup-lv_root50G 2.9G 44G 7% /tmpfs 5.9G 100K 5.9G 1% /dev/shm/dev/sda1 485M 37M 423M 8% /boot/dev/mapper/VolGroup-lv_home1.1T 200M 988G 1% /home 2.卸載掛載分區[root@localhost ~]# umount /home 3.檢查VolGroup-lv_home檔案的錯誤性,-f 即使檔案系統沒有錯誤跡象,仍強制地檢查正確性。[root@localhost ~]# e2fsck -f /dev/mapper/VolGroup-lv_homee2fsck 1.41.12 (17-May-2010)第一步: 檢查inode,塊,和大小第二步: 檢查目錄結構第3步: 檢查目錄串連性Pass 4: Checking reference counts第5步: 檢查簇概要資訊/dev/mapper/VolGroup-lv_home: 27/69304320 files (0.0% non-contiguous), 4400705/277215232 blocks 4.調整/home為20G,[root@localhost ~]# resize2fs -p /dev/mapper/VolGroup-lv_home 20Gresize2fs 1.41.12 (17-May-2010)Resizing the filesystem on /dev/mapper/VolGroup-lv_home to 5242880 (4k) blocks.Begin pass 2 (max = 32784)正在重定位塊 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXBegin pass 3 (max = 8460)正在掃描inode表 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXBegin pass 4 (max = 15)正在更新inode引用 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXThe filesystem on /dev/mapper/VolGroup-lv_home is now 5242880 blocks long. 5.重新掛載並查看[root@localhost ~]# mount /home[root@localhost ~]# df -h檔案系統 容量 已用 可用 已用%% 掛載點/dev/mapper/VolGroup-lv_root50G 2.9G 44G 7% /tmpfs 5.9G 100K 5.9G 1% /dev/shm/dev/sda1 485M 37M 423M 8% /boot/dev/mapper/VolGroup-lv_home20G 172M 19G 1% /home  6.劃分20G外面的剩餘空間。使用lvreduce指令用於減少LVM邏輯卷佔用的空間大小。可能會刪除邏輯卷上已有的資料,所以在操作前必須進行確認。記得輸入 “y”[root@localhost ~]# lvreduce -L 20G /dev/mapper/VolGroup-lv_homeWARNING: Reducing active and open logical volume to 20.00 GiBTHIS MAY DESTROY YOUR DATA (filesystem etc.)Do you really want to reduce lv_home? [y/n]: yReducing logical volume lv_home to 20.00 GiBLogical volume lv_home successfully resized[root@localhost ~]# df -h檔案系統 容量 已用 可用 已用%% 掛載點/dev/mapper/VolGroup-lv_root50G 2.9G 44G 7% /tmpfs 5.9G 100K 5.9G 1% /dev/shm/dev/sda1 485M 37M 423M 8% /boot/dev/mapper/VolGroup-lv_home20G 172M 19G 1% /home 7.查看“Free PE / Size”剩餘空間[root@localhost ~]# vgdisplay--- Volume group ---VG Name VolGroupSystem 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 1.09 TiBPE Size 4.00 MiBTotal PE 285022Alloc PE / Size 19424 / 75.88 GiBFree PE / Size 265598 / 1.01 TiBVG UUID nSbflh-J7fN-xDvf-zLjL-tFcu-Y5Tm-ybnDk0 8.使用lvextend指令:擴充邏輯卷空間到/dev/mapper/VolGroup-lv_root目錄下,也就是“/”目錄下。 [root@localhost ~]# lvextend -L +1.01T /dev/mapper/VolGroup-lv_rootRounding size to boundary between physical extents: 1.01 TiBExtending logical volume lv_root to 1.06 TiBLogical volume lv_root successfully resized 9.執行操作,使之生效,中間一定要耐心等待。[root@localhost ~]# resize2fs -p /dev/mapper/VolGroup-lv_rootresize2fs 1.41.12 (17-May-2010)Filesystem at /dev/mapper/VolGroup-lv_root is mounted on /; on-line resizing requiredold desc_blocks = 4, new_desc_blocks = 68Performing an on-line resize of /dev/mapper/VolGroup-lv_root to 284227584 (4k) blocks.The filesystem on /dev/mapper/VolGroup-lv_root is now 284227584 blocks long. 10.查看分區成功[root@localhost ~]# df -h檔案系統 容量 已用 可用 已用%% 掛載點/dev/mapper/VolGroup-lv_root1.1T 2.9G 1011G 1% /tmpfs 5.9G 100K 5.9G 1% /dev/shm/dev/sda1 485M 37M 423M 8% /boot/dev/mapper/VolGroup-lv_home20G 172M 19G 1% /home11.重啟[root@localhost ~]# shutdown -r now 

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.