附加新卷后如何扩展根卷?

附加新卷后如何扩展根卷?

我在 OpenStack 项目中创建新的虚拟机。

在我想在虚拟机中添加大小的可用空间之后。

我添加了新卷并附加到虚拟机。

启动虚拟机后,我尝试检查硬盘状态。

fdisk -l

Disk /dev/vda: 5368 MB, 5368709120 bytes, 10485760 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: 0x000ad846

   Device Boot      Start         End      Blocks   Id  System
/dev/vda1   *        2048    10485759     5241856   83  Linux

Disk /dev/vdb: 155.7 GB, 155692564480 bytes, 304087040 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

lsblk-f

NAME   FSTYPE LABEL UUID                                 MOUNTPOINT
vda
└─vda1 xfs          b22f809d-38b7-43fd-8eda-22acb001877f /
vdb

df-h

Filesystem      Size  Used Avail Use% Mounted on
devtmpfs        7.7G     0  7.7G   0% /dev
tmpfs           7.8G     0  7.8G   0% /dev/shm
tmpfs           7.8G   17M  7.7G   1% /run
tmpfs           7.8G     0  7.8G   0% /sys/fs/cgroup
/dev/vda1       5.0G  2.4G  2.6G  48% /
tmpfs           1.6G     0  1.6G   0% /run/user/20226

在我尝试创建新的主分区后

fdisk /dev/vdb

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.

Device does not contain a recognized partition table
Building a new DOS disklabel with disk identifier 0xa9dbcbca.

Command (m for help): p

Disk /dev/vdb: 155.7 GB, 155692564480 bytes, 304087040 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: 0xa9dbcbca

   Device Boot      Start         End      Blocks   Id  System

Command (m for help): n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-304087039, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-304087039, default 304087039):
Using default value 304087039
Partition 1 of type Linux and of size 145 GiB is set

Command (m for help): t
Selected partition 1
Hex code (type L to list all codes): 8e
Changed type of partition 'Linux' to 'Linux LVM'

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

fdisk -l

Disk /dev/vda: 5368 MB, 5368709120 bytes, 10485760 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: 0x000ad846

   Device Boot      Start         End      Blocks   Id  System
/dev/vda1   *        2048    10485759     5241856   83  Linux

Disk /dev/vdb: 155.7 GB, 155692564480 bytes, 304087040 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: 0xa9dbcbca

   Device Boot      Start         End      Blocks   Id  System
/dev/vdb1            2048   304087039   152042496   8e  Linux LVM

如何扩大根卷 /dev/vda1 5.0G 2.4G 2.6G 48% / 新卷 /dev/vdb1

答案1

我不相信你可以将一个硬盘扩展到另一个硬盘。您可以将 vda 复制到 vdb,然后使用 vdb 作为“/”硬盘。尝试 dd 或任何卷复制工具。复制完成后,您可以将分区扩​​展到所需的大小。

相关内容