天天看點

linux根目錄擴容方法,Linux系統擴容根目錄磁盤空間的操作方法

問題描述

系統的服務無法正常運作,檢視磁盤空間,發現根目錄已經滿了

linux根目錄擴容方法,Linux系統擴容根目錄磁盤空間的操作方法

解決過程

1.添加磁盤空間

2.使用fdisk -l指令檢視磁盤資訊

3.建立磁盤分區

4.使用fdisk /dev/sda3, 建立新分區。

按照下面Linux操作進行分區。

[email protected]:/opt# fdisk /dev/sda3

指令(輸入 m 擷取幫助): m

指令操作

a toggle a bootable flag

b edit bsd disklabel

c toggle the dos compatibility flag

d delete a partition

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 #new 新分區

Partition type:

p primary (1 primary, 1 extended, 2 free)

l logical (numbered from 5)

Select (default p): p #選擇主分區

分區号 (1-4,預設為 3): 3 #分區序号

起始 sector (499712-314572799,預設為 499712): #分區開始回車預設

将使用預設值 499712

Last sector, +扇區 or +size{K,M,G} (499712-501757,預設為 501757):

将使用預設值 501757

指令(輸入 m 擷取幫助): n #new 新分區

Partition type:

p primary (2 primary, 1 extended, 1 free)

l logical (numbered from 5)

Select (default p): p #選擇主分區

Selected partition 4 #分區序号

起始 sector (62912512-314572799,預設為 62912512): #分區開始回車預設

将使用預設值 62912512

Last sector, +扇區 or +size{K,M,G} (62912512-314572799,預設為 314572799):

将使用預設值 314572799

指令(輸入 m 擷取幫助): t #修改分區格式

分區号 (1-5): 4 #修改分區号

Hex code (type L to list codes): 8e #格式選擇8e linux LVM

Changed system type of partition 4 to 8e (Linux LVM)

指令(輸入 m 擷取幫助): p #顯示分區資訊

Disk /dev/vda: 161.1 GB, 161061273600 bytes

16 heads, 63 sectors/track, 312076 cylinders, total 314572800 sectors

Units = 扇區 of 1 * 512 = 512 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x0001a023

裝置 啟動 起點 終點 塊數 Id 系統

/dev/vda1 * 2048 499711 248832 83 Linux

/dev/vda2 501758 62912511 31205377 5 擴充

/dev/vda3 499712 501757 1023 83 Linux

/dev/vda4 62912512 314572799 125830144 8e Linux LVM

/dev/vda5 501760 62912511 31205376 8e Linux LVM

Partition table entries are not in disk order

指令(輸入 m 擷取幫助): w #儲存資訊

The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: 裝置或資源忙.

The kernel still uses the old table. The new table will be used at

the next reboot or after you run partprobe(8) or kpartx(8)

Syncing disks.

linux根目錄擴容方法,Linux系統擴容根目錄磁盤空間的操作方法

5.重新開機Linux作業系統,使用reboot指令。

6.建立實體卷,使用pvcreate /dev/sda3指令。

linux根目錄擴容方法,Linux系統擴容根目錄磁盤空間的操作方法

7.将添加新的實體卷,加載到centos卷組,使用vgextend centos /dev/sda3指令。

linux根目錄擴容方法,Linux系統擴容根目錄磁盤空間的操作方法

8.增加/dev/mapper/centos-root大小,增加50G。使用lvresize -L +50G /dev/mapper/centos-root指令。

linux根目錄擴容方法,Linux系統擴容根目錄磁盤空間的操作方法

9.同步檔案系統。

linux根目錄擴容方法,Linux系統擴容根目錄磁盤空間的操作方法

10.檢視擴容後的大小 ,使用df -h指令。

linux根目錄擴容方法,Linux系統擴容根目錄磁盤空間的操作方法

參考: