茫茫網海中的冷日
         
茫茫網海中的冷日
發生過的事,不可能遺忘,只是想不起來而已!
 恭喜您是本站第 1671644 位訪客!  登入  | 註冊
主選單

Google 自訂搜尋

Goole 廣告

隨機相片
IMG_60D_00004.jpg

授權條款

使用者登入
使用者名稱:

密碼:


忘了密碼?

現在就註冊!

小企鵝開談 : [原創]紀錄一次 CentOS 的 root 空間不足擴容方案

發表者 討論內容
冷日
(冷日)
Webmaster
  • 註冊日: 2008/2/19
  • 來自:
  • 發表數: 15771
[原創]紀錄一次 CentOS 的 root 空間不足擴容方案
在某次使用場景中,用戶回報『Web 系統可以連上線,但輸入密碼後就不動了』!
經查,是 CentOS 的 root 空間使用爆炸了!
原因是早年的 VM 因為 Server HD 小,所以給各個 GuestOS 的空間都不大!
所以開始了這一次的擴容之旅!

1.在 VMHost 上面多開一個虛擬硬碟
2.把開好的虛擬硬碟掛載到 VMGuest 上
3.用 fdisk 把 partition 做好
4.用 pvcreate 建立 LVM
5.用 vgextend 擴充 LVM
6.用 vgextend 擴充 extFS

詳細方法轉載於後面

PS:強力推薦鳥哥的教學:進階檔案系統管理
冷日
(冷日)
Webmaster
  • 註冊日: 2008/2/19
  • 來自:
  • 發表數: 15771
[轉載]給linux虛擬機增加根目錄硬盤
# 目的
VMVare或者雲ECS中, 發現根目錄磁盤太小, 需要增加根目錄磁盤大小.

# 申請磁盤
這個步驟省略, 可在VMVare軟件更改磁盤大小或申請雲硬盤.

# 準備分區
沒有處理的磁盤, 現在Linux裡面是看不到的.
先查看磁盤分區
[root@centos dev]# fdisk -l

磁盤 /dev/sda:42.9 GB, 42949672960 字節,83886080 個扇區
Units = 扇區 of 1 * 512 = 512 bytes
扇區大小(邏輯/物理):512 字節 / 512 字節
I/O 大小(最小/最佳):512 字節 / 512 字節
磁盤標籤類型:dos
磁盤標識符:0x000b340a

   設備 Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048     2099199     1048576   83  Linux
/dev/sda2         2099200    41943039    19921920   8e  Linux LVM

磁盤 /dev/mapper/centos-root:18.2 GB, 18249416704 字節,35643392 個扇區
Units = 扇區 of 1 * 512 = 512 bytes
扇區大小(邏輯/物理):512 字節 / 512 字節
I/O 大小(最小/最佳):512 字節 / 512 字節


磁盤 /dev/mapper/centos-swap:2147 MB, 2147483648 字節,4194304 個扇區
Units = 扇區 of 1 * 512 = 512 bytes
扇區大小(邏輯/物理):512 字節 / 512 字節
I/O 大小(最小/最佳):512 字節 / 512 字節


上面看到有2個分區`sda1`, `sda2`, 這個時候`sda`已經擴為40G了, 我們來創建新的`sda3`
[root@centos dev]# fdisk /dev/sda
歡迎使用 fdisk (util-linux 2.23.2)。

更改將停留在內存中,直到您決定將更改寫入磁盤。
使用寫入命令前請三思。

命令(輸入 m 獲取幫助):m
命令操作
   a   toggle a bootable flag
   b   edit bsd disklabel
   c   toggle the dos compatibility flag
   d   delete a partition
   g   create a new empty GPT partition table
   G   create an IRIX (SGI) partition table
   l   list known partition types
   m   print this menu
   n   add a new partition
   o   create a new empty DOS partition table
   p   print the partition table
   q   quit without saving changes
   s   create a new empty Sun disklabel
   t   change a partition\'s system id
   u   change display/entry units
   v   verify the partition table
   w   write table to disk and exit
   x   extra functionality (experts only)

命令(輸入 m 獲取幫助):n  // 命令n用於添加新分區
Partition type:
   p   primary (2 primary, 0 extended, 2 free)
   e   extended
Select (default p): p    // 選擇創建主分區
分區號 (3,4,默認 3):   //fdisk會讓你選擇主分區的編號,前面有1,2了
起始 扇區 (41943040-83886079,默認為 41943040):
將使用默認值 41943040
Last 扇區, +扇區 or +size{K,M,G} (41943040-83886079,默認為 83886079):
將使用默認值 83886079
分區 3 已設置為 Linux 類型,大小設為 20 GiB

命令(輸入 m 獲取幫助):w // w 保存所有並退出,分區劃分完畢
The partition table has been altered!

Calling ioctl() to re-read partition table.


我們的新建分區/dev/sda3,卻不是LVM的。所以,接下來使用fdisk將其改成LVM的
[root@centos dev]# fdisk /dev/sda
歡迎使用 fdisk (util-linux 2.23.2)。

更改將停留在內存中,直到您決定將更改寫入磁盤。
使用寫入命令前請三思。


命令(輸入 m 獲取幫助):m
命令操作
   a   toggle a bootable flag
   b   edit bsd disklabel
   c   toggle the dos compatibility flag
   d   delete a partition
   g   create a new empty GPT partition table
   G   create an IRIX (SGI) partition table
   l   list known partition types
   m   print this menu
   n   add a new partition
   o   create a new empty DOS partition table
   p   print the partition table
   q   quit without saving changes
   s   create a new empty Sun disklabel
   t   change a partition's system id
   u   change display/entry units
   v   verify the partition table
   w   write table to disk and exit
   x   extra functionality (experts only)

命令(輸入 m 獲取幫助):t //改變分區系統id
分區號 (1-3,默認 3):3  //指定分區號
Hex 代碼(輸入 L 列出所有代碼):8e  //指定要改成的id號,8e代表LVM
已將分區「Linux」的類型更改為「Linux LVM」

命令(輸入 m 獲取幫助):w
The partition table has been altered!


重啟系統`reboot`後,登陸系統。(一定要重啟系統,否則無法擴充新分區)

# 新分區掛到根目錄

這個時候 `fdisk -l`可以看到新分區了, 然後格式化新分區
mkfs -t ext3 /dev/sda3   //在硬盤分區「/dev/sda3」上創建「ext3」文件系統


這個時候我們可以使用`pvcreate`擴充新分區了

pvcreate指令用於將物理硬盤分區初始化為物理卷,以便被LVM使用。要創建物理卷必須首先對硬盤進行分區,並且將硬盤分區的類型設置為「8e」後,才能使用pvcreat指令將分區初始化為物理卷.
[root@centos1 ~]# pvcreate /dev/sda3
WARNING: ext3 signature detected on /dev/sda3 at offset 1080. Wipe it? [y/n]: y
  Wiping ext3 signature on /dev/sda3.
  Physical volume "/dev/sda3" successfully created.


然後我們使用`vgextend`擴充當前的lvm組,具體lvm組名可以使用下面命令查看
[root@centos1 ~]# vgs
  VG     #PV #LV #SN Attr   VSize   VFree
  centos   1   2   0 wz--n- <19.00g    0

// 對比df 命令和lvs命令
[root@centos1 ~]# df -h
文件系統                 容量  已用  可用 已用% 掛載點
/dev/mapper/centos-root   17G  5.4G   12G   32% /
devtmpfs                 895M     0  895M    0% /dev

[root@centos1 ~]# lvs
  LV   VG     Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  root centos -wi-ao---- <17.00g
  swap centos -wi-ao----   2.00g


知道當前有1個lvm組centos, 下面2個LV. 然後使用`vgextend + lvm組名`
[root@centos1 ~]# vgextend centos /dev/sda3
  Volume group "centos" successfully extended


這個時候可以看到加入的磁盤容量, 前面部分省略, 注意Free PE, 就是我們新增的容量
[root@centos1 ~]# vgdisplay
.....
  Alloc PE / Size       4863 / <19.00 GiB
  Free  PE / Size       5119 / <20.00 GiB
  VG UUID               oU868Z-fAk7-kSaN-wAud-AC3U-WDBh-N75dZS
v

然後擴充空間
[code]
[root@centos1 centos]# lvextend -L+19.8G /dev/centos/root /dev/sda3
  Rounding size to boundary between physical extents: 19.80 GiB.
  Size of logical volume centos/root changed from <17.00 GiB (4351 extents) to <36.80 GiB (9420 extents).
  Logical volume centos/root successfully resized.


最後, 增大"ext2/ext3"文件系統大小
[root@centos1 centos]# xfs_growfs /dev/centos/root
meta-data=/dev/mapper/centos-root isize=512    agcount=4, agsize=1113856 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=0 spinodes=0
data     =                       bsize=4096   blocks=4455424, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
log      =internal               bsize=4096   blocks=2560, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
data blocks changed from 4455424 to 9646080


操作完最後一步, 才能看到根目錄已經擴展為40G了
[root@centos1 centos]# df -h
文件系統                 容量  已用  可用 已用% 掛載點
/dev/mapper/centos-root   37G  5.4G   32G   15% /
devtmpfs                 895M     0  895M    0% /dev



原文出處:给linux虚拟机增加根目录硬盘
冷日
(冷日)
Webmaster
  • 註冊日: 2008/2/19
  • 來自:
  • 發表數: 15771
[轉載]擴展根分區報錯

擴展根分區報錯,xfs_growfs 提示 / is not a mounted XFS filesystem

擴容磁盤後,執行:xfs_growfs / 刷新磁盤容量的時候, 提示:

xfs_growfs: / is not a mounted XFS filesystem

那麼 可能是 文件系統格式對應的刷新命令不對:

特別注意的是:

resize2fs 命令 針對的是ext2、ext3、ext4文件系統

xfs_growfs 命令 針對的是xfs文件系統

可以嘗試實行:

# resize2fs /


原文出處:扩展根分区报错,xfs_growfs 提示 / is not a mounted XFS filesystem-CSDN博客
冷日
(冷日)
Webmaster
  • 註冊日: 2008/2/19
  • 來自:
  • 發表數: 15771
[轉載]CentOS 6 yum repo
[ 分享 ] CentOS 6 的 yum repo 源

CentOS 6 的 EOL ( End of Life ) : 30 November 2020 .

所以 , 不管任何原因 , 如果有人跟我一樣還在使用 CentOS 6 的 , 卻找不到網路上可用的 yum repo , 可以試試看這個 :

請注意 , 這邊提供的是 x86_64 的版本 , 也就是 64 位元 的 CentOS 6 ; 我相信應該沒有人會使用 32 位元 的版本才對 .

( 直接覆蓋掉你 CentOS 6 原本的 CentOS-Base.repo 和 epel.repo 即可 )

方法 ( 共 4 行 指令 ) :
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.vpnforgame.net/centos/6/CentOS-Base.repo

curl -o /etc/yum.repos.d/epel.repo http://mirrors.vpnforgame.net/epel/6/epel.repo

yum clean all

yum makecache

這樣就可以了 , 然後你就可以 yum update 試試看 .


原文出處:[ 分享 ] CentOS 6 的 yum repo 源 . - Mobile01
冷日
(冷日)
Webmaster
  • 註冊日: 2008/2/19
  • 來自:
  • 發表數: 15771
[轉載]command not found xfs_growfs

xfs_growfs

Utilities for managing the XFS filesystem

Install

All systems
curl cmd.cat/xfs_growfs.sh
Debian Debian
apt-get install xfsprogs
Ubuntu
apt-get install xfsprogs
Arch Arch Linux
pacman -S xfsprogs
Kali Linux
apt-get install xfsprogs
CentOS
yum install xfsprogs
Fedora

dnf install xfsprogs
Windows (WSL2)
sudo apt-get update sudo apt-get install xfsprogs
Raspbian
apt-get install xfsprogs
Docker
docker run cmd.cat/xfs_growfs xfs_growfs powered by Commando

原文出處:command-not-found.com – xfs_growfs
前一個主題 | 頁首 | | |



Powered by XOOPS 2.0 © 2001-2008 The XOOPS Project|