Cryptswap and Linux assigning different devices letters to disk

I had this weird issue recently: I had a simple Ubuntu setup with cryptesetup and swap, and the crypt swap device (say /dev/mapper/mycryptoswap1) keept disappearing.
Caution: fiddling with cryptsetup and disk devices is dangerous for data and OS. I personally made a full backup on a separate disk and then umplugged it to be sure it wouldn’t be involved in any mishap.

Turns out is a little worse that that: Linux is changing the drive devices assignations (eg /dev/sdb /dev/sdg) at every boot under my nose. I did not notice at first because I am using UUIDs, so everything looked fine. Unfortunately my raw partition did not have any UUID.  Probably there’s a way to assign an UUID to a general partition, but I didn’t address this issue.
Having the disk changing its letter any time was the reason why the crypttab device wasn’t created a boot.  I was lucky: would a partition with valuable data be present in the other disk, it would be overwritten with encrypted swap data.
Continue reading “Cryptswap and Linux assigning different devices letters to disk”

A quick and dirty udevadm script

This script (very dirty) was handful to me to discover some parameters (e.g KERNELS) to differentiate on udev/rules.d rules similar devices on a physical usb port basis.
It’s relased under the GNU General Public License and with no guaranties. Please read the Disclaimer.
It needs of course udevadm and less.
Syntax is: showdevicedetails.sh

#!/bin/bash
# Copyright (C) Giuseppe Dia 06/May/2011
# showdevicedetails.sh this script is useful to peek into a device details.
# Syntax: showdevicedetails.sh
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License
version 3 oas published by
# the Free Software Foundation, .
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see http://www.gnu.org/licenses/gpl-3.0.txt
#
UDEVADM_BIN=”/sbin/udevadm”
LESS_BIN=”/usr/bin/less”
if [ “$1” == “” ]
then
echo Please specify device e.g $0 /dev/ttyACM0
exit 1
fi
#
# is a block device.
if [ -b “$1” ]|| [ -c “$1” ]
then
echo “$1 is a device.”
$UDEVADM_BIN info -a -p $($UDEVADM_BIN info -q path -n $1)|$LESS_BIN
exit 0
else
echo “$1 is not a device, or it doesn’t exist, please specify a valid device exiting”
exit 1
fi
#################################