本產品的文件集力求使用無偏見用語。針對本文件集的目的,無偏見係定義為未根據年齡、身心障礙、性別、種族身分、民族身分、性別傾向、社會經濟地位及交織性表示歧視的用語。由於本產品軟體使用者介面中硬式編碼的語言、根據 RFP 文件使用的語言,或引用第三方產品的語言,因此本文件中可能會出現例外狀況。深入瞭解思科如何使用包容性用語。
思科已使用電腦和人工技術翻譯本文件,讓全世界的使用者能夠以自己的語言理解支援內容。請注意,即使是最佳機器翻譯,也不如專業譯者翻譯的內容準確。Cisco Systems, Inc. 對這些翻譯的準確度概不負責,並建議一律查看原始英文文件(提供連結)。
本文檔介紹如何向Linux虛擬機器(VM)新增磁碟空間。
Linux(和Linux VM)安裝在硬碟上,無論是真實硬碟還是虛擬硬碟。其頂部堆疊了一個卷管理器,後跟一個檔案系統,通常使用檔案系統。
對於Linux虛擬機器,需要執行以下步驟才能增加檔案系統的大小:
附註:許多調整大小選項都存在風險,可能會使虛擬機器處於不可啟動的狀態或資料損壞。請小心。
附註:在增加磁碟空間之前,請確保已經清理了現有檔案系統。/tmp、/var/tmp、/var/tmp/broadhop和/var/log中通常有一些檔案是不需要的,可以刪除這些檔案而不是增加磁碟空間。
#df -h檔案系統:_____________________________裝載於:_________________________
以下是df -h指令的輸出範例:
[root@sessionmgr02 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
18G 2.4G 15G 15% /
/dev/mapper/VolGroup00-LogVol02
5.7G 140M 5.3G 3% /home
/dev/mapper/VolGroup00-LogVol03
30G 27G 1.5G 97% /data
/dev/sda1 99M 40M 55M 43% /boot
tmpfs 16G 0 16G 0% /dev/shm
tmpfs 8.0G 1.1G 7.0G 13% /data/sessions.1
# pvdisplayPV名稱:_____________________________________
以下是pvdisplay命令的輸出示例:
[root@sessionmgr02 ~]# pvdisplay
--- Physical volume ---
PV Name /dev/sda2
VG Name VolGroup00
PV Size 69.89 GB / not usable 18.64 MB
Allocatable yes
PE Size (KByte) 32768
Total PE 2236
Free PE 320
Allocated PE 1916
PV UUID HO3ICX-nRhO-FaBA-MvB3-Zlzv-JLG4-vNFQeU
附註:PV名稱(/dev/sda2)顯示兩件事。第一部分(/dev/sda)顯示裝置,第二部分(2)顯示分割槽號。
要新增的磁碟空間<amount>:____________________________________
# vgdisplay
Alloc PE / Size:________________________Free PE / Size:_________________________
以下顯示vgdisplay命令的輸出示例:
[root@sessionmgr02 ~]# vgdisplay
--- Volume group ---
VG Name VolGroup00
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 9
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 74.88 GB
PE Size 32.00 MB
Total PE 2396
Alloc PE / Size 1916 / 59.88 GB
Free PE / Size 480 / 15.00 GB
VG UUID pPSNBU-FRWO-z3aC-iAxS-ewaw-jOFT-dTcBKd
附註:如果有足夠的可用空間用於此擴展,請繼續執行第4部分。如果沒有足夠的可用空間,請停止此過程並在繼續之前向資料儲存區新增磁碟空間。
# shutdown -h now
此範例顯示shutdown -h now命令的輸出:
[root@sessionmgr02 ~]# shutdown -h now
Broadcast message from root (pts/0) (Wed Dec 18 11:48:20 2013):
The system is going down for system halt NOW!
附註:增加的數量必須小於資料儲存上的可用空間量。 請勿過度調配。
附註:等待5分鐘,等待VM完全載入。
# ssh
此示例顯示ssh命令的輸出:
[root@pcrfclient01 ~]# ssh 172.10.1.30
\\Last login: Wed Dec 18 11:48:14 2013 from 172.10.1.9
Spacewalk kickstart on 2010-08-23
[root@sessionmgr02 ~]#
# fdisk -l /dev/sda
磁碟大小:_______________________________
此示例顯示fdisk -l /dev/sda命令的輸出:
[root@sessionmgr02 ~]# fdisk -l /dev/sda
Disk /dev/sda2: 75.0 GB, 75047454720 bytes
255 heads, 63 sectors/track, 9124 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
此示例輸出顯示/dev/sda2當前已為其分配了75G。
# fdisk
此示例顯示fdisk /dev/sda命令的輸出:
[root@sessionmgr02 ~]# fdisk /dev/sda
The number of cylinders for this disk is set to 9137.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)
Command (m for help):
Command (m for help): p
此範例顯示輸入字母「p」後顯示分割槽表的輸出:
Command (m for help): p
Disk /dev/sda: 75.1 GB, 75161927680 bytes
255 heads, 63 sectors/track, 9137 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 9137 73288530 8e Linux LVM
Command (m for help):
開始:_______________________Id:_________________________
Command (m for help): d
此範例顯示輸入d後的結果:
Disk /dev/sda: 75.1 GB, 75161927680 bytes
255 heads, 63 sectors/track, 9137 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 9137 73288530 8e Linux LVM
Command (m for help): d
Partition number (1-4):
Partition number (1-4): <number>
此示例顯示輸入分割槽編號後的結果:
Disk /dev/sda: 75.1 GB, 75161927680 bytes
255 heads, 63 sectors/track, 9137 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 9137 73288530 8e Linux LVM
Command (m for help): d
Partition number (1-4): 2
Command (m for help):
Command (m for help): n
此範例顯示輸入n後的結果:
Disk /dev/sda: 75.1 GB, 75161927680 bytes
255 heads, 63 sectors/track, 5221 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 9137 73288530 8e Linux LVM
Command (m for help): d
Partition number (1-4): 2
Command (m for help): n
Command action
e extended
p primary partition (1-4)
Command (m for help): n
Command (m for help): p
此範例顯示輸入p後的輸出:
Disk /dev/sda: 75.1 GB, 75161927680 bytes
255 heads, 63 sectors/track, 5221 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 9137 73288530 8e Linux LVM
Command (m for help): d
Partition number (1-4): 2
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4):
Partition number (1-4): 2
此示例顯示輸入分割槽編號後的結果:
Disk /dev/sda: 75.1 GB, 75161927680 bytes
255 heads, 63 sectors/track, 5221 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 9137 73288530 8e Linux LVM
Command (m for help): d
Partition number (1-4): 2
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 2
First cylinder (14-9137, default 14):
此範例顯示接受預設值並按Enter鍵後的結果:
Disk /dev/sda: 75.1 GB, 75161927680 bytes
255 heads, 63 sectors/track, 5221 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 9137 73288530 8e Linux LVM
Command (m for help): d
Partition number (1-4): 2
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 2
First cylinder (14-9790, default 14):
Using default value 14
Last cylinder or +size or +sizeM or +sizeK (14-9790, default 9790):
此示例顯示接受預設值並按Enter鍵後的結果:
Disk /dev/sda: 75.1 GB, 75161927680 bytes
255 heads, 63 sectors/track, 5221 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 9137 73288530 8e Linux LVM
Command (m for help): d
Partition number (1-4): 2
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 2
First cylinder (14-9790, default 14):
Using default value 14
Last cylinder or +size or +sizeM or +sizeK (14-9790, default 9790):
Using default value 9790
Command (m for help):
Command (m for help): t
此範例顯示輸入t後的結果:
Disk /dev/sda: 75.1 GB, 75161927680 bytes
255 heads, 63 sectors/track, 5221 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 9137 73288530 8e Linux LVM
Command (m for help): d
Partition number (1-4): 2
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 2
First cylinder (14-9790, default 14):
Using default value 14
Last cylinder or +size or +sizeM or +sizeK (14-9790, default 9790):
Using default value 9790
Command (m for help): t
Partition number (1-4):
Partition number (1-4): 2
此示例顯示輸入分割槽編號後的結果:
Disk /dev/sda: 75.1 GB, 75161927680 bytes
255 heads, 63 sectors/track, 5221 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 9137 73288530 8e Linux LVM
Command (m for help): d
Partition number (1-4): 2
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 2
First cylinder (14-9790, default 14):
Using default value 14
Last cylinder or +size or +sizeM or +sizeK (14-9790, default 9790):
Using default value 9790
Command (m for help): t
Partition number (1-4): 2
Hex code (type L to list codes):
Hex code (type L to list codes): 8e
此示例顯示輸入十六進位制代碼後的結果:
Disk /dev/sda: 75.1 GB, 75161927680 bytes
255 heads, 63 sectors/track, 5221 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 9137 73288530 8e Linux LVM
Command (m for help): d
Partition number (1-4): 2
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 2
First cylinder (14-9790, default 14):
Using default value 14
Last cylinder or +size or +sizeM or +sizeK (14-9790, default 9790):
Using default value 9790
Command (m for help): t
Partition number (1-4): 2
Hex code (type L to list codes): 8e
Changed system type of partition 2 to 8e (Linux LVM)
Command (m for help):
Command (m for help): w
此範例顯示您在提示中輸入w後的結果:
Disk /dev/sda: 75.1 GB, 75161927680 bytes
255 heads, 63 sectors/track, 5221 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 9137 73288530 8e Linux LVM
Command (m for help): d
Partition number (1-4): 2
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 2
First cylinder (14-9790, default 14):
Using default value 14
Last cylinder or +size or +sizeM or +sizeK (14-9790, default 9790):
Using default value 9790
Command (m for help): t
Partition number (1-4): 2
Hex code (type L to list codes): 8e
Changed system type of partition 2 to 8e (Linux LVM)
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table.
The new table will be used at the next reboot.
Syncing disks.
[root@sessionmgr02 ~]#
這會退出fdisk並進入根提示。
# init 6
[root@sessionmgr02 ~]# fdisk -l /dev/sda
Disk /dev/sda2: 80.4 GB, 80418562560 bytes
255 heads, 63 sectors/track, 9777 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
此示例輸出顯示/dev/sda現在已為其分配了80GB。
警告:這個過程有點危險。 請小心。
# pvresize /dev/sda2
此範例顯示輸入pvresize命令後的結果:
[root@sessionmgr02 ~]# pvresize /dev/sda2
Physical volume "/dev/sda2" changed
1 physical volume(s) resized / 0 physical volume(s) not resized
此範例顯示輸入vgdisplay命令後的結果:
[root@sessionmgr02 ~]# vgdisplay
--- Volume group ---
VG Name VolGroup00
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 9
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 74.88 GB
PE Size 32.00 MB
Total PE 2396
Alloc PE / Size 1916 / 59.88 GB
Free PE / Size 480 / 15.00 GB
VG UUID pPSNBU-FRWO-z3aC-iAxS-ewaw-jOFT-dTcBKd
該示例顯示在上一節中新增的磁碟空間。
從df命令的輸出中記錄「檔案系統」和「已掛載」的值。
# df -h
檔案系統:_______________________裝載於:__________________________
[root@sessionmgr02 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
18G 2.4G 15G 15% /
/dev/mapper/VolGroup00-LogVol02
5.7G 140M 5.3G 3% /home
/dev/mapper/VolGroup00-LogVol03
30G 27G 1.5G 97% /data
/dev/sda1 99M 40M 55M 43% /boot
tmpfs 16G 0 16G 0% /dev/shm
tmpfs 8.0G 1.1G 7.0G 13% /data/sessions.1
要新增的磁碟空間<amount>:____________________________
# lvextend -L+5G /dev/mapper/VolGroup-LogVol-03
此範例顯示輸入lvextend命令後的結果:
[root@sessionmgr02 ~]# lvextend -L+5G /dev/mapper/VolGroup00-LogVol03
Extending logical volume LogVol03 to 45.00 GB
Logical volume LogVol03 successfully resized
[root@sessionmgr02 ~]#
這會將新新增的空間新增到邏輯卷。
警告:完成此命令可能需要一些時間。
# resize2fs <filesystem>
此範例顯示輸入resize2fs命令後的結果:
[root@sessionmgr02 ~]# resize2fs /dev/mapper/VolGroup00-LogVol03
resize2fs 1.39 (29-May-2006)
Filesystem at /dev/mapper/VolGroup00-LogVol03 is
mounted on /data; on-line resizing required
Performing an on-line resize of /dev/mapper/VolGroup00-LogVol03
to 11796480 (4k) blocks.
The filesystem on /dev/mapper/VolGroup00-LogVol03 is now 11796480 blocks long.
[root@sessionmgr02 ~]#
# df -h
輸入df -h命令得到的結果示例:
[root@sessionmgr02 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
18G 2.4G 15G 15% /
/dev/mapper/VolGroup00-LogVol02
5.7G 140M 5.3G 3% /home
/dev/mapper/VolGroup00-LogVol03
44G 22G 21G 52% /data
/dev/sda1 99M 40M 55M 43% /boot
tmpfs 16G 0 16G 0% /dev/shm
tmpfs 8.0G 4.0K 8.0G 1% /data/sessions.1
修訂 | 發佈日期 | 意見 |
---|---|---|
1.0 |
29-Jun-2015 |
初始版本 |