How to use UUID and blkid to manage devices

Having trouble with device mapping at reboot (iscsi device mapping can change at every reboot) ?

Use UUID (Universal Unique Identifier)!

 

Say you have two iSCSI targets on your Linux. They show, for example, as disks /dev/sdc and /dev/sdd the first time you discover them (with iscsiadm) :

# sfdisk -s

/dev/sda:  20971520
/dev/sdb: 104857600
/dev/sdc: 2122317824
/dev/sdd: 2122317824

Using fdisk or parted you will create the devices /dev/sdc1 and /dev/sdd1 :

# sfdisk -l /dev/sdc

Disk /dev/sdc: 264216 cylinders, 255 heads, 63 sectors/track

Units = cylinders of 8225280 bytes, blocks of 1024 bytes, counting from 0

Device Boot Start     End   #cyls    #blocks   Id  System

/dev/sdc1          0+ 264215  264216- 2122314988+  83  Linux

/dev/sdc2          0       -       0          0    0  Empty

/dev/sdc3          0       -       0          0    0  Empty

/dev/sdc4          0       -       0          0    0  Empty

Disk /dev/sdd: 264216 cylinders, 255 heads, 63 sectors/track

Units = cylinders of 8225280 bytes, blocks of 1024 bytes, counting from 0

Device Boot Start     End   #cyls    #blocks   Id  System

/dev/sdd1          0+ 264215  264216- 2122314988+  83  Linux

/dev/sdd2          0       -       0          0    0  Empty

/dev/sdd3          0       -       0          0    0  Empty

/dev/sdd4          0       -       0          0    0  Empty

Then you can create the two file systems and mount them:

# mkfs -t ext3 /dev/sdc1

# mount -t ext3 /dev/sdc1 /VLS1

# mkfs -t ext3 /dev/sdd1

# mount -t ext3 /dev/sdd1 /VLS2

You need to add the file system in /etc/fstab in order to automatically mount them at startup.

However let’s first reboot the system to check if everything is alright.

At you surprise after reboot you can’t mount /dev/sdc1 and /dev/sdd1.

If you check with sfdisk –l  you can see that /dev/sdc1 and /dev/sdd1 still exist but /dev/sde1 and /dev/sdf1 appeared out of nowhere …

Actually, your two iSCSI disks are now /dev/sde1 et sdf1 (but sdc1 can also be sdd1 at the new reboot and so on …) thanks to the magic of Linux’s dynamic mapping of devices (udev).

That’s where UUID is your best friend !

UUID (Universal Unique Identifier) enable to uniquely identify you device. UUID is not changing at every reboot the way device files (/dev/sdX ou /dev/hdX …) are.

For instance you may know MAC addresses are unique identifier for network cards, well MAC addresses are UUID (version 1).

So if you can get the UUID for your two file systems your problem is solved.

On linux you can get a file system UUIDs with command “blkid” (“vol_id” command can sometimes be used for old Linux versions).

blkid can be found into util-linux package.

# blkid /dev/sdc1

/dev/sdc1: UUID="01066206-c67c-47d1-83a9-d61791fff943" SEC_TYPE="ext2" TYPE="ext3"

# blkid /dev/sdd1

/dev/sdd1 UUID="cea28516-ca98-4ac4-954f-6710b6ac36c7" SEC_TYPE="ext2" TYPE="ext3"

 

Then add the following lines to /etc/fstab :

UUID=4a496f92-6840-4736-a0d5-5b9916113835       /VLS1   ext3 _netdev    0 0
UUID=cab5e3ec-4797-4227-98e8-e9bca3c3f766       /VLS2   ext3 _netdev    0 0

“_netdev” substitute to the usual “default” because network needs to be up before iSCSI filesystems mount.

Now your iSCSI file systems will be automatically mounted after every reboot (well, as long as your iSCSI server is up ?).

Samba troubleshooting : NT_STATUS_BAD_NETWORK_NAME

Tip : if you’ve configured a samba server and you know you configuration should work, but you can’t connect from a Windows server, try to run smbclient from a linux server.

You will have more information to work with.

Try to run :

# smbclient –L myhost1 –U myusername

Domain=[ myhost1] OS=[Unix] Server=[Samba 3.5.6-86.el6]

Sharename       Type      Comment

---------       ----      -------

sqldump Disk      dumps sql

IPC$            IPC       IPC Service (Samba Server Version 3.5.6-86.el6)

Domain=[ myhost1] OS=[Unix] Server=[Samba 3.5.6-86.el6]

Server               Comment

---------            -------

Workgroup            Master

---------            -------

 

For instance the share sqldump should be ok to connect with but when I try to connect with smbclient, I get the following error:

tree connect failed: NT_STATUS_BAD_NETWORK_NAME

 

Try to disable SELinux, even temporarly with :

echo 0 > /selinux/enforce

And try again, it should work.

 

For more information on how to disable SELinux try this link:

http://www.crypt.gen.nz/selinux/disable_selinux.html

Access to SRM >>> through Tru64 with consvar command

This is how you can access to the system firmware console (SRM) of Alpha servers from Tru64 Operating System.
Voici comment accéder à la console firmware système (SRM) des serveurs Alpha depuis le système d’exploitation Tru64.

You can get and set variables with -g and -s options.
Les variables peuvent être mises à jour et affichées avec les options –s et –g.

To list all the supported variables:
Pour lister les variables supportées :

[root@myhost1]/# consvar -v -l
Firmware Rev: 7.1-1
system fam:34  cpu:8  smm:1940
auto_action = HALT
boot_dev = dsk0
bootdef_dev = dsk0
booted_dev = dsk0
boot_file =
booted_file =
boot_osflags = A
booted_osflags = A
boot_reset = ON
Failed to get dump_dev
enable_audit = ON
license = MU
char_set =
language = 0x3c
tty_dev = 0
Failed to get scsiid
Failed to get scsifast
com1_baud =
com1_modem =
com1_flow = 9600
Failed to get com1_misc
com2_baud = OFF
com2_modem = SOFTWARE
com2_flow = 9600
Failed to get com2_misc
Failed to get password
secure = off
logfail = 0
srm2dev_id =