-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathgetslid
More file actions
40 lines (29 loc) · 716 Bytes
/
getslid
File metadata and controls
40 lines (29 loc) · 716 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/bin/bash
#get syslinux MBR ID and partition ID
SL_ID=""
get_slid() #$1 - device name (e.g. /dev/sda1)
{
#get base name
T_BN=`basename $1`
#get volume number
T_VOLNUM=`echo "$T_BN" | sed 's/^[a-z]*//'`
#get disk name
T_DSKNAM=`echo "$1"|sed 's/[0-9]\+$//'`
if [ -z "$T_DSKNAM" ]; then
return 1 #error
fi
#get MBR ID
#T_MBRID=`fdisk -l "$T_DSKNAM" | grep "Disk identifier"|awk '{print $3}'`
T_MBRID=`hexdump -s 440 -n 4 -e '"0x%08x\n"' "$T_DSKNAM"`
SL_ID="mbr:$T_MBRID $T_VOLNUM"
}
if [ -z "$1" ]; then
echo "Use "`basename $0` "<device>"
exit
fi
get_slid "$1"
if [ "$?" -ne 0 ];then
echo "Error!"
else
echo "$1: $SL_ID"
fi