Rescan disk in Linux

When adding disks or enlarging existing disk in our VMs I use this twoliner to trigger a rescan of disks:

for i in /sys/class/scsi_host/host*/scan ; do echo "- - -" >$i ; done
for i in /sys/class/scsi_disk/*/device/rescan ; do echo "1" >$i ; done

Auto detecting monitors in Linux

When using an external monitor to my laptop I have set my X to enable TwinView and have the larger external display be primary display left of the laptop display. But when I am away from home and does not have external monitor connected the nv driver does not detect that and still set up TwinView as before leaving much of the desktop out of display. To remedy this I have made two xorg.conf, one for single display and one for dual.

I have copied these manually before when I’m switching. Now I have something slightly better. I start X, run xrandr, capture its output and copy one of the configs depending on what’s in the output. This is how I do it

rm -f /tmp/xrandr /tmp/nullconf
/usr/bin/xinit /usr/bin/xrandr -q -- /usr/bin/X -config /tmp/nullconf -quiet >/tmp/xrandr 2>/dev/null
if grep -q '^DVI.* connected' /tmp/xrandr ; then
cp -f /etc/X11/xorg.conf.dual /etc/X11/xorg.conf
cp -f /etc/X11/xorg.conf.single /etc/X11/xorg.conf
rm -f /tmp/nullconf

My external monitor is detected as a DVI and the internal as LVDS

Upgraded harddrive with encrypted LVM

My HP laptop with 160GB harddrive was getting full and I wanted to upgrade it to a bigger one. Found that 2.5″ 500GB was relatively cheap so I bought one and detailed the procedure of upgrading with all data intact. I bought a 2.5″ USB-SATA chassis as well for the old drive to sit in. As I hit a few snags when doing this I thought it could be useful for others to read about.

Continue reading Upgraded harddrive with encrypted LVM