I have the same problem as you:
renaming by kernel of /dev/sd**
after a reboot:
Of course all my automatic mounting in /etc/fstab
are referenced by LABEL or by UUID, so basically there is no problem for that.
And all the commands above ,blkid or lsblk, give this kind of information.
But the trouble begins as in my case, when you are using partition in RAW mode, in the currently booted system point-of-view:
for example either:
the partition is used as raw device, to make a virtual disk for VirtualBox
(so the reference to this partition is something like: /dev/sdf3
)
or
the partition is used as raw device, to make a LUN for iSCSI
(so the reference to this partition is something like: /dev/sdc6
)
So now at boot , for example in rc.local, you have to find in a reliable manner, what is the /dev/sdXX
device of your dedicated RAW partition, and adapt some file:
EXAMPLE 1
The VirtualBox disk *.vmk description of this raw disk, in the part something like:
\# Extent description
RW 488397167 FLAT "/dev/sdXX" 0
and then restart the VirtualBox service
EXAMPLE 2
in tgtd configuration, a target :target0 was associated to /dev/sdd6
at build time.
After reboot you get the same partition renamed /deb/sdc6
This happens with a removable disk, USB or eSATA!
So how to find the new device automatically ?
Again in /etc/rc.d/rc.local
So in this case we need a reliable manner to find what is the new device name.
GPT partition offers unique GUID for any GPT partition, written in GPT table.
gdisk does not provide this info with listing mode, but only in interactive mode with: i command. Fortunately, blkid does it!
So you need to write a shell script, to look in all your disks, which is the device /dev/sdXX
, associated to the GUID noticed at partition creation time.
Something like, search_device_by_partUUID.sh:
\#!/bin/bash
PART_UUID=$1
if [ "$PART_UUID" = "" ]
then
echo "Syntax: $0 <a valid partition UUID>"
exit 3
fi
lsblk | grep '^sd' | awk '{print $1}' | while read DISK_DEVICE
do
INFO=`blkid /dev/${DISK_DEVICE}* | grep "PARTUUID=\"$PART_UUID\"" `
if [ "$INFO" != "" ]
then
echo INFO : "$INFO"
BLK_DEVICE=`echo "$INFO" | awk '{print $1}'`
echo $BLK_DEVICE > /dev/shm/blkdevice
echo -n "BLK_DEVICE : " ; cat /dev/shm/blkdevice
fi
done
and then use /dev/shm/blkdevice
, in your rc.local script.