Fix badblocks on a hard drive

Fix badblocks on a hard drive

At first, we run a read-only badblocks scan on the device to find the corrupt blocks.

% badblocks /dev/sda
55575184
55575185
55575186
55575187
55575188
55575189
55575190
55575191
55575192
55575193
55575194
55575195
55575196
55575197
55575198
55575199

Now we know that block 55575184 - 55575199 are dead. If there are only a few blocks, it’s possible to replace these.

read more

Rename network interface

Rename network interface

Using udev

Change the interface name in /etc/udev/rules.d/75-persistent-net-generator.rules

Using ip utility

ip link set eth1 down
ip link set eth1 name wan0
ip link set wan0 up

read more

Rescan PCI for new virtio devices

Rescan PCI for new virtio devices

I want to extend a running KVM Linux guest system with a physical hard drive. I’ve connected the new disk via

virsh attach-disk my_vm /dev/sdf vdc

to connect sdf to vdc, but inside the guest, nothing happens.

The solution is simple: attaching a new disk requires a new virtio block controller which is a PCI device. The trick is to rescan the PCI bus system to detect the new controller:

echo 1 > /sys/bus/pci/rescan

Now lspci shows the new controller and dmesg shows the new vdc block device.

00:08.0 SCSI storage controller: Red Hat, Inc Virtio block device

Update:

Simply load the both modules

acpiphp pci_hotplug

then you don’t need to rescan the PCI bus.

read more