Linux

分區未使用完整空間

  • April 3, 2016

sda5分區有 1953 GB,但dev/mapper/MediaServer--vg-root實際上只使用了 496 GB。如何擴展dev/mapper/MediaServer--vg-root以利用整個空間?

sudo fdisk -l

Disk /dev/sda: 2000.4 GB, 2000398934016 bytes
255 heads, 63 sectors/track, 243201 cylinders, total 3907029168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x000a9ebd

  Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048      499711      248832   83  Linux
/dev/sda2          501758  3907028991  1953263617    5  Extended
Partition 2 does not start on physical sector boundary.
/dev/sda5          501760  3907028991  1953263616   8e  Linux LVM

Disk /dev/mapper/MediaServer--vg-root: 495.9 GB, 495909339136 bytes
255 heads, 63 sectors/track, 60290 cylinders, total 968572928 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x00000000

Disk /dev/mapper/MediaServer--vg-root doesn't contain a valid partition table

Disk /dev/mapper/MediaServer--vg-swap_1: 3883 MB, 3883925504 bytes
255 heads, 63 sectors/track, 472 cylinders, total 7585792 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x00000000

Disk /dev/mapper/MediaServer--vg-swap_1 doesn't contain a valid partition table

您可以執行 lvextend 來增加邏輯卷的大小:

sudo lvextend /dev/mapper/MediaServer--vg-root

您還需要擴展文件系統以利用新空間。對於 ext2/3/4 文件系統,執行:

sudo resize2fs /dev/mapper/MediaServer--vg-root

如果您正在執行現代版本的 Linux,您應該能夠線上完成所有這些操作。標準警告適用於儲存混亂和數據失去的可能性。備份重要文件並謹慎操作。

如果這不起作用,很高興看到您的 lvm 結構。這應該會提供一些有用的調試資訊:

sudo pvdisplay 
sudo vgdisplay
sudo lvdisplay

引用自:https://serverfault.com/questions/766151