Display IP address in console login screen

Here is one liner that will add the current IP address in the console login screen (if you are not running X as is case for servers):

 (ip -o -4 a| awk '$2 !="lo" {print "\nIP Address ::"$4}' |tr '\n' ',';echo)>>/etc/issue

Just execute the above command as root. It will add the required code in “/etc/issue” to display the IP address. BTW, you can also use “\4” or “\6” instead of that command to get the IP but that will not work with some old versions of Linux.

Linked clone with qemu-img

As you would have seen in Virtualbox or vmware, there is option to create a linked clone. I wanted to use the same feature as “Snapshot” feature anyway does not look/work so great with virt-manager. So, I created a script to create a linked clone VM and here it is :


#!/bin/bash - 
#          FILE: qcow2-linked-clone.sh
#         USAGE: ./qcow2-linked-clone.sh 
#       OPTIONS: ---
#          BUGS: ---
#         NOTES: ---
#        AUTHOR: Amit Agarwal (aka)
#       CREATED: 01/05/2018 09:54
# Last modified: Wed Feb 28, 2018  04:39PM
#      REVISION:  ---

set -o nounset                              # Treat unset variables as an error
UP="amitag:amitag" #Here you need to put your username and group.

if [[ $# == 0 ]]
    read -p "Enter the source path :: " spath
    read -p "Enter the source disk :: " sdisk
    read -p "Enter the destin path :: " dpath
    read -p "Enter the destin disk :: " ddisk
    read -p "Enter new VMName :: " vmname
    spath=$(dirname $1)
    sdisk=$(basename $1)

sudo chown $UP "$spath/$sdisk"
qemu-img create -f qcow2 -b "$spath/$sdisk" "$dpath/$ddisk"

virt-install --disk $dpath/$ddisk --ram 512 \
    --virt-type kvm --vcpus 1 --name "$vmname" --import

The script will create a linked qcow2 and then create a VM with that image. Running it is simple, either provide command line options or just run and it will ask you for details.


Hope it is useful.

Battery life on laptops

To improve your laptop battery life, just do the following:

sudo dnf install tlp tlp-rdw
systemctl start tlp
systemctl enable tlp