The brother of the VMware Exsi virtualization Group after a new n-disk is added to a virtual machine master, the sequence of partitions is discovered after the reboot, causing the files that are mounted under each mount point to be inconsistent. The solution given at that time was to use the UUID in the/etc/fstab file because the UUID would not change.
First, UUID and mount point
1. Use Blkid command to get UUID
code is as follows |
copy code |
[root@361way ~]# blkid /dev/sda1:sec_type=" Msdos "uuid=" F159-ea55 "type=" VFAT "partlabel=" EFI System Partition "partuuid= Ed7d2e13-8197-4226-8fdc-47d4aa64aebb" /dev/sda2:label= "boot" Uuid= "F7755604-99f2-4d94-ab1a-47b14def7e26" type= "XFS" partuuid= "627c028f-bf10-4705-b465-d5118d8ee67d" /dev/ Sda3:uuid= "BS0VJV-CENA-E9EO-2WCM-IJNQ-26MR-FGG1PR" type= "Lvm2_member" partuuid= " 18c50ff9-0e0d-40ac-8e2a-4f7f768347ed " /dev/mapper/cl-root:uuid=" B2f57437-ba99-4a2d-9c82-a41037aa0e38 "TYPE=" XFS /dev/mapper/cl-swap:uuid= "2930b30d-3039-442d-a210-da1d7775652e" type= "swap" /dev/mapper/cl-data: Label= "Data" uuid= "cfc65b4e-0ca4-4b48-934e-5f668a4fb3b5" type= "XFS" |
2. View/dev directory get UUID
The code is as follows |
Copy Code |
[Root@361way ~]# Ll/dev/disk/by-uuid/ Total dosage 0 lrwxrwxrwx 1 root root 10 November 19:56 2930b30d-3039-442d-a210-da1d7775652e->. /.. /dm-1 lrwxrwxrwx 1 root root 10 November 19:56 b2f57437-ba99-4a2d-9c82-a41037aa0e38->. /.. /dm-0 lrwxrwxrwx 1 root root 10 November 19:56 cfc65b4e-0ca4-4b48-934e-5f668a4fb3b5->. /.. /dm-2 lrwxrwxrwx 1 root root 10 November 19:56 F159-ea55->. /.. /sda1 lrwxrwxrwx 1 root root 10 November 19:56 f7755604-99f2-4d94-ab1a-47b14def7e26->. /.. /sda2
|
3, modify/etc/fstab file, use UUID
The code is as follows |
Copy Code |
[Root@361way ~]# Cat/etc/fstab
#
#/etc/fstab
# Created by Anaconda on Mon Sep 8 16:38:29 2014
#
# Accessible filesystems, by reference, are maintained under '/dev/disk '
# to the man pages Fstab (5), Findfs (8), mount (8) and/or Blkid (8) for more info
#
/DEV/MAPPER/CL-ROOT/XFS Defaults 1 1
Uuid=f7755604-99f2-4d94-ab1a-47b14def7e26/boot XFS Defaults 1 2
Uuid=f159-ea55/boot/efi vfat umask=0077,shortname=winnt 0 0
/dev/mapper/cl-data/data XFS Defaults,noatime,nobarrier 1 2
/dev/mapper/cl-swap Swap Defaults 0 0
|
After modifying the method above, reboot the host and discover that all mount points are normal.
Second, use Udev to adjust the disk order
One day the database side of the brother asked Sdb, SDC, SDE multiple disk names increase after the problem of chaos. Later on their own virtual machine and try to use Udev to solve the problem, refer to the SNIPPLR Web site, the code is as follows:
The code is as follows |
Copy Code |
(Make sure both devices are unmounted) # cat/proc/partitions # Cd/dev # RM Sda,sdb # MKNOD/DEV/SDA B # fill with major and minor devices obtained from/proc/partitions for SDB # Mknod/dev/sdb B 8 0 # Verify these major, minor values for SDA in/proc/partitions # PARTPROBE/DEV/SDA # hdparm-z/DEV/SDA # sfdisk-r/DEV/SDA # Blockdev--REREADPT/DEV/SDA (Repeat the last 4 commands for SDB) Alternatively and to make it permanent: Create the File/etc/udev/rules.d/10-local.rules with the following content: kernel== "SDA", name= "SDB" kernel== "SDB", name= "SDA" (End of file) and then: # Service Udev Restart # Udevadm Control--reload-rules # Udevadm Trigger
|
1, view the disk of this machine
The code is as follows |
Copy Code |
[Root@localhost rules.d]# Fdisk-l
disk/dev/vda:21.5 GB, 21474836480 bytes
Heads, Sectors/track, 41610 cylinders
Units = Cylinders of 1008 * 516096 bytes
Sector size (logical/physical): bytes/512 bytes
I/O size (minimum/optimal): bytes/512 bytes
Disk identifier:0x0001bcdb
Device Boot Start End Blocks Id System
/DEV/VDA1 * 3 1018 512000 Linux
Partition 1 does not end on cylinder boundary.
/dev/vda2 1018 41611 20458496 8e Linux LVM
Partition 2 does not end on cylinder boundary.
disk/dev/vdb:1073 MB, 1073741824 bytes
Heads, Sectors/track, 2080 cylinders
Units = Cylinders of 1008 * 516096 bytes
Sector size (logical/physical): bytes/512 bytes
I/O size (minimum/optimal): bytes/512 bytes
Disk identifier:0x00000000
disk/dev/vdc:2147 MB, 2147483648 bytes
Heads, Sectors/track, 4161 cylinders
Units = Cylinders of 1008 * 516096 bytes
Sector size (logical/physical): bytes/512 bytes
I/O size (minimum/optimal): bytes/512 bytes
Disk identifier:0x00000000
|
You can see a VDB disk with a size of 1G and a VDC disk of 2G size.
2. Create Rule File
Create a rule file in/etc/udev/rules.d/, as follows
The code is as follows |
Copy Code |
# Cat 10-local.rules kernel== "Vdb", Name= "VDC" kernel== "VDC", name= "VDB"
|
3. Overload the rule file with the Udevadm command
The code is as follows |
Copy Code |
# Udevadm Control--reload-rules # Udevadm Trigger
|
4, and then view the local disk
The code is as follows |
Copy Code |
[Root@localhost ~]# Fdisk-l
disk/dev/vda:21.5 GB, 21474836480 bytes
Heads, Sectors/track, 41610 cylinders
Units = Cylinders of 1008 * 516096 bytes
Sector size (logical/physical): bytes/512 bytes
I/O size (minimum/optimal): bytes/512 bytes
Disk identifier:0x0001bcdb
Device Boot Start End Blocks Id System
/DEV/VDA1 * 3 1018 512000 Linux
Partition 1 does not end on cylinder boundary.
/dev/vda2 1018 41611 20458496 8e Linux LVM
Partition 2 does not end on cylinder boundary.
disk/dev/vdb:2147 MB, 2147483648 bytes
Heads, Sectors/track, 4161 cylinders
Units = Cylinders of 1008 * 516096 bytes
Sector size (logical/physical): bytes/512 bytes
I/O size (minimum/optimal): bytes/512 bytes
Disk identifier:0x00000000
disk/dev/vdc:1073 MB, 1073741824 bytes
Heads, Sectors/track, 2080 cylinders
Units = Cylinders of 1008 * 516096 bytes
Sector size (logical/physical): bytes/512 bytes
I/O size (minimum/optimal): bytes/512 bytes
Disk identifier:0x00000000
|
Then look at the discovery that Vdb turned 2G,VDC into a 1G size.
Iii. Udev rule-related
1. Udev rule operator
"= =": Compare keys, values, if equal, then this condition is satisfied;
"!=": Comparison of keys, values, if not equal to, then this condition is satisfied;
"=": Assign a value to a key;
"+ =": Assigns a value to a key that represents multiple entries.
': = ': Assign a value to a key and reject all changes to the key after that. The purpose is to prevent subsequent rules files from assigning values to the key.
2. Matching keys for udev rules
Action: The behavior of an event (uevent), such as: Add (Add Device), remove (remove device).
KERNEL: Kernel device name, for example: SDA, CDROM.
DEVPATH: The DEVPATH path to the device.
SUBSYSTEM: The subsystem name of the device, for example: SDA subsystem is block.
Bus: The Devpath name of the device in the box, for example: USB.
DRIVER: Device-driven name for the device in Devpath, for example: Ide-cdrom.
ID: The identification number of the device in the Devpath.
Sysfs{filename}: The contents of the device's property file "FileName" under the Devpath path of the device.
Env{key}: Environment variable. In one rule, you can set up a matching key for up to five environment variables.
Program: Invokes an external command.
Result: The return results of the external command program.
3, Udev important assignment key
Name: The device file name that is generated under/dev. Only the first assignment of the name of a device takes effect, and then the matching rule will be ignored for the device's name assignment behavior. If no rules are assigned to the device's name, Udev uses the kernel device name to produce the device file.
SYMLINK: Generates symbolic links for the device files under/dev/. Because Udev can only produce one device file for a device, it is recommended that you use symbolic links in order to not overwrite files generated by the system's default Udev rules.
OWNER, GROUP, MODE: Set permissions for the device.
Env{key}: Import an environment variable
4, Udev value and callable substitution operator
$kernel,%k: The device's kernel device name, for example: SDA, CDROM.
$number,%n: The kernel number of the device, for example: Sda3 's kernel number is 3.
$devpath,%p: Devpath path to the device.
$id,%b: The ID number of the device in the Devpath.
$sysfs {file},%s{file}: The contents of file in the Sysfs of the device. is actually the property value of the device.
For example, $sysfs {size} represents the size of the device (disk).
$env {key},%e{key}: The value of an environment variable.
$major,%m: Major number of the equipment.
$minor%m: Minor number of the device.
$result,%c:program returns the result.
$parent,%P: The device file name for the parent device.
$root, the%r:udev_root value, the default is/dev/.
$tempnode,%N: Temporary device name.
Percent%: sign% itself.
$$: Symbol $ itself.
Iv. udevadm and rule
To view disk or partition information through Udevadm:
The code is as follows |
Copy Code |
[Root@localhost rules.d]# udevadm info-a-p/sys/block/vdb
Udevadm info starts with the device specified by the Devpath and then
Walks up the chain of parent devices. It prints for every device
Found, all possible attributes in the UDEV rules key format.
A rule to match, can is composed by the attributes of the device
And the attributes from a single parent device.
Looking at device '/DEVICES/PCI0000:00/0000:00:06.0/VIRTIO3/BLOCK/VDB ':
kernel== "VDB"
subsystem== "Block"
driver== ""
attr{range}== "16"
attr{ext_range}== "16"
attr{removable}== "0"
attr{ro}== "0"
attr{size}== "2097152"
attr{alignment_offset}== "0"
attr{discard_alignment}== "0"
attr{capability}== "10"
attr{stat}== "276 13 2312 8 0 0 0 0 0 8 8"
attr{inflight}== "0 0"
attr{serial}== ""
Looking at parent device '/devices/pci0000:00/0000:00:06.0/virtio3 ':
kernels== "Virtio3"
subsystems== "Virtio"
drivers== "Virtio_blk"
attrs{device}== "2"
attrs{vendor}== "6900"
attrs{status}== "0x00000007"
attrs{modalias}== "VIRTIO:D00000002V00001AF4"
attrs{features}== "0010101101100000000000000000110000000000000000000000000000000000"
Looking at parent device '/devices/pci0000:00/0000:00:06.0 ':
kernels== "0000:00:06.0"
subsystems== "PCI"
drivers== "Virtio-pci"
attrs{vendor}== "0X1AF4"
attrs{device}== "0x1001"
attrs{subsystem_vendor}== "0X1AF4"
attrs{subsystem_device}== "0x0002"
attrs{class}== "0x010000"
attrs{irq}== "11"
attrs{local_cpus}== "1"
attrs{local_cpulist}== "0"
attrs{modalias}== "Pci:v00001af4d00001001sv00001af4sd00000002bc01sc00i00"
attrs{numa_node}== "-1"
attrs{enable}== "1"
attrs{broken_parity_status}== "0"
attrs{msi_bus}== ""
Looking at parent device '/devices/pci0000:00 ':
kernels== "pci0000:00"
subsystems== ""
drivers== ""
|
If you have more than one disk, which has the same size, you can differentiate by other criteria, such as the rules can write:
The code is as follows |
Copy Code |
subsystem== "Block", attr{size}== "234441648", name= "My_hard_disk" subsystem== "Block", subsystems== "scsi", attrs{model}== "St3120827as", name= "My_hard_disk" kernel== "sda1" attr{size}== "2096753" name= "ASM_OCR"
|
Note: Some old versions of the Udev have no udevadm in the bag, using the Udevinfo command.
V. UEDV and ASM Disk rule
1. scsi_id Get disk UUID
The code is as follows |
Copy Code |
[Root@localhost ~]#/sbin/scsi_id-g-u/dev/sdb 3690b11c0002be80e00000ce3514380db [Root@localhost ~]#/sbin/scsi_id-g-U/DEV/SDC 3690b11c0002be80e00000ce5514380f8 [Root@localhost ~]#/sbin/scsi_id-g-U/DEV/SDD 3690b11c0002be80e00000ce75143810c
|
The scsi_id command in the new version is located in/usr/lib/udev/scsi_id.
2. ASM Rule Rules
The code is as follows |
Copy Code |
#cat/etc/udev/rules.d/99-oracle-asmdevices.rules kernel== "Sd?1", bus= "scsi," program== "/sbin/scsi_id-g-u-d/dev/$parent", result== "3690b11c0002be80e00000ce3514380db", Name= "Asm-crs01", owner= "grid", group= "Asmadmin", mode= "0660" kernel== "Sd?1", bus= "scsi," program== "/sbin/scsi_id-g-u-d/dev/$parent", result== "3690b11c0002be80e00000ce5514380f8", Name= "Asm-data01", owner= "grid", group= "Asmadmin", mode= "0660" kernel== "Sd?1", bus= "scsi," program== "/sbin/scsi_id-g-u-d/dev/$parent", result== "3690b11c0002be80e00000ce75143810c", Name= "Asm-data02", owner= "grid", group= "Asmadmin", mode= "0660"
|
3. Restart Udev Service
The code is as follows |
Copy Code |
[Root@localhost rules.d]#/SBIN/PARTPROBE/DEV/SDB1 [Root@localhost rules.d]#/SBIN/PARTPROBE/DEV/SDC1 [Root@localhost rules.d]#/SBIN/PARTPROBE/DEV/SDD1 [Root@localhost rules.d]#/sbin/start_udev
|
4. View ASM Equipment
The code is as follows |
Copy Code |
[Root@localhost rules.d]# ll/dev/asm* BRW-RW----. 1 root root 8, 17 March 11:30/dev/asm-crs01 BRW-RW----. 1 root root 8, 33 March 11:30/DEV/ASM-DATA01 BRW-RW----. 1 root root 8, 49 March 11:30/DEV/ASM-DATA02
|
The Udev in the CENTOS7/REDHAT7 version is no longer a separate package, but a udev tool is included in the SYSTEMD package. Rule rules in addition to/ETC/UDEV/RULES.D directories, there are/usr/lib/udev/rules.d/directories.