????Linux?′????????????
???????????? ???????[ 2014/8/29 11:46:46 ] ?????????????? Linux ????
????????????linux??????п?????????????????????????????????????????м???????????????????raid????????????????raid??????????????????????????????????????????????????????????μ??????????raid???????????汾??????????????????????????????????????????sata/ssd???????????????????????????
????????????????????????ν??????????????????????????????????????????????????udevinfo(centos5)????udevadm(centos6)??????????豸???????豸???????????????????????????????????豸?????/dev/????????slot0???????????豸????????5???????????slot0-4????5???豸????????????????????Щ?????????ok??????????£?
#!/bin/bash
#set -x
function get_release()
{
while read i
do
release=`echo "$i" |grep"release" |awk '{print $3;}'`
main_version=${release:0:1}
if [ ! -z $main_version ]
then
echo $main_version
return 0
fi
done < "/etc/redhat-release"
return 1
}
function get_id_serial()
{
device=$1;
if [ -z "$device" ]
then
return -1
fi
device=`basename $device`
main_version=`get_release`
if [ $? -ne 0 ]
then
echo "get centos release versionerror" 1>&2
return $?
fi
case $main_version in
"5" ) cmd="/usr/bin/udevinfo-q all -n $device" ;;
"6" ) cmd="/sbin/udevadminfo --query=all --name=$device" ;;
esac
ID_SERIAL=$( $cmd |grep"ID_SERIAL=" |awk -F '=' '{print $2;}')
if [ -z $ID_SERIAL ]
then
return 1
fi
echo -n "$ID_SERIAL"
return 0
}
diskctl_config="/etc/udev/rules.d/99-hd.rules"
rm -rf $diskctl_config
diskctl_db="/usr/diskctl/diskctl.db"
rm -rf $diskctl_db
mkdir -p /usr/diskctl
touch $diskctl_db
index=0
for i in /dev/sd*[a-z]
do
device=`basename $i`
ID_SERIAL=`get_id_serial $i`
if [ $? -ne 0 ]
then
echo "FATAL: get ID_SERIAL error" 1>&2
exit 1
fi
slot=`printf "slot%02d" $index`
echo"KERNEL=="sd*[a-z]"??ACTION=="add"??ENV{ID_SERIAL}=="$ID_SERIAL"??SYMLINK+="$slot"">> $diskctl_config
echo"KERNEL=="sd*[0-9]"??ACTION=="add"??ENV{ID_SERIAL}=="$ID_SERIAL"??SYMLINK+="$slot-part%n"">> $diskctl_config
echo"KERNEL=="sd*[a-z]"??ACTION=="remove"??ENV{ID_SERIAL}=="$ID_SERIAL"??RUN+="/bin/rm-f /dev/$slot /dev/$slot-part*"" >> $diskctl_config
echo "#split$ID_SERIAL#############################" >> $diskctl_config
ID_SN=`smartctl -i $i 2>/dev/null |grep"Serials*number" -i |awk '{print $3;}'`
if [ -z "$ID_SN" ]
then
ID_SN="error"
fi
echo "$slot $ID_SERIAL $ID_SN" >> $diskctl_db
((index=index+1))
Done
/sbin/udevcontrolreload_rules
/sbin/start_udev
/etc/fstab????????????????????????
/dev/slot02 /data02 ext4 defaults 0 0
/dev/slot03 /data03 ext4 defaults 0 0
/dev/slot04 /data04 ext4 defaults 0 0
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11