Friday, October 27, 2017

Template creation from a Virtual Machine

Template  creation from a Virtual Machine:

Before creating a template out of a virtual machine, we need to delete unique stuff related to a VM. For example, hostname, mac address, UUID.

You can use the following commands to make it generic enough and then save the template.


hostnamectl set-hostname localhost.localdomain

Remove the entries starting with 'UUID" & "HWADDR" in /etc/sysconfig/network-scripts/ifcfg-eth0 ( on all the interfaces, in case of more than one NIC available ).

Delete all but one file




Delete all but one file:

ls | grep -v testfile.tar | xargs rm 

So, all files except testfile.tar will be deleted.


use "xargs rm -rf"   if you wish to delete directories as well.


vagrant + ansible

vagrant + ansible

I have followed this neat tutorial https://fedoramagazine.org/using-ansible-provision-vagrant-boxes/


After trying out the above, I have tried out provisioning by modifying ansible file.

So, Add the below lines in lamp.yml and then:

# vagrant provision 

lamp.yml
- name: Creates directory
  file: path=/tmp/newdirectory state=directory
The above makes changes in running image and can observed using vagrant ssh
Note, you need to do vagrant ssh in the same directory to verify same. (lampbox in this example).

Friday, September 29, 2017

Direct link to google docs




Use direct link to google docs(s):

newdoc - http://docs.google.com/?action=newdoc
newsheet - http://spreadsheets.google.com/ccc?new
newslide - https://docs.google.com/presentation/u/0/
newimage - https://docs.google.com/drawings/create?hl=en

Bookmark as above in your favourite browser and access google doc directly for new files.
For example, newsheet for opening a new spreadsheet.

Tuesday, September 12, 2017

Setting up thin volume steps


Thin LVM creation steps:


# Creating Virtual disk(loop device) using testlvm file
dd if=/dev/zero of=/root/testlvm.img bs=1024 count=600000

# Link the file created to loop device
losetup /dev/loop1 /root/testlvm.img
    # this will find first free loop device to use and attach to the file.
losetup -f /root/testlvm.img


   To verify:
   losetup -a


#  Make disk as lvm disk
pvcreate /dev/loop1

Note: use #pvdisplay, #pvscan for physical volume information.

# Create volume group
vgcreate test_VG /dev/loop1

Note: - use vgs, vgdisplay for info .

#  Create a thin LV pool
lvcreate -L 500M -T test_VG/mythinpool

Note: #lvdisplay test_VG or #lvs test_VG for verify

#  Create thin logical volume (LV) out of  LV pool created
lvcreate -V1000M  -T test_VG/mythinpool -n thinvolume

Note: #lvdisplay test_VG or #lvs test_VG for verify.
Note, -V is virtual size and it is more than size mentioned above.

#  Format the LV
mkfs.ext4 /dev/test_VG/thinvolume

# Mount the LV
mount /dev/test_VG/thinvolume /mnt

Refer:
man 7 lvmthin
man 8 lvm
man 8 losetup