Last active
          September 20, 2024 09:18 
        
      - 
      
 - 
        
Save jalaziz/bcfe2f71e3f7e8fe42a9c294c1e9279f to your computer and use it in GitHub Desktop.  
    CoreOS AWS EBS NVMe udev rules
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | # ebs nvme devices | |
| KERNEL=="nvme[0-9]*n[0-9]*", ENV{DEVTYPE}=="disk", ATTRS{model}=="Amazon Elastic Block Store", PROGRAM="/opt/bin/ebs-nvme-mapping /dev/%k", SYMLINK+="%c" | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | #!/bin/bash | |
| vol=$(nvme id-ctrl --raw-binary "$1" | cut -c3073-3104 | tr -s ' ' | sed 's/ $//g') | |
| vol=${vol#/dev/} | |
| if [[ -n "$vol" ]]; then | |
| echo ${vol/xvd/sd} ${vol/sd/xvd} | |
| fi | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | [Unit] | |
| Description=Reload AWS EBS NVMe rules | |
| Requires=coreos-setup-environment.service | |
| After=coreos-setup-environment.service | |
| Before=user-config.target | |
| [Service] | |
| Type=oneshot | |
| RemainAfterExit=yes | |
| EnvironmentFile=-/etc/environment | |
| ExecStart=/usr/bin/udevadm control --reload-rules | |
| ExecStart=/usr/bin/udevadm trigger -y "nvme[0-9]*n[0-9]*" | |
| ExecStart=/usr/bin/udevadm settle | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | [Unit] | |
| Description=Formats /dev/xvdb | |
| Before=dbus.service docker.service | |
| After=ebs-nvme-udev-trigger.service dev-xvdb.device | |
| Wants=ebs-nvme-udev-trigger.service dev-xvdb.device | |
| [Service] | |
| Type=oneshot | |
| RemainAfterExit=yes | |
| ExecStart=/bin/bash -c '(blkid -t TYPE=ext4 /dev/xvdb) || (/usr/sbin/mkfs.ext4 -F /dev/xvdb)' | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
            
Thanks for sharing this, I found it helpful.