Thursday, December 20, 2018

vi editor - arrow key now working properly

By default, we use h, j, k and l keys for navigation on vi/vim text editor.
You can use arrow key to navigate around.
But sometimes, when you press arrow keys in the insert mode, it will insert newlines and prints A, B, C, D capital letters.

To fix this issue, set the following,
:set nocompatible

or add this entry to user's home directory

$ echo "set nocompatible" >> ~/.vimrc
$ echo "set nocompatible" >> ~/.exrc

RHEL - How to Reduce PDF file size

How to Reduce PDF file size

If you have a large size pdf file due to scanned document, you can reduce it using the tool called ps2pdf.
ps2pdf is available on linux based systems and its a part of ghostscript package.

Installation of a software

Redhat based systems
# yum install ghostscript

On Debian based systems
$ sudo apt-get install ghostscript

Compress PDF File In Linux
Once package is installed, run the command below.
$ ps2pdf old_file.pdf new_file.pdf

$ du -sh *.pdf
5M old_file.pdf
500K new_file.pdf

Tuesday, December 18, 2018

RHEL7 - Set up a secure HTTPS server with SSL


  1. Install httpd packages for default page display

Verify that you have httpd package is installed and default page is working as expected.
[root@server2 ~]# rpm -qa | grep httpd
httpd-tools-2.4.6-40.el7.x86_64
httpd-manual-2.4.6-40.el7.noarch
httpd-2.4.6-40.el7.x86_64
[root@server2 ~]# yum install httpd
[root@server2 ~]# echo "This is a test default page" >/var/www/html/index.html
[root@server2 ~]# systemctl status httpd
[root@server2 ~]# systemctl start httpd
[root@server2 ~]# systemctl enable httpd
[root@server2 ~]# elinks http://localhost

  1. Allow http on firewall

Allow apache http port 80 and https port 443

To check run the command
[root@server2 ~]# firewall-cmd --list-all
if you didn't see the ports on output, add them

[root@server2 ~]# firewall-cmd --permanent --add-port=80/tcp
[root@server2 ~]# firewall-cmd --permanent --add-port=443/tcp
[root@server2 ~]# firewall-cmd --reload


  1. Now, Install SSL packages

We need ssl package to generate the keys. Check to see if its already installed.
[root@server2 ~]# rpm -qa | grep mod_ssl
mod_ssl-2.4.6-40.el7.x86_64
[root@server2 ~]# rpm -qa | grep openssl
openssl-1.0.1e-42.el7_1.9.x86_64
openssl-libs-1.0.1e-42.el7_1.9.x86_64

If not installed, install it
[root@server2 ~]# yum install mod_ssl openssl


  1. Now, generate certificates.

a. Generate self-signed certificate (key) with 2048 bit encryption
[root@server2 ~]# openssl genrsa -out ca.key 2048
Generating RSA private key, 2048 bit long modulus
.........................................................................................................................+++
............................................+++
e is 65537 (0x10001)
[root@server2 ~]#

b. Generate certificate signing request (csr)
[root@server2 ~]# openssl req -new -key ca.key -out ca.csr
just follow the prompt.

c. SSL certificate
Note: self-signed certificate (csr of x509 type) is valid for a year.

[root@server2 ~]# openssl x509 -req -days 365 -in ca.csr -signkey ca.key -out ca.crt
Signature ok
Getting Private key

[root@server2 ~]# ls -ltr
-rw-r--r--. 1 root root 1679 Dec 18 23:07 ca.key
-rw-r--r--. 1 root root  997 Dec 18 23:10 ca.csr
-rw-r--r--. 1 root root 1188 Dec 18 23:11 ca.crt

Once these certificates are created, you need to copy to the right directory location as follows.

[root@server2 ~]# cp ca.crt /etc/pki/tls/certs/
[root@server2 ~]# cp ca.key ca.csr /etc/pki/tls/private/

Note: if you copied these certs from different location, you have
to run the semanage command to apply right context. Just verify ..
for eg,
[root@server2 ~]# wget http://192.168.10.120/certs/ca.crt
[root@server2 ~]# mv ca.crt /etc/pki/tls/certs/
[root@server2 ~]# ls -lZd /etc/pki/tls/certs/
drwxr-xr-x. root root system_u:object_r:cert_t:s0      /etc/pki/tls/certs/
[root@server2 ~]# ls -lZd /etc/pki/tls/certs/ca.crt
-rw-r--r--. root root unconfined_u:object_r:cert_t:s0  /etc/pki/tls/certs/ca.crt
and so on

  1. Now, configure your server with the certificates.

[root@server2 ~]# mkdir /var/www/html/best.expanor.local
[root@server2 ~]# echo "Best.expanor.local" >/var/www/html/best.expanor.local/index.html
[root@server2 ~]# systemctl restart httpd
[root@server2 ~]# cat /etc/httpd/conf.d/spage.conf
<virtualhost 192.168.10.122:443>
        servername best.expanor.local
        documentroot best.expanor.local
        directoryindex  index.html
        sslengine on
        sslcertificatefile /etc/pki/tls/certs/ca.crt
        sslcertificatekeyfile /etc/pki/tls/private/ca.key
</virtualhost>

Note: You append/specify sslengine , sshcertificate file, and sslcertificatekeyfile.

[root@server2 ~]# vi /etc/hosts
192.168.10.122  best.expanor.local
[root@server2 ~]# systemctl restart httpd

Or

You can directly edit ssl.conf file which is created by default.

# vi /etc/httpd/conf.d/ssl.conf
Go to the section <VirtualHost _default_:443>.
Uncomment the DocumentRoot and ServerName line and replace example.com with your domain/ipaddress.

<VirtualHost _default_:443>
DocumentRoot "/var/www/html"
ServerName 192.168.10.122:443

Now, go to line SSLCertificateFile and SSLCertificateKeyFile and change with your cert.

SSLEngine on
SSLCertificateFile /etc/pki/tls/certs/ca.crt
SSLCertificateKeyFile /etc/pki/tls/private/ca.key

Save the file and restart the service
# systemctl restart httpd

Or
[root@server2 ~]# cat /etc/httpd/conf.d/webpage.conf
<virtualhost 192.168.10.122:443>
        servername best.expanor.local
        documentroot /var/www/html/best.expanor.local
        directoryindex  index.html
        sslengine on
        sslcertificatefile /etc/pki/tls/certs/ca.crt
        sslcertificatekeyfile /etc/pki/tls/private/ca.key
</virtualhost>
[root@server2 ~]#

Note: Make sure to add hosts entry of domain
# cat /etc/hosts
192.168.10.122  best.expanor.local

  1. Verify it. Open your browser and type

Sunday, December 16, 2018

Monday, December 10, 2018

RHEL7 - Installing OpenStack



  rubygem-io-console.x86_64 0:0.4.2-34.el7_6
  rubygem-json.x86_64 0:1.7.7-34.el7_6
  rubygem-psych.x86_64 0:2.0.0-34.el7_6
  rubygem-rdoc.noarch 0:4.0.0-34.el7_6
  rubygem-rgen.noarch 0:0.6.6-2.el7
  rubygems.noarch 0:2.0.14.1-34.el7_6

Complete!
[root@ipa ~]# yum install openstack-packstack
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirror.cogentco.com
 * extras: mirror.cogentco.com
 * updates: mirror.cogentco.com
Package 1:openstack-packstack-12.0.0-2.el7.noarch already installed and latest version
Nothing to do
[root@ipa ~]# clear
[root@ipa ~]# echo "disable selinux"
disable selinux
[root@ipa ~]# df -h
Filesystem               Size  Used Avail Use% Mounted on
/dev/mapper/centos-root  8.0G  4.2G  3.9G  52% /
devtmpfs                 903M     0  903M   0% /dev
tmpfs                    920M     0  920M   0% /dev/shm
tmpfs                    920M   22M  898M   3% /run
tmpfs                    920M     0  920M   0% /sys/fs/cgroup
/dev/sda1                497M  212M  286M  43% /boot
tmpfs                    184M  4.0K  184M   1% /run/user/42
tmpfs                    184M   44K  184M   1% /run/user/1000
[root@ipa ~]# pvs
  PV         VG     Fmt  Attr PSize  PFree
  /dev/sda2  centos lvm2 a--  10.00g 4.00m
[root@ipa ~]# vgs
  VG     #PV #LV #SN Attr   VSize  VFree
  centos   1   2   0 wz--n- 10.00g 4.00m
[root@ipa ~]# fdisk -l

Disk /dev/sda: 17.2 GB, 17179869184 bytes, 33554432 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: 0x000d8fa2

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048     1026047      512000   83  Linux
/dev/sda2         1026048    22013951    10493952   8e  Linux LVM

Disk /dev/mapper/centos-root: 8589 MB, 8589934592 bytes, 16777216 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 /dev/mapper/centos-swap: 2147 MB, 2147483648 bytes, 4194304 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

[root@ipa ~]# vi /etc/selinux/config
[root@ipa ~]# systemctl disable firewalld
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@ipa ~]# systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
   Active: active (running) since Fri 2018-12-07 08:33:36 EST; 3 days ago
     Docs: man:firewalld(1)
 Main PID: 5649 (firewalld)
   CGroup: /system.slice/firewalld.service
           └─5649 /usr/bin/python -Es /usr/sbin/firewalld --nofork --nopid

Dec 07 08:33:34 rhel7.6.expanor.local systemd[1]: Starting firewalld - dynamic firewall dae.....
Dec 07 08:33:36 rhel7.6.expanor.local systemd[1]: Started firewalld - dynamic firewall daemon.
Hint: Some lines were ellipsized, use -l to show in full.
[root@ipa ~]# systemctl status NetworkManager status
● NetworkManager.service - Network Manager
   Loaded: loaded (/usr/lib/systemd/system/NetworkManager.service; enabled; vendor preset: enabl                                                                        ed)
   Active: active (running) since Fri 2018-12-07 08:33:36 EST; 3 days ago
     Docs: man:NetworkManager(8)
 Main PID: 5697 (NetworkManager)
   CGroup: /system.slice/NetworkManager.service
           └─5697 /usr/sbin/NetworkManager --no-daemon

Dec 08 22:09:30 rhel7.6.expanor.local NetworkManager[5697]: <info>  [1544324970.5305] device...)
Dec 08 22:09:30 rhel7.6.expanor.local NetworkManager[5697]: <info>  [1544324970.5308] device...)
Dec 08 22:09:30 rhel7.6.expanor.local NetworkManager[5697]: <info>  [1544324970.5310] manage...L
Dec 08 22:09:30 rhel7.6.expanor.local NetworkManager[5697]: <info>  [1544324970.5778] manage...E
Dec 08 22:09:30 rhel7.6.expanor.local NetworkManager[5697]: <info>  [1544324970.5780] policy...S
Dec 08 22:09:30 rhel7.6.expanor.local NetworkManager[5697]: <info>  [1544324970.5810] device....
Dec 08 22:09:30 rhel7.6.expanor.local NetworkManager[5697]: <info>  [1544324970.5816] manage...L
Dec 08 22:14:31 ipa.expanor.local NetworkManager[5697]: <info>  [1544325271.8679] hostname: ..."
Dec 08 22:14:31 ipa.expanor.local NetworkManager[5697]: <info>  [1544325271.8725] policy: se...)
Dec 10 22:42:02 ipa.expanor.local NetworkManager[5697]: <info>  [1544499722.2493] manager: k...d
Unit status.service could not be found.
Hint: Some lines were ellipsized, use -l to show in full.
[root@ipa ~]# systemctl disable NetworkManager
Removed symlink /etc/systemd/system/multi-user.target.wants/NetworkManager.service.
Removed symlink /etc/systemd/system/dbus-org.freedesktop.NetworkManager.service.
Removed symlink /etc/systemd/system/dbus-org.freedesktop.nm-dispatcher.service.
Removed symlink /etc/systemd/system/network-online.target.wants/NetworkManager-wait-online.servi                                                                        ce.
[root@ipa ~]# systemctl mask firewalld
Created symlink from /etc/systemd/system/firewalld.service to /dev/null.
[root@ipa ~]# systemctl mask NetworkManager
Created symlink from /etc/systemd/system/NetworkManager.service to /dev/null.
[root@ipa ~]# echo " 1. Make sure you have enought disk space available.
> 2. Assign Static IP address
> 3. Disable Selinux/Firewall
> 4. Disable NetworkManager"
 1. Make sure you have enought disk space available.
2. Assign Static IP address
3. Disable Selinux/Firewall
4. Disable NetworkManager
[root@ipa ~]# cat /etc/sysconfig/network-scripts/ifcfg-
ifcfg-ens192  ifcfg-lo
[root@ipa ~]# cat /etc/sysconfig/network-scripts/ifcfg-ens192
TYPE="Ethernet"
PROXY_METHOD="none"
BROWSER_ONLY="no"
#BOOTPROTO="dhcp"
BOOTPROTO="static"
DEFROUTE="yes"
IPV4_FAILURE_FATAL="no"
IPV6INIT="yes"
IPV6_AUTOCONF="yes"
IPV6_DEFROUTE="yes"
IPV6_FAILURE_FATAL="no"
IPV6_ADDR_GEN_MODE="stable-privacy"
NAME="ens192"
UUID="ddaf1fdc-e7c6-474d-8713-2b19315bf41f"
DEVICE="ens192"
ONBOOT="yes"
ETHTOOL_OPTS="wol d"
IPADDR="192.168.10.140"
PREFIX="24"
GATEWAY="192.168.10.1"
DNS1="192.168.10.110"
DOMAIN="192.168.10.120"
IPV6_PRIVACY="no"
[root@ipa ~]# echo "Now install OpenStack"
Now install OpenStack
[root@ipa ~]# packstack --allinone
Welcome to the Packstack setup utility

The installation log file is available at: /var/tmp/packstack/20181210-225648-zoz5cX/openstack-s                                                                        etup.log
Packstack changed given value  to required value /root/.ssh/id_rsa.pub

Installing:
Clean Up                                             [ DONE ]
Discovering ip protocol version                      [ DONE ]
Setting up ssh keys                                  [ DONE ]
Preparing servers                                    [ DONE ]
Pre installing Puppet and discovering hosts' details [ DONE ]
Preparing pre-install entries                        [ DONE ]
Setting up CACERT                                    [ DONE ]
Preparing AMQP entries                               [ DONE ]
Preparing MariaDB entries                            [ DONE ]
Fixing Keystone LDAP config parameters to be undef if empty[ DONE ]
Preparing Keystone entries                           [ DONE ]
Preparing Glance entries                             [ DONE ]
Checking if the Cinder server has a cinder-volumes vg[ DONE ]
Preparing Cinder entries                             [ DONE ]
Preparing Nova API entries                           [ DONE ]
Creating ssh keys for Nova migration                 [ DONE ]
Gathering ssh host keys for Nova migration           [ DONE ]
Preparing Nova Compute entries                       [ DONE ]
Preparing Nova Scheduler entries                     [ DONE ]
Preparing Nova VNC Proxy entries                     [ DONE ]
Preparing OpenStack Network-related Nova entries     [ DONE ]
Preparing Nova Common entries                        [ DONE ]
Preparing Neutron LBaaS Agent entries                [ DONE ]
Preparing Neutron API entries                        [ DONE ]
Preparing Neutron L3 entries                         [ DONE ]
Preparing Neutron L2 Agent entries                   [ DONE ]
Preparing Neutron DHCP Agent entries                 [ DONE ]
Preparing Neutron Metering Agent entries             [ DONE ]
Checking if NetworkManager is enabled and running    [ DONE ]
Preparing OpenStack Client entries                   [ DONE ]
Preparing Horizon entries                            [ DONE ]
Preparing Swift builder entries                      [ DONE ]
Preparing Swift proxy entries                        [ DONE ]
Preparing Swift storage entries                      [ DONE ]
Preparing Gnocchi entries                            [ DONE ]
Preparing Redis entries                              [ DONE ]
Preparing Ceilometer entries                         [ DONE ]
Preparing Aodh entries                               [ DONE ]
Preparing Puppet manifests                           [ DONE ]
Copying Puppet modules and manifests                 [ DONE ]
Applying 192.168.10.140_controller.pp
Testing if puppet apply is finished: 192.168.10.140_controller.pp  [ | ]


RHEL7- Extending xfs root filesystem on CentOS 7

kamal@192.168.10.140's password:
Last login: Mon Dec 10 22:35:38 2018 from 192.168.10.2
[kamal@ipa ~]$ df -h
Filesystem               Size  Used Avail Use% Mounted on
/dev/mapper/centos-root  8.0G  4.4G  3.7G  55% /
devtmpfs                 903M     0  903M   0% /dev
tmpfs                    920M     0  920M   0% /dev/shm
tmpfs                    920M   22M  898M   3% /run
tmpfs                    920M     0  920M   0% /sys/fs/cgroup
/dev/sda1                497M  212M  286M  43% /boot
tmpfs                    184M  4.0K  184M   1% /run/user/42
tmpfs                    184M   44K  184M   1% /run/user/1000
tmpfs                    184M     0  184M   0% /run/user/0
[kamal@ipa ~]$ su -
Password:
Last login: Mon Dec 10 22:35:52 EST 2018 on pts/1
[root@ipa ~]# fdisk -l

Disk /dev/sda: 17.2 GB, 17179869184 bytes, 33554432 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: 0x000d8fa2

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048     1026047      512000   83  Linux
/dev/sda2         1026048    22013951    10493952   8e  Linux LVM

Disk /dev/mapper/centos-root: 8589 MB, 8589934592 bytes, 16777216 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 /dev/mapper/centos-swap: 2147 MB, 2147483648 bytes, 4194304 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

[root@ipa ~]# fdisk /dev/sda
Welcome to fdisk (util-linux 2.23.2).

Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.


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

Command (m for help): p

Disk /dev/sda: 17.2 GB, 17179869184 bytes, 33554432 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: 0x000d8fa2

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048     1026047      512000   83  Linux
/dev/sda2         1026048    22013951    10493952   8e  Linux LVM
/dev/sda3        22013952    33554431     5770240   83  Linux

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

Command (m for help): p

Disk /dev/sda: 17.2 GB, 17179869184 bytes, 33554432 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: 0x000d8fa2

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048     1026047      512000   83  Linux
/dev/sda2         1026048    22013951    10493952   8e  Linux LVM
/dev/sda3        22013952    33554431     5770240   8e  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@ipa ~]# partprobe -s
/dev/sda: msdos partitions 1 2 3
[root@ipa ~]# echo "If it does not work, you can use partx"
If it does not work, you can use partx
[root@ipa ~]# partx  -v -a /dev/sda
partition: none, disk: /dev/sda, lower: 0, upper: 0
/dev/sda: partition table type 'dos' detected
partx: /dev/sda: adding partition #1 failed: Device or resource busy
partx: /dev/sda: adding partition #2 failed: Device or resource busy
partx: /dev/sda: adding partition #3 failed: Device or resource busy
partx: /dev/sda: error adding partitions 1-3
[root@ipa ~]# fdisk -l

Disk /dev/sda: 17.2 GB, 17179869184 bytes, 33554432 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: 0x000d8fa2

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048     1026047      512000   83  Linux
/dev/sda2         1026048    22013951    10493952   8e  Linux LVM
/dev/sda3        22013952    33554431     5770240   8e  Linux LVM

Disk /dev/mapper/centos-root: 8589 MB, 8589934592 bytes, 16777216 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 /dev/mapper/centos-swap: 2147 MB, 2147483648 bytes, 4194304 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

[root@ipa ~]# pvcreate /dev/sda3
  Physical volume "/dev/sda3" successfully created.
[root@ipa ~]# vgs
  VG     #PV #LV #SN Attr   VSize  VFree
  centos   1   2   0 wz--n- 10.00g 4.00m
[root@ipa ~]# vgextend centos /dev/sda3
  Couldn't create temporary archive name.
[root@ipa ~]# vgs
  VG     #PV #LV #SN Attr   VSize  VFree
  centos   1   2   0 wz--n- 10.00g 4.00m
[root@ipa ~]# df -h .
Filesystem               Size  Used Avail Use% Mounted on
/dev/mapper/centos-root  8.0G  4.8G  3.3G  60% /
[root@ipa ~]# vgextend centos /dev/sda3
  Volume group "centos" successfully extended
[root@ipa ~]# pvscan
  PV /dev/sda2   VG centos          lvm2 [10.00 GiB / 4.00 MiB free]
  PV /dev/sda3   VG centos          lvm2 [5.50 GiB / 5.50 GiB free]
  Total: 2 [15.50 GiB] / in use: 2 [15.50 GiB] / in no VG: 0 [0   ]
[root@ipa ~]# vgs
  VG     #PV #LV #SN Attr   VSize  VFree
  centos   2   2   0 wz--n- 15.50g 5.50g
[root@ipa ~]# df -h .
Filesystem               Size  Used Avail Use% Mounted on
/dev/mapper/centos-root  8.0G  4.9G  3.2G  61% /
[root@ipa ~]# xfs_info /dev/mapper/centos-root
meta-data=/dev/mapper/centos-root isize=512    agcount=4, agsize=524288 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=0 spinodes=0
data     =                       bsize=4096   blocks=2097152, 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
[root@ipa ~]# echo "now, extend your logical volume using whole partition, rather then specifyting particular size"
now, extend your logical volume using whole partition, rather then specifyting particular size
[root@ipa ~]# lvextend /dev/mapper/centos-root /dev/sda3
  Size of logical volume centos/root changed from 8.00 GiB (2048 extents) to 13.50 GiB (3456 extents).
  Logical volume centos/root successfully resized.
[root@ipa ~]# lvs
  LV   VG     Attr       LSize  Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  root centos -wi-ao---- 13.50g
  swap centos -wi-ao----  2.00g
[root@ipa ~]# lvscan
  ACTIVE            '/dev/centos/root' [13.50 GiB] inherit
  ACTIVE            '/dev/centos/swap' [2.00 GiB] inherit
[root@ipa ~]# df -h .
Filesystem               Size  Used Avail Use% Mounted on
/dev/mapper/centos-root  8.0G  4.9G  3.2G  62% /
[root@ipa ~]# echo "You just extended LVM, now you have to extend xfs filessytem"
You just extended LVM, now you have to extend xfs filessytem
[root@ipa ~]# xfs_growfs /dev/mapper/centos-root
meta-data=/dev/mapper/centos-root isize=512    agcount=4, agsize=524288 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=0 spinodes=0
data     =                       bsize=4096   blocks=2097152, 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 2097152 to 3538944
[root@ipa ~]# echo "It says data blocks changed from 2097152 to 3538944"
It says data blocks changed from 2097152 to 3538944
[root@ipa ~]# df -h .
Filesystem               Size  Used Avail Use% Mounted on
/dev/mapper/centos-root   14G  5.0G  8.6G  37% /
[root@ipa ~]#

Thursday, November 15, 2018

From Code to Package

Here is an basic steps that involve writing simple code and packaging code into software bundle.

1. Write simple code
- Write simple code first. Test it. Document it. and gradually add more code.

2. Save code on easyly accessible location
- If its a larger program, make it available to everyone in your group.

3. Compile the code
-  Once you write code, the code need to compile.

4. Review error and code
- If you find any error on code, fix it.

5. Perform unit test
- What that particular block code does, test it. Review the error.

6. Test the functionality
- Make sure verify what code need to do, and how it does after compiling the code.

7. Build a software package
- After installing, testing, validating the functionality of your code/software, bundle a software package for the operating system you intend to install. We will build RPM package.

8. Store on repository
- Store your software package on easily accessible locatin such as software repository.


Next, creating RPM package