resize raw image

freebsd# truncate -s +500G disk0.img

[Expert@cpmg:0]# parted
GNU Parted 3.1
Using /dev/sda
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) print
Error: The backup GPT table is not at the end of the disk, as it should be.
This might mean that another operating system believes the disk is smaller.
Fix, by moving the backup to the end (and removing the old backup)?
Fix/Ignore/Cancel?Fix
Warning: Not all of the space available to /dev/sda appears to be used, you can
fix the GPT to use all of the space (an extra 1048576000 blocks) or continue
with the current setting?
Fix/Ignore? Fix
Model: ATA BHYVE SATA DISK (scsi)
Disk /dev/sda: 1074GB
Sector size (logical/physical): 512B/65536B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
1 17.4kB 315MB 315MB ext3 boot
2 315MB 17.1GB 16.8GB linux-swap(v1)
3 17.1GB 537GB 520GB lvm
(parted)
(parted) print free
Model: ATA BHYVE SATA DISK (scsi)
Disk /dev/sda: 1074GB
Sector size (logical/physical): 512B/65536B
Partition Table: gpt
Disk Flags:

Number Start End Size File system Name Flags
1 17.4kB 315MB 315MB ext3 boot
2 315MB 17.1GB 16.8GB linux-swap(v1)
3 17.1GB 537GB 520GB lvm
537GB 1074GB 537GB Free Space

unit s

(parted) print free
Model: ATA BHYVE SATA DISK (scsi)
Disk /dev/sda: 2097152000s
Sector size (logical/physical): 512B/65536B
Partition Table: gpt
Disk Flags:

Number Start End Size File system Name Flags
1 34s 614433s 614400s ext3 boot
2 614434s 33435228s 32820795s linux-swap(v1)
3 33435229s 1015140738s 981705510s opt
1015140739s 2097151966s 1082011228s Free Space

(parted) rm 3
Error: Partition(s) 3 on /dev/sda have been written, but we have been unable to
inform the kernel of the change, probably because it/they are in use. As a
result, the old partition(s) will remain in use. You should reboot now before
making further changes.
Ignore/Cancel? Ignore

(parted) mkpart lvm 33435229s 2097151966s
Warning: The resulting partition is not properly aligned for best performance.
Ignore/Cancel? Ignore
Error: Partition(s) 3 on /dev/sda have been written, but we have been unable to
inform the kernel of the change, probably because it/they are in use. As a
result, the old partition(s) will remain in use. You should reboot now before
making further changes.
Ignore/Cancel? Ignore

(parted) set 3 lvm
New state? [on]/off? on
Error: Partition(s) 3 on /dev/sda have been written, but we have been unable to
inform the kernel of the change, probably because it/they are in use. As a
result, the old partition(s) will remain in use. You should reboot now before
making further changes.
Ignore/Cancel? Ignore
(parted) print free
Model: ATA BHYVE SATA DISK (scsi)
Disk /dev/sda: 2097152000s
Sector size (logical/physical): 512B/65536B
Partition Table: gpt
Disk Flags:

Number Start End Size File system Name Flags
1 34s 614433s 614400s ext3 boot
2 614434s 33435228s 32820795s linux-swap(v1)
3 33435229s 2097151966s 2063716738s lvm lvm

(parted)

partprobe /dev/sda
Error: Partition(s) 3 on /dev/sda have been written, but we have been unable to inform the kernel of the change, probably because it/they are in use. As a result, the old partition(s) will remain in use. You should reboot now before making further changes.
pvresize /dev/sda3
[Expert@cpmg:0]# pvdisplay
--- Physical volume ---
PV Name /dev/sda3
VG Name vg_splat
PV Size 484.06 GiB / not usable 26.19 MiB
Allocatable yes
PE Size 32.00 MiB
Total PE 15489
Free PE 6625
Allocated PE 8864
PV UUID tHI2xN-SBLH-jVjy-9krd-s0av-LeHZ-hnxXrZ

[Expert@cpmg:0]# pvresize /dev/sda3
Physical volume "/dev/sda3" changed
1 physical volume(s) resized / 0 physical volume(s) not resized
[Expert@cpmg:0]# pvdisplay
--- Physical volume ---
PV Name /dev/sda3
VG Name vg_splat
PV Size 984.06 GiB / not usable 25.19 MiB
Allocatable yes
PE Size 32.00 MiB
Total PE 31489
Free PE 22625
Allocated PE 8864
PV UUID tHI2xN-SBLH-jVjy-9krd-s0av-LeHZ-hnxXrZ

[Expert@cpmg:0]#