V tomto případě jde spíše o grow disk, tedy „růst“ disku. V té češtině to zní příšerně, uznávám.
Máme .qcow2 image s virtuálkou pro KVM. Jakékoliv ostatní např. instalační image jsou k dispozici zde.
Na linuxu jsem dal qemu-img resize
qemu-img info FreeBSD-13.1-RELEASE-amd64.qcow2
image: FreeBSD-13.1-RELEASE-amd64.qcow2
file format: qcow2
virtual size: 5 GiB (6877755392 bytes)
disk size: 3.87 GiB
cluster_size: 65536
Format specific information:
compat: 0.10
refcount bits: 16
# qemu-img resize FreeBSD-13.1-RELEASE-amd64.qcow2 26G
Image resized.
# qemu-img info FreeBSD-13.1-RELEASE-amd64.qcow2
image: FreeBSD-13.1-RELEASE-amd64.qcow2
file format: qcow2
virtual size: 26 GiB (27917287424 bytes)
disk size: 3.87 GiB
cluster_size: 65536
Format specific information:
compat: 0.10
refcount bits: 16
Uvnitř virtuálky s FreeBSD
# gpart show
=> 3 10552571 vtbd0 GPT (26G) [CORRUPT]
3 123 1 freebsd-boot (62K)
126 66584 2 efi (33M)
66710 2097152 3 freebsd-swap (1.0G)
2163862 8388712 4 freebsd-ufs (4.0G)
root@freebsd:~ #
root@freebsd:~ # gpart recover
gpart: Invalid number of arguments.
root@freebsd:~ # gpart recover vtbd0
vtbd0 recovered
root@freebsd:~ # gpart show
=> 3 54525941 vtbd0 GPT (26G)
3 123 1 freebsd-boot (62K)
126 66584 2 efi (33M)
66710 2097152 3 freebsd-swap (1.0G)
2163862 8388712 4 freebsd-ufs (4.0G)
10552574 43973370 - free - (21G)
Zvětšíme partition uvnitř FreeBSD virtuálky na 21 GB
# gpart show
=> 3 54525941 vtbd0 GPT (26G)
3 123 1 freebsd-boot (62K)
126 66584 2 efi (33M)
66710 2097152 3 freebsd-swap (1.0G)
2163862 8388712 4 freebsd-ufs (4.0G)
10552574 43973370 - free - (21G)
root@freebsd:~ #
root@freebsd:~ # gpart resize -i 4 -s 21G -a 4k vtbd0 # -i 4 je pořadové číslo partition, -s je cílová velikost 21G, -a 4K je velikost bloku a vtbd0 je název disku
vtbd0p4 resized
root@freebsd:~ # gpart show
=> 3 54525941 vtbd0 GPT (26G)
3 123 1 freebsd-boot (62K)
126 66584 2 efi (33M)
66710 2097152 3 freebsd-swap (1.0G)
2163862 44040186 4 freebsd-ufs (21G)
46204048 8321896 - free - (4.0G)
Jde to i v MB 😉
gpart resize -i 4 -s 25567M -a 4k vtbd0
vtbd0p4 resized
root@freebsd:~ # gpart show
=> 3 54525941 vtbd0 GPT (26G)
3 123 1 freebsd-boot (62K)
126 66584 2 efi (33M)
66710 2097152 3 freebsd-swap (1.0G)
2163862 52361210 4 freebsd-ufs (25G)
54525072 872 - free - (436K)
Ještě grow Filesystem
root@freebsd:~ # df -Th
Filesystem Type Size Used Avail Capacity Mounted on
/dev/gpt/rootfs ufs 3.9G 3.9G -315M 109% /
devfs devfs 1.0K 1.0K 0B 100% /dev
/dev/gpt/efiesp msdosfs 32M 875K 31M 3% /boot/efi
root@freebsd:~ # growfs /dev/gpt/rootfs
Device is mounted read-write; resizing will result in temporary write suspension for /.
It's strongly recommended to make a backup before growing the file system.
OK to grow filesystem on /dev/gpt/rootfs, mounted on /, from 4.0GB to 25GB? [yes/no] yes
super-block backups (for fsck_ffs -b #) at:
8979008, 10261696, 11544384, 12827072, 14109760, 15392448, 16675136, 17957824, 19240512,
20523200, 21805888, 23088576, 24371264, 25653952, 26936640, 28219328, 29502016, 30784704,
32067392, 33350080, 34632768, 35915456, 37198144, 38480832, 39763520, 41046208, 42328896,
43611584, 44894272, 46176960, 47459648, 48742336, 50025024, 51307712
Hotovo!
root@freebsd:~ # df -Th
Filesystem Type Size Used Avail Capacity Mounted on
/dev/gpt/rootfs ufs 24G 3.9G 18G 17% /
devfs devfs 1.0K 1.0K 0B 100% /dev
/dev/gpt/efiesp msdosfs 32M 875K 31M 3% /boot/efi