0

I create new virtual machine in OpenStack Project.

After I want to add size free space in VM.

I added new Volume and attached to VM.

After start VM I tryed to check status HDD.

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

after I tried create new primary partition

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

How to expand the root volume /dev/vda1 5.0G 2.4G 2.6G 48% / new volume /dev/vdb1 ?

  • Have you considered enlarging the existing disk instead of adding a new one? Then you'd be able to grow the partition and filesystem. To do so with another disk you need to either have the filesystem on an LVM logical volume or use a filesystem with volume management (ex. ZFS, BTRFS). – Emmanuel Rosa Mar 10 at 23:38
0

I dont believe you can expand one harddisk to another. You could copy vda to vdb and then use vdb as your "/" harddisk. Try dd or any volume copy tool. After copy, you can expand the partitions to the desired size.

  • The OP has tagged the partition on /dev/vdb1 as LVM. I would assume that performing a raw copy from /dev/vda to /dev/vdb would therefore be counterproductive. – roaima Mar 10 at 20:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.