Resize ext4 Partition with virsh and fdisk

aslinya begini :

samsul@openstack:~$ df -h
Filesystem      Size  Used Avail Use% Mounted on
udev            3.9G     0  3.9G   0% /dev
tmpfs           804M  760K  804M   1% /run
/dev/vda1        20G  4.7G   14G  26% /
tmpfs           4.0G     0  4.0G   0% /dev/shm
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs           4.0G     0  4.0G   0% /sys/fs/cgroup
tmpfs           804M     0  804M   0% /run/user/1000

While the VM is running, run this from the host:

root@piccolo ~# virsh blockresize openstack /home/samsul/virsh/openstack.img 70GB
Block device '/home/samsul/virsh/openstack.img' is resized
root@piccolo ~#

Resize with fdisk:

samsul@openstack:~$ sudo -i
root@openstack:~# fdisk /dev/vda

Welcome to fdisk (util-linux 2.31.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.


Command (m for help): d
Selected partition 1
Partition 1 has been deleted.

Command (m for help): n
Partition type
   p   primary (0 primary, 0 extended, 4 free)
   e   extended (container for logical partitions)
Select (default p): 

Using default response p.
Partition number (1-4, default 1): 
First sector (2048-136718749, default 2048): 
Last sector, +sectors or +size{K,M,G,T,P} (2048-136718749, default 136718749): 

Created a new partition 1 of type 'Linux' and of size 65.2 GiB.
Partition #1 contains a ext4 signature.

Do you want to remove the signature? [Y]es/[N]o: n

Command (m for help): w

The partition table has been altered.
Syncing disks.

root@openstack:~# reboot

see the result :

samsul@openstack:~$ sudo -i
root@openstack:~# resize2fs /dev/vda1
resize2fs 1.44.1 (24-Mar-2018)
Filesystem at /dev/vda1 is mounted on /; on-line resizing required
old_desc_blocks = 6, new_desc_blocks = 9
The filesystem on /dev/vda1 is now 17089587 (4k) blocks long.

root@openstack:~# df -h
Filesystem      Size  Used Avail Use% Mounted on
udev            3.9G     0  3.9G   0% /dev
tmpfs           804M  752K  804M   1% /run
/dev/vda1        65G  4.7G   57G   8% /
tmpfs           4.0G     0  4.0G   0% /dev/shm
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs           4.0G     0  4.0G   0% /sys/fs/cgroup
tmpfs           804M     0  804M   0% /run/user/1000
root@openstack:~# 

Beress

  • linux/Resize.ext4.Partition.with.virsh.and.fdisk
  • Terakhir diubah: 9 bulan yang lalu
  • (Perubahan eksternal)