• Skip to main content

Uly.me

cloud engineer

  • Home
  • About
  • Archives

Archives for August 2021

GCP Display Device Names on OS

August 18, 2021

In GCP console you can see the VM’s Device Names. In this case, it’s boot and persistent-disk-1.

Name		          Device name
server-boot               boot	
server-data               persistent-disk-1

Name Device name server-boot boot server-data persistent-disk-1

To display the volume names on the OS, run this command.

$ ls -l /dev/disk/by-id
total 0
lrwxrwxrwx. 1 root root  9 Aug  2 01:12 google-boot -> ../../sda
lrwxrwxrwx. 1 root root 10 Aug  2 01:12 google-boot-part1 -> ../../sda1
lrwxrwxrwx. 1 root root  9 Aug 18 18:48 google-persistent-disk-1 -> ../../sdb
lrwxrwxrwx. 1 root root  9 Aug  2 01:12 scsi-0Google_PersistentDisk_boot -> ../../sda
lrwxrwxrwx. 1 root root 10 Aug  2 01:12 scsi-0Google_PersistentDisk_boot-part1 -> ../../sda1
lrwxrwxrwx. 1 root root  9 Aug 18 18:48 scsi-0Google_PersistentDisk_persistent-disk-1 -> ../../sdb

$ ls -l /dev/disk/by-id total 0 lrwxrwxrwx. 1 root root 9 Aug 2 01:12 google-boot -> ../../sda lrwxrwxrwx. 1 root root 10 Aug 2 01:12 google-boot-part1 -> ../../sda1 lrwxrwxrwx. 1 root root 9 Aug 18 18:48 google-persistent-disk-1 -> ../../sdb lrwxrwxrwx. 1 root root 9 Aug 2 01:12 scsi-0Google_PersistentDisk_boot -> ../../sda lrwxrwxrwx. 1 root root 10 Aug 2 01:12 scsi-0Google_PersistentDisk_boot-part1 -> ../../sda1 lrwxrwxrwx. 1 root root 9 Aug 18 18:48 scsi-0Google_PersistentDisk_persistent-disk-1 -> ../../sdb

As you can see, boot and persistent-disk-1 are displayed along with its device names /dev/sda and /dev/sdb.

Filed Under: Cloud, Linux Tagged With: disks, display, gcp, id, names, volumes

Check Open Ports Remotely

August 17, 2021

Here are a few tools to check if ports are open from a remote host.

nc -zvw10 192.168.0.1 22
nmap 192.168.0.1 -p 22
telnet 192.168.0.1 22

nc -zvw10 192.168.0.1 22 nmap 192.168.0.1 -p 22 telnet 192.168.0.1 22

You may have to install netcat and nmap if missing in your distro.

yum install nc
yum install nmap

yum install nc yum install nmap

Filed Under: Linux Tagged With: check, nc, nmap, open, ports, remote, telnet

Terraform GCloud VM Image Family

August 10, 2021

How to implement image family with Terraform in GCP.

Declare the machine image in terraform.tfvars.

image-family = "centos-7"

image-family = "centos-7"

Declare data type for the machine image in maint.tf.

data "google_compute_image" "my_image" {
  family  = var.image-family
  project = "your-project-id"
}

data "google_compute_image" "my_image" { family = var.image-family project = "your-project-id" }

In main.tf use “google_compute_instance” under boot disk section in main.tf.

boot_disk {
  initialize_params {
    image = data.google_compute_image.my_image.self_link
  }
}

boot_disk { initialize_params { image = data.google_compute_image.my_image.self_link } }

Filed Under: Cloud Tagged With: family, gcp, image, terraform

Bash Variable Empty

August 6, 2021

Here’s how to check in Bash if a variable is empty or unset.

if [ -z "${VAR}" ]; 
then
  echo 'do something'
else
  echo 'do another'
fi

if [ -z "${VAR}" ]; then echo 'do something' else echo 'do another' fi

One liner

if [ -z "${VAR}" ]; then echo 'do something'; else echo 'do another'; fi

if [ -z "${VAR}" ]; then echo 'do something'; else echo 'do another'; fi

The inverse

if [ ! -z "${VAR}" ]; 
then
  echo 'do something'
else
  echo 'do another'
fi

if [ ! -z "${VAR}" ]; then echo 'do something' else echo 'do another' fi

if [ ! -z "${VAR}" ]; then echo 'do something'; else echo 'do another'; fi

if [ ! -z "${VAR}" ]; then echo 'do something'; else echo 'do another'; fi

Filed Under: Linux Tagged With: bash, check, empty, unset, variable

Markdown Language

August 5, 2021

Style your text using markdown. If you use GitHub, markdown will come in handy.

Examples:

# This is an <h1> tag
## This is an <h2> tag
###### This is an <h6> tag

# This is an <h1> tag ## This is an <h2> tag ###### This is an <h6> tag

Here are more markdown examples.

Filed Under: HTML Tagged With: github, markdown

Corosync Settings

August 5, 2021

Here are the SAP Corosync settings.

[root@server ~]corosync-cmapctl | grep fail_recv_const
runtime.config.totem.fail_recv_const (u32) = 500

[root@server ~]corosync-cmapctl | grep fail_recv_const runtime.config.totem.fail_recv_const (u32) = 500

Filed Under: Linux Tagged With: corosync, sap, settings

Sublime Text Terraform Syntax

August 4, 2021

If you use Terraform and Sublime Text, add Terraform Syntax Highlighter using Package Control.

Press Ctrl+Shift+P or Cmd+Shift+P.
Select “Package Control: Install package”
Select “Terraform”

Press Ctrl+Shift+P or Cmd+Shift+P. Select “Package Control: Install package” Select “Terraform”

It should install in a few seconds.

Filed Under: Misc Tagged With: highlighter, sublime text 3, syntax, terraform

  • Home
  • About
  • Archives

Copyright © 2023