Archive for the Disks Category

May 26 2021

KVM – detach disk

sudo virsh detach-disk --domain test --persistent --live --target vdb

May 12 2021

KVM – Add / Attach Disk

Create disk:
qemu-img create \
-f qcow2 \
-o lazy_refcounts=on,preallocation=falloc \
$FILEPATH \
[size]G

qemu-img comes with various options for setting the allocation when creating new disk images.

preallocation=metadata – allocates the space required by the metadata but doesn’t allocate any space for the data. This is the quickest to provision but the slowest for guest writes.

preallocation=falloc – allocates space for the metadata and data but marks the blocks as unallocated. This will provision slower than metadata but quicker than full. Guest write performance will be much quicker than metadata and similar to full.

preallocation=full – allocates space for the metadata and data and will therefore consume all the physical space that you allocate (not sparse). All empty allocated space will be set as a zero. This is the slowest to provision and will give similar guest write performance to falloc.

Convert disk:
mv disk.qcow2 disk.qcow2.bak
qemu-img convert -O qcow2 -o lazy_refcounts=on,preallocation=falloc disk.qcow2.bak disk.qcow2

 

Attach disk:
virsh attach-disk [vm ID] \
--source /path/to/disk.qcow2 \
--target vd[x] \
--persistent \
--subdriver qcow2

Feb 15 2021

EFI boot entry

show
efibootmgr
root@hphost:~# efibootmgr
BootCurrent: 0002
Timeout: 0 seconds
BootOrder: 0000,0004,0002,0001
Boot0000* debian
Boot0001* ubuntu
Boot0002* rEFInd Boot Manager
Boot0004* Windows Boot Manager

change order
sudo efibootmgr -o 0004,0002,0001,0000

change the EFI boot manager timeout
efibootmgr --timeout=4

delete entry
efibootmgr -Bb 0003

May 25 2012

reinstaling lilo

Boot from any Live CD

mkdir /myraid
mount /dev/md0 /myraid
mount /dev/sda1 /myraid/boot
mount –bind /dev /myraid/dev
mount -t devpts devpts /myraid/dev/pts
mount -t proc proc /myraid/proc
mount -t sysfs sysfs /myraid/sys
chroot /myraid
lilo
exit