User Tools

Site Tools


Action disabled: source
docs:tips_n_tricks:linux.html

Linux

Commands

Some Linux commands seldom used - so sometimes not remembered

which find executables (candidates)
watch repeat command and display output
pv Pipe Viewer

System

Some tipp 'n tricks to handle you linux system in seldom situations

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 Soft RAID (mdadm) resync

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 with no battery attached!
This is no clean shutdown
echo b > /proc/sysrq-trigger

Credits and further reading: GEEX, ct' online, kernel.org git.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

Avoid accidental wakeups after hibernate with systemd

Entries: systemd, hibernate

/etc/systemd/sleep.conf.diff
diff -u -r1.1 sleep.conf
--- sleep.conf  2020-04-01 19:23:42+02  1.1
+++ sleep.conf  2022-10-07 10:19:04+02
@@ -18,7 +18,7 @@
 #AllowHybridSleep=yes
 #SuspendMode=
 #SuspendState=mem standby freeze
-#HibernateMode=platform shutdown
+HibernateMode=shutdown
 #HibernateState=disk
 #HybridSleepMode=suspend platform shutdown
 #HybridSleepState=disk

References:

docs/tips_n_tricks/linux.html.txt · Last modified: 25.05.2023 23:58 CEST by peter

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki