Linux System

Rescan Blockdevices / Reread Partition Tables

Tipps I found with variable usefullness:

blockdev --rereadpt /dev/sda7

(from VMWare Communities)

partprobe /dev/sdX
hdparm -z /dev/sda
sfdisk -R /dev/sda
echo 1 > /sys/block/sdX/device/rescan
echo "scsi remove-single-device X X X X" > /proc/scsi/scsi
echo "scsi add-single-device X X X X"    > /proc/scsi/scsi

(X X X X is <AdapterNo.> <Channel> <Id> <LUN>)

echo "- - -" > /sys/class/scsi_host/host<N>/scan

(see Linux Journal)

echo "scsi scsi-scan-devices" > /proc/scsi/scsi
partprobe [options]

(Thanks to linux-poweredge)

sfdisk -R

Force hard reset

In case you are in danger, that your remote system might hang while doing a clean shutdown, a “cold reboot” triggered by software might help

:!:Please understand: The running system is affected the same way as when suddenly switching off the power supply off with no battery attached!

:!:This is no clean shutdown

echo b > /proc/sysrq-trigger

Credits and further reading: GEEX, ct' online, kernel.org

Reset USB device (bus?)

Regain access to an build-in card reader after

udisksctl power-off -b /dev/sdc

/var/log/syslog

Feb 26 16:38:27 myhost udisksd[6074]: Ignoring SCSI command START STOP UNIT failure (Non-GOOD SCSI status from SGIO v3 ioctl: status=2 host_status=0 driver_status=8) on /dev/sdc
Feb 26 16:38:27 myhost udisksd[6074]: Powered off /dev/sdc - successfully wrote to sysfs path /sys/devices/pci0000:00/0000:00:1d.7/usb2/2-4/remove
Feb 26 16:38:27 myhost kernel: [179303.432273] usb 2-4: USB disconnect, device number 8
Feb 26 16:38:27 myhost colord: device removed: sysfs-HP-HP_Flash_Media_Reader
Feb 26 16:38:28 myhost colord-sane: io/hpmud/pp.c 627: unable to read device-id ret=-1

succeeded with:

echo 0 > /sys/bus/usb/drivers/usb/usb2/authorized
echo 1 > /sys/bus/usb/drivers/usb/usb2/authorized

Credits: How do you reset a USB Device from the command line? - Ask Ubuntu

Back to top
docs/tips_n_tricks/linux_system.txt · Last modified: 27.02.2015 04:14 by peter