Friday, December 30, 2016

File/folder size explorer in Linux



Wanna check out linux disk space usage (and kick out some old files/folders) ?

checkout baobab - yes its very interesting name, which is quite difficult to remember.

of course, its a X based application :)

Thursday, December 29, 2016

resize qemu kvm image size


On HOST MACHINE:
==========================
// adding 2 G space to qemu image
$ qemu-img resize /var/lib/libvirt/images/centos7.0_ceph3.qcow2  +2G
Image resized.


NOW INSIDE VM:
=========================
// Now delete the root / partition and add new partition with updated size.
[root@marvelcentos ~]# fdisk /dev/vda
Welcome to fdisk (util-linux 2.23.2).

Command (m for help): p

Disk /dev/vda: 5368 MB, 5368709120 bytes, 10485760 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x0009f32f

   Device Boot      Start         End      Blocks   Id  System
/dev/vda1   *        2048     2099199     1048576   83  Linux
/dev/vda2         2099200     6291455     2096128   8e  Linux LVM

Command (m for help): d
Partition number (1,2, default 2): 2
Partition 2 is deleted

Command (m for help): n
Partition type:
   p   primary (1 primary, 0 extended, 3 free)
   e   extended
Select (default p): p
Partition number (2-4, default 2): 2
First sector (2099200-10485759, default 2099200):
Using default value 2099200
Last sector, +sectors or +size{K,M,G} (2099200-10485759, default 10485759):
Using default value 10485759
Partition 2 of type Linux and of size 4 GiB is set

Command (m for help): t
Partition number (1,2, default 2): 2
Hex code (type L to list all codes): 8e
Changed type of partition 'Linux' to 'Linux LVM'

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.
[root@marvelcentos ~]#
---------------------------
REBOOT VM
# reboot
=========================++
Now in VM MACHINE :
++++++++++++++++++
// extend the physical volume
[root@marvelcentos ~]# pvdisplay
  --- Physical volume ---
  PV Name               /dev/vda2
  VG Name               cl_supercentos
  PV Size               2.00 GiB / not usable 2.00 MiB
  Allocatable           yes (but full)
  PE Size               4.00 MiB
  Total PE              511
  Free PE               0
  Allocated PE          511
  PV UUID               ngQJZP-cOEp-S0DE-7JJX-1MN9-btqJ-zZ8pIH
[root@marvelcentos ~]#
[root@marvelcentos ~]# pvresize /dev/vda2
  Physical volume "/dev/vda2" changed
  1 physical volume(s) resized / 0 physical volume(s) not resized
[root@marvelcentos ~]# pvdisplay
  --- Physical volume ---
  PV Name               /dev/vda2
  VG Name               cl_supercentos
  PV Size               4.00 GiB / not usable 2.00 MiB
  Allocatable           yes
  PE Size               4.00 MiB
  Total PE              1023
  Free PE               512
  Allocated PE          511
  PV UUID               ngQJZP-cOEp-S0DE-7JJX-1MN9-btqJ-zZ8pIH
[root@marvelcentos ~]#
[root@marvelcentos ~]#
-------------------------------------
// Extend the logical volume with *updated* physical volume
[root@marvelcentos ~]# lvextend  /dev/mapper/cl_supercentos-root  /dev/vda2 
  Size of logical volume cl_supercentos/root changed from 1.70 GiB (434 extents) to 3.70 GiB (946 extents).
  Logical volume cl_supercentos/root successfully resized.
[root@marvelcentos ~]#
[root@marvelcentos ~]# df -h
Filesystem                       Size  Used Avail Use% Mounted on
/dev/mapper/cl_supercentos-root  1.7G  1.4G  318M  82% /
devtmpfs                         910M     0  910M   0% /dev
tmpfs                            920M     0  920M   0% /dev/shm
tmpfs                            920M   17M  904M   2% /run
tmpfs                            920M     0  920M   0% /sys/fs/cgroup
/dev/vda1                       1014M  184M  831M  19% /boot
tmpfs                            184M     0  184M   0% /run/user/0
[root@marvelcentos ~]#
[root@marvelcentos ~]#

// Extend the underlying partition too
[root@marvelcentos ~]# xfs_growfs /dev/mapper/cl_supercentos-root  
meta-data=/dev/mapper/cl_supercentos-root isize=512    agcount=4, agsize=111104 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=0 spinodes=0
data     =                       bsize=4096   blocks=444416, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
log      =internal               bsize=4096   blocks=2560, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
data blocks changed from 444416 to 968704

// See the results :)
[root@marvelcentos ~]# df -h
Filesystem                       Size  Used Avail Use% Mounted on
/dev/mapper/cl_supercentos-root  3.7G  1.4G  2.4G  38% /
devtmpfs                         910M     0  910M   0% /dev
tmpfs                            920M     0  920M   0% /dev/shm
tmpfs                            920M   17M  904M   2% /run
tmpfs                            920M     0  920M   0% /sys/fs/cgroup
/dev/vda1                       1014M  184M  831M  19% /boot
tmpfs                            184M     0  184M   0% /run/user/0
[root@marvelcentos ~]#

====================================

Note: On Centos, file system is mounted by xfs file system , you cannot use resize2fs,
rather you should use xfs_growfs.

reboot after partition update is quite important ( you may call partprobe too instead of reboot).


Wednesday, December 28, 2016

Android - open notification panel on the lock screen




 Opening the notification panel on the lock screen:


Enable this feature by going to Settings > Notifications > Advanced settings and slide the Enable on lock screen switch to the right.

source: http://webcazine.com/12040/how-to-display-notifications-on-xiaomi-phones-lock-screen-2/


ssh bad owner or permissions on config


While doing ssh to a hostname (with a custom configuration file named ~/.ssh/config) faced this error:
ssh bad owner or permissions on config

Solution:
chown $USER ~/.ssh/config
chmod 644 ~/.ssh/config
Because of the potential for abuse, this file must have strict permissions: read/write for the user, and not writable by others. It may be group-writable provided that the group in question contains only the user.



source: https://serverfault.com/questions/253313/ssh-hostname-returns-bad-owner-or-permissions-on-ssh-config/710453#710453

cloning a qemu VM and removing old details present in clone



Cloning the vm:

First clone the VM using virt-manager UI. (launch # sudo virt-manager, the click on the VM to clone, and right click and select clone).

Assign a new name while cloning.

Ensure the new VM is shutdown and then run virt-sysprep as follows

Then, use virt-sysprep as follows:

virt-sysprep -d <new name of clone> --hostname <new hostname> --root-password password:<new root password>

Here,
-d => decontextualize

Look at man virt-sysprep for more options available.

-------------------
How do you get new name of the clone?

It is the name field available in the xml file.
-------------------

Example:
# virt-sysprep -d node2  --hostname node2 --root-password password:testpassword  
[   0.0] Examining the guest ...
[   2.8] Performing "abrt-data" ...
[   2.8] Performing "bash-history" ...
[   2.8] Performing "blkid-tab" ...
[   2.8] Performing "crash-data" ...
[   2.8] Performing "cron-spool" ...
[   2.8] Performing "dhcp-client-state" ...
[   2.8] Performing "dhcp-server-state" ...
[   2.8] Performing "dovecot-data" ...
[   2.8] Performing "logfiles" ...
[   2.9] Performing "machine-id" ...
[   2.9] Performing "mail-spool" ...
[   2.9] Performing "net-hostname" ...
[   2.9] Performing "net-hwaddr" ...
[   2.9] Performing "pacct-log" ...
[   2.9] Performing "package-manager-cache" ...
[   2.9] Performing "pam-data" ...
[   2.9] Performing "puppet-data-log" ...
[   2.9] Performing "rh-subscription-manager" ...
[   2.9] Performing "rhn-systemid" ...
[   2.9] Performing "rpm-db" ...
[   2.9] Performing "samba-db-log" ...
[   2.9] Performing "script" ...
[   2.9] Performing "smolt-uuid" ...
[   2.9] Performing "ssh-hostkeys" ...
[   2.9] Performing "ssh-userdir" ...
[   2.9] Performing "sssd-db-log" ...
[   2.9] Performing "tmp-files" ...
[   2.9] Performing "udev-persistent-net" ...
[   2.9] Performing "utmp" ...
[   2.9] Performing "yum-uuid" ...
[   2.9] Performing "customize" ...
[   2.9] Setting a random seed
[   2.9] Setting the hostname: node2
[   2.9] Setting passwords
[   4.9] Performing "lvm-uuids" ...

=======================================



Friday, December 16, 2016

disable automount/running programs on media insertion - fedora 22



To disable any automounting / running program when android mobile(or any media) is inserted:

Window -> type "Details" -> "removable media"  -> check "Never prompt or start programs on media insertion"


Wednesday, December 7, 2016

sourcing vs executing a script

source a script vs executing(or running) a script, what is the difference?

short:
sourcing will run the commands in the current shell process. executing will run the commands in a new shell process.

long:
sourcing :
Sourcing the script does not create a new shell. All commands are run in the current shell and changes to the environment take effect in the current shell.

It's as if you typed the contents of the script.

 running:
The changes were made in a new shell. The current shell spawned a new shell to run the script. The script is running in the new shell and all changes to the environment take effect in the new shell. After the script is done the new shell is destroyed. All changes to the environment in the new shell are destroyed with the new shell. Only the output text is printed in the current shell.




link :
http://superuser.com/questions/176783/what-is-the-difference-between-executing-a-bash-script-and-sourcing-a-bash-scrip

 

Sunday, December 4, 2016

failed to find romfile "efi-virtio.rom" - qemu failed to start - solution


Started facing this error:
# virsh create centos7.0.xml
error: Failed to create domain from centos7.0.xml
error: internal error: process exited while connecting to monitor: 2016-12-04T16:20:01.524386Z qemu-system-x86_64: -device virtio-net-pci,netdev=hostnet0,id=net0,mac=52:54:00:2e:7b:93,bus=pci.0,addr=0x3: failed to find romfile "efi-virtio.rom"
2016-12-04T16:20:01.524477Z qemu-system-x86_64: -device virtio-net-pci,netdev=hostnet0,id=net0,mac=52:54:00:2e:7b:93,bus=pci.0,addr=0x3: Device 'virtio-net-pci' could not be initialized

Then fixed all the links of rom files as below:

root@gant qemu$ ls -l efi*.rom
lrwxrwxrwx 1 root root 24 Jun 22 20:08 efi-e1000.rom -> ../ipxe.efi/8086100e.rom
lrwxrwxrwx 1 root root 24 Jun 22 20:08 efi-ne2k_pci.rom -> ../ipxe.efi/10ec8029.rom
lrwxrwxrwx 1 root root 24 Jun 22 20:08 efi-pcnet.rom -> ../ipxe.efi/10222000.rom
lrwxrwxrwx 1 root root 24 Jun 22 20:08 efi-rtl8139.rom -> ../ipxe.efi/10ec8139.rom
lrwxrwxrwx 1 root root 24 Jun 22 20:08 efi-virtio.rom -> ../ipxe.efi/1af41000.rom
root@gant qemu$
root@gant qemu$
root@gant qemu$ ln -sf   ../ipxe/8086100e.rom efi-e1000.rom
root@gant qemu$ ln -sf   ../ipxe/10ec8029.rom efi-ne2k_pci.rom
root@gant qemu$ ln -sf ../ipxe/10222000.rom efi-pcnet.rom
root@gant qemu$ ln -sf  ../ipxe/10ec8139.rom efi-rtl8139.rom
root@gant qemu$ ln -sf  ../ipxe/1af41000.rom efi-virtio.rom
root@gant qemu$
root@gant qemu$ ls -l efi*.rom
lrwxrwxrwx 1 root root 20 Dec  4 22:32 efi-e1000.rom -> ../ipxe/8086100e.rom
lrwxrwxrwx 1 root root 20 Dec  4 22:32 efi-ne2k_pci.rom -> ../ipxe/10ec8029.rom
lrwxrwxrwx 1 root root 20 Dec  4 22:32 efi-pcnet.rom -> ../ipxe/10222000.rom
lrwxrwxrwx 1 root root 20 Dec  4 22:32 efi-rtl8139.rom -> ../ipxe/10ec8139.rom
lrwxrwxrwx 1 root root 20 Dec  4 22:32 efi-virtio.rom -> ../ipxe/1af41000.rom
root@gant qemu$


Saturday, December 3, 2016

பாரதி பாடல் - சின்னஞ் சிறு கிளியே

சின்னஞ் சிறு கிளியே - கண்ணம்மா! 
செல்வக் களஞ்சியமே! 
என்னைக் கலி தீர்த்தே - உலகில் 
ஏற்றம் புரிய வந்தாய்! 
பிள்ளைக் கனியமுதே - கண்ணம்மா 
பேசும்பொற் சித்திரமே! 
அள்ளி யணைத்திடவே - என் முன்னே 
ஆடி வருந்தே! 

ஓடி வருகையில் - கண்ணம்மா 
உள்ளங் குளிரு தடீ! 
ஆடித்திரிதல் கண்டால் - உன்னைப்போய் 
ஆவி தழுவு தடீ! 
உச்சி தனை முகந்தால் - கருவம் 
ஓங்கி வளரு தடீ! 
மெச்சி யுனை யூரார் - புகழ்ந்தால் 
மேனி சிலிர்க்கு தடீ! 

கன்னத்தில் முத்தமிட்டால் - உள்ளந்தான் 
கள்வெறி கொள்ளு தடீ! உன்னைத் தழுவிடிலோ - கண்ணம்மா 
உன்மத்த மாகு தடீ! 
சற்றுன் முகஞ் சிவந்தால் - மனது 
சஞ்சல மாகு தடீ! 
நெற்றி சுருங்கக் கண்டால் - எனக்கு 
நெஞ்சம் பதைக்கு தடீ! 

உன்கண்ணில் நீர்வழிந்தால் - என்நெஞ்சில் 
உதிரங் கொட்டு தடீ! 
என் கண்ணிற் பாவையன்றோ? - கண்ணம்மா! 
என்னுயிர் நின்ன தன்றோ? 
சொல்லு மழலையிலே - கண்ணம்மா! 
துன்பங்கள் தீர்த்திடு வாய்; 
முல்லைச் சிரிப்பாலே - எனது 
மூர்க்கந் தவிர்த்திடு வாய். 

இன்பக் கதைக ளெல்லாம் - உன்னைப்போல் 
ஏடுகள் சொல்வ துண்டோ? 
அன்பு தருவதிலே - உனைநேர் 
ஆகுமோர் தெய்வ முண்டோ? 
மார்பில் அணிவதற்கே -உன்னைப்போல் 
வைர மணிக ளுண்டோ? 
சீர்பெற்று வாழ்வதற்கே -உன்னைப் போல் 
செல்வம் பிறிது முண்டோ?


// என்னைக் கலி தீர்த்தே - எனது துன்பங்களையெல்லாம் ஒழித்து