我有一台专用服务器,我将用它在 KVM 之上构建虚拟机(谢谢 Virtualizor),问题是,我无法物理访问该机器,因为它是从一家大公司租来的,我需要弄清楚如何将 2 个存储分组为 1 个卷,如果有人认为一个系统比其他存储更容易管理卷组,我可以更改系统,我有操作系统选项(虚拟化器支持和专用提供商)允许:CentOS 7 或 Ubuntu 16.04(x86_64) 并且机器有 2 个 960GB SSD
我面临的问题(我目前使用的是 CentOS 7)是:
- 因为我使用一个磁盘,所以我不知道如何在使用时管理它
- 根目录几乎拥有一个磁盘的所有空间,还剩 60MB
- 我不知道如何将它们设置在一个卷组中
我相信我理解了文档中关于如何减小根大小的部分,但是如果您能更清楚地描述该过程、步骤以及步骤是什么,我真诚地感激。因此,如果我可以减小根大小,剩下的唯一一件事就是将 2 个磁盘合并到一个卷组中,我已尝试扩展它,但我可能错过了一些东西 IDK
[root@server]# fdisk /dev/sda
Welcome to fdisk (util-linux 2.23.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Command (m for help): p
Disk /dev/sda: 960.2 GB, 960197124096 bytes, 1875385008 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 label type: dos
Disk identifier: 0x00023b47
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 2099199 1048576 83 Linux
[root@server]# vgs
VG #PV #LV #SN Attr VSize VFree
vg 1 3 0 wz--n- 894.25g 60.00m
[root@server]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg-root 876G 3.0G 828G 1% /
devtmpfs 63G 0 63G 0% /dev
tmpfs 63G 0 63G 0% /dev/shm
tmpfs 63G 9.6M 63G 1% /run
tmpfs 63G 0 63G 0% /sys/fs/cgroup
/dev/sda1 1008M 143M 815M 15% /boot
/dev/mapper/vg-tmp 976M 2.6M 907M 1% /tmp
tmpfs 13G 0 13G 0% /run/user/0
[root@server]# pvdisplay
--- Physical volume ---
PV Name /dev/sdb1
VG Name vg
PV Size 894.25 GiB / not usable 2.00 MiB
Allocatable yes
PE Size 4.00 MiB
Total PE 228928
Free PE 15
Allocated PE 228913
PV UUID kytvOh-HaSm-OOo3-l7OM-nbkk-QyQf-Mx1gCu
[root@server]# pvscan
PV /dev/sdb1 VG vg lvm2 [894.25 GiB / 60.00 MiB free]
Total: 1 [894.25 GiB] / in use: 1 [894.25 GiB] / in no VG: 0 [0 ]
[root@server]# fdisk -l
Disk /dev/sdb: 960.2 GB, 960197124096 bytes, 1875385008 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 label type: dos
Disk identifier: 0x0001c70b
Device Boot Start End Blocks Id System
/dev/sdb1 2048 1875384319 937691136 8e Linux LVM
Disk /dev/sda: 960.2 GB, 960197124096 bytes, 1875385008 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 label type: dos
Disk identifier: 0x00023b47
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 2099199 1048576 83 Linux
Disk /dev/mapper/vg-root: 954.8 GB, 954762002432 bytes, 1864769536 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/vg-swap: 4294 MB, 4294967296 bytes, 8388608 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/vg-tmp: 1073 MB, 1073741824 bytes, 2097152 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
答案1
您要做的第一件事是在/dev/sda
设备上创建新分区。假设您将创建/dev/sda2
.您可以使用以下命令来完成此操作:
fdisk /dev/sda
n - to create new partition
t -> 8e - to change partition type to Linux LVM
w - to write changes and exit
然后必须让内核知道新分区已创建:
partprobe /dev/sda2
此命令将为/dev/sda2
LVM 初始化分区,并将它们添加到现有卷组中:
pvcreate /dev/sda2
vgextend vg /dev/sda2
然后,您可以扩展现有逻辑卷或使用lvextend
或创建新逻辑卷lvcreate
。您可以创建几种类型的逻辑卷:线性、条带、RAID。如何使用空间取决于您。
如果您选择扩展现有 LV,您还必须调整文件系统(xfs_growfs
或resize2fs
EXT)的大小。如果您选择创建新的 LV,则必须使用mkfs
命令在其上创建文件系统。