我幫助一家橫跨半個國家的公司維護他們在 CentOS 7 上運行的網站和 Web 伺服器。我無法識別新的磁碟空間並將其新增至根分割區。
這是fdisk -l
輸出。
$ sudo fdisk -l
Disk /dev/sda: 322.1 GB, 322122547200 bytes, 629145600 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 label type: dos
Disk identifier: 0x0007be79
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 1026047 512000 83 Linux
/dev/sda2 1026048 266338303 132656128 8e Linux LVM
Disk /dev/sdb: 136.4 GB, 136365211648 bytes, 266338304 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/mapper/centos-root: 53.7 GB, 53687091200 bytes, 104857600 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 /dev/mapper/centos-swap: 4160 MB, 4160749568 bytes, 8126464 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 /dev/mapper/centos-home: 77.9 GB, 77921779712 bytes, 152190976 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
我在這裡很困惑。 /dev/sda 有 322.1 GB,磁碟標籤類型為「dos」。我假設這是新磁碟。
但是上面有sda1和sda2分區。那是作業系統嗎?
我需要在 /dev/mapper/centos-root 分割區新增 300 GB。我怎麼做?
我在下面附上了一些可能有用的其他命令的結果。
$ sudo pvdisplay
--- Physical volume ---
PV Name /dev/sda2
VG Name centos
PV Size 126.51 GiB / not usable 3.00 MiB
Allocatable yes
PE Size 4.00 MiB
Total PE 32386
Free PE 16
Allocated PE 32370
PV UUID vFa16P-F0LF-hpTo-6xca-Wz83-wfoD-GbxNVp
$ sudo lvmdiskscan
/dev/centos/root [ 50.00 GiB]
/dev/sda1 [ 500.00 MiB]
/dev/centos/swap [ <3.88 GiB]
/dev/sda2 [ 126.51 GiB] LVM physical volume
/dev/centos/home [ 72.57 GiB]
/dev/sdb [ 127.00 GiB]
4 disks
1 partition
0 LVM physical volume whole disks
1 LVM physical volume
$ sudo parted -l
Model: Msft Virtual Disk (scsi)
Disk /dev/sda: 322GB
Sector size (logical/physical): 512B/4096B
Partition Table: msdos
Disk Flags:
Number Start End Size Type File system Flags
1 1049kB 525MB 524MB primary xfs boot
2 525MB 136GB 136GB primary lvm
Error: /dev/sdb: unrecognised disk label
Model: Msft Virtual Disk (scsi)
Disk /dev/sdb: 136GB
Sector size (logical/physical): 512B/512B
Partition Table: unknown
Disk Flags:
Model: Linux device-mapper (linear) (dm)
Disk /dev/mapper/centos-home: 77.9GB
Sector size (logical/physical): 512B/4096B
Partition Table: loop
Disk Flags:
Number Start End Size File system Flags
1 0.00B 77.9GB 77.9GB xfs
Model: Linux device-mapper (linear) (dm)
Disk /dev/mapper/centos-swap: 4161MB
Sector size (logical/physical): 512B/4096B
Partition Table: loop
Disk Flags:
Number Start End Size File system Flags
1 0.00B 4161MB 4161MB linux-swap(v1)
Model: Linux device-mapper (linear) (dm)
Disk /dev/mapper/centos-root: 53.7GB
Sector size (logical/physical): 512B/4096B
Partition Table: loop
Disk Flags:
Number Start End Size File system Flags
1 0.00B 53.7GB 53.7GB xfs
答案1
我剛剛發現這個優秀的教程解決了我所有的問題。我經歷了兩次。一次將未使用的/dev/sda空間格式化為LVM分割區,並將其新增至邏輯磁碟區。並第二次格式化新的/dev/sdb磁碟,並將其新增至邏輯磁碟區。
我的 centos-root 磁碟空間從 54 GB 增加到 376 GB!