Total Pageviews

Monday, 24 October 2016

APACHE Web Server Configuration !!!

In this post, I am going to configure my Ubuntu machine as APACHE web server. It all needs a package installation and then few edits in the configuration file...

ubu@ubuntu-new:~$
ubu@ubuntu-new:~$ su -
Password:
root@ubuntu-new:~#
root@ubuntu-new:~# service --status-all | grep apache
root@ubuntu-new:~#

We can see no service related to apache, let us check whether HTTP port is Open or not...

root@ubuntu-new:~# netstat -a | more
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State
tcp        0      0 0.0.0.0:hostmon         0.0.0.0:*               LISTEN
tcp        0      0 localhost:domain        0.0.0.0:*               LISTEN
tcp        0      0 0.0.0.0:ssh             0.0.0.0:*               LISTEN
tcp        0     64 ubuntu-new:ssh          10.0.0.43:52040         ESTABLISHED
tcp6       0      0 [::]:hostmon            [::]:*                  LISTEN
tcp6       0      0 [::]:ssh                [::]:*                  LISTEN
udp        0      0 localhost:domain        0.0.0.0:*
udp        0      0 0.0.0.0:bootpc          0.0.0.0:*
udp        0      0 0.0.0.0:hostmon         0.0.0.0:*
udp6       0      0 [::]:hostmon            [::]:*
Active UNIX domain sockets (servers and established)
Proto RefCnt Flags       Type       State         I-Node   Path
unix  2      [ ]         DGRAM                    18460    /run/user/1000/systemd/notify
unix  2      [ ACC ]     SEQPACKET  LISTENING     11655    /run/udev/control
unix  2      [ ACC ]     STREAM     LISTENING     18461    /run/user/1000/systemd/private
unix  3      [ ]         DGRAM                    11648    /run/systemd/notify
unix  2      [ ACC ]     STREAM     LISTENING     14344    /run/snapd.socket
unix  2      [ ]         DGRAM                    11649    /run/systemd/cgroups-agent
unix  2      [ ACC ]     STREAM     LISTENING     14345    /run/snapd-snap.socket
unix  2      [ ACC ]     STREAM     LISTENING     11650    /run/systemd/private
unix  2      [ ACC ]     STREAM     LISTENING     14357    /run/uuidd/request
unix  2      [ ACC ]     STREAM     LISTENING     14360    /run/acpid.socket
unix  2      [ ACC ]     STREAM     LISTENING     11656    /run/systemd/journal/stdout
unix  8      [ ]         DGRAM                    11657    /run/systemd/journal/socket
unix  2      [ ACC ]     STREAM     LISTENING     11660    /run/systemd/fsck.progress
unix  2      [ ]         DGRAM                    11824    /run/systemd/journal/syslog
unix  2      [ ACC ]     STREAM     LISTENING     11865    /run/lvm/lvmpolld.socket
unix  2      [ ACC ]     STREAM     LISTENING     11937    /run/lvm/lvmetad.socket
unix  14     [ ]         DGRAM                    11940    /run/systemd/journal/dev-log
root@ubuntu-new:~#

Later we can see how output looks like when Http port is open.. So lets go with apache package installation...
We need to update our apt (Advanced Packaging Tool) using apt-get update...

root@ubuntu-new:~# apt-get install apache2
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
  apache2-bin apache2-data apache2-utils libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap liblua5.1-0
  ssl-cert
Suggested packages:
  www-browser apache2-doc apache2-suexec-pristine | apache2-suexec-custom openssl-blacklist
The following NEW packages will be installed:
  apache2 apache2-bin apache2-data apache2-utils libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap
  liblua5.1-0 ssl-cert
0 upgraded, 10 newly installed, 0 to remove and 0 not upgraded.
Need to get 1,553 kB of archives.
After this operation, 6,412 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://us.archive.ubuntu.com/ubuntu yakkety/main amd64 libapr1 amd64 1.5.2-4 [85.9 kB]
Get:2 http://us.archive.ubuntu.com/ubuntu yakkety/main amd64 libaprutil1 amd64 1.5.4-2 [77.1 kB]
Get:3 http://us.archive.ubuntu.com/ubuntu yakkety/main amd64 libaprutil1-dbd-sqlite3 amd64 1.5.4-2 [10.6 kB]
Get:4 http://us.archive.ubuntu.com/ubuntu yakkety/main amd64 libaprutil1-ldap amd64 1.5.4-2 [8,704 B]
Get:5 http://us.archive.ubuntu.com/ubuntu yakkety/main amd64 liblua5.1-0 amd64 5.1.5-8.1build1 [105 kB]
Get:6 http://us.archive.ubuntu.com/ubuntu yakkety/main amd64 apache2-bin amd64 2.4.18-2ubuntu4 [920 kB]
Get:7 http://us.archive.ubuntu.com/ubuntu yakkety/main amd64 apache2-utils amd64 2.4.18-2ubuntu4 [81.1 kB]
Get:8 http://us.archive.ubuntu.com/ubuntu yakkety/main amd64 apache2-data all 2.4.18-2ubuntu4 [161 kB]
Get:9 http://us.archive.ubuntu.com/ubuntu yakkety/main amd64 apache2 amd64 2.4.18-2ubuntu4 [86.3 kB]
Get:10 http://us.archive.ubuntu.com/ubuntu yakkety/main amd64 ssl-cert all 1.0.38 [17.0 kB]
Fetched 1,553 kB in 0s (2,658 kB/s)
Preconfiguring packages ...
Selecting previously unselected package libapr1:amd64.
(Reading database ... 62996 files and directories currently installed.)
Preparing to unpack .../0-libapr1_1.5.2-4_amd64.deb ...
Unpacking libapr1:amd64 (1.5.2-4) ...
Selecting previously unselected package libaprutil1:amd64.
Preparing to unpack .../1-libaprutil1_1.5.4-2_amd64.deb ...
Unpacking libaprutil1:amd64 (1.5.4-2) ...
Selecting previously unselected package libaprutil1-dbd-sqlite3:amd64.
Preparing to unpack .../2-libaprutil1-dbd-sqlite3_1.5.4-2_amd64.deb ...
Unpacking libaprutil1-dbd-sqlite3:amd64 (1.5.4-2) ...
Selecting previously unselected package libaprutil1-ldap:amd64.
Preparing to unpack .../3-libaprutil1-ldap_1.5.4-2_amd64.deb ...
Unpacking libaprutil1-ldap:amd64 (1.5.4-2) ...
Selecting previously unselected package liblua5.1-0:amd64.
Preparing to unpack .../4-liblua5.1-0_5.1.5-8.1build1_amd64.deb ...
Unpacking liblua5.1-0:amd64 (5.1.5-8.1build1) ...
Selecting previously unselected package apache2-bin.
Preparing to unpack .../5-apache2-bin_2.4.18-2ubuntu4_amd64.deb ...
Unpacking apache2-bin (2.4.18-2ubuntu4) ...
Selecting previously unselected package apache2-utils.
Preparing to unpack .../6-apache2-utils_2.4.18-2ubuntu4_amd64.deb ...
Unpacking apache2-utils (2.4.18-2ubuntu4) ...
Selecting previously unselected package apache2-data.
Preparing to unpack .../7-apache2-data_2.4.18-2ubuntu4_all.deb ...
Unpacking apache2-data (2.4.18-2ubuntu4) ...
Selecting previously unselected package apache2.
Preparing to unpack .../8-apache2_2.4.18-2ubuntu4_amd64.deb ...
Unpacking apache2 (2.4.18-2ubuntu4) ...
Selecting previously unselected package ssl-cert.
Preparing to unpack .../9-ssl-cert_1.0.38_all.deb ...
Unpacking ssl-cert (1.0.38) ...
Setting up libapr1:amd64 (1.5.2-4) ...
Processing triggers for ufw (0.35-2) ...
Processing triggers for ureadahead (0.100.0-19) ...
Setting up apache2-data (2.4.18-2ubuntu4) ...
Setting up ssl-cert (1.0.38) ...
Processing triggers for libc-bin (2.24-3ubuntu1) ...
Setting up libaprutil1:amd64 (1.5.4-2) ...
Processing triggers for systemd (231-9git1) ...
Processing triggers for man-db (2.7.5-1) ...
Setting up liblua5.1-0:amd64 (5.1.5-8.1build1) ...
Setting up libaprutil1-ldap:amd64 (1.5.4-2) ...
Setting up libaprutil1-dbd-sqlite3:amd64 (1.5.4-2) ...
Setting up apache2-utils (2.4.18-2ubuntu4) ...
Setting up apache2-bin (2.4.18-2ubuntu4) ...
Setting up apache2 (2.4.18-2ubuntu4) ...
Enabling module mpm_event.
Enabling module authz_core.
Enabling module authz_host.
Enabling module authn_core.
Enabling module auth_basic.
Enabling module access_compat.
Enabling module authn_file.
Enabling module authz_user.
Enabling module alias.
Enabling module dir.
Enabling module autoindex.
Enabling module env.
Enabling module mime.
Enabling module negotiation.
Enabling module setenvif.
Enabling module filter.
Enabling module deflate.
Enabling module status.
Enabling conf charset.
Enabling conf localized-error-pages.
Enabling conf other-vhosts-access-log.
Enabling conf security.
Enabling conf serve-cgi-bin.
Enabling site 000-default.
Processing triggers for libc-bin (2.24-3ubuntu1) ...
Processing triggers for ureadahead (0.100.0-19) ...
Processing triggers for systemd (231-9git1) ...
Processing triggers for ufw (0.35-2) ...
root@ubuntu-new:~#

Once package is installed, port is open and in LISTEN state...

root@ubuntu-new:~# netstat -a | more
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State
tcp        0      0 0.0.0.0:hostmon         0.0.0.0:*               LISTEN
tcp        0      0 localhost:domain        0.0.0.0:*               LISTEN
tcp        0      0 0.0.0.0:ssh             0.0.0.0:*               LISTEN
tcp        0     64 ubuntu-new:ssh          10.0.0.43:52040         ESTABLISHED
tcp6       0      0 [::]:hostmon            [::]:*                  LISTEN
tcp6       0      0 [::]:http               [::]:*                  LISTEN
tcp6       0      0 [::]:ssh                [::]:*                  LISTEN
udp        0      0 localhost:domain        0.0.0.0:*
udp        0      0 0.0.0.0:bootpc          0.0.0.0:*
udp        0      0 0.0.0.0:hostmon         0.0.0.0:*
udp6       0      0 [::]:hostmon            [::]:*
Active UNIX domain sockets (servers and established)
Proto RefCnt Flags       Type       State         I-Node   Path
unix  2      [ ]         DGRAM                    18460    /run/user/1000/systemd/notify
unix  2      [ ACC ]     SEQPACKET  LISTENING     11655    /run/udev/control
unix  2      [ ACC ]     STREAM     LISTENING     18461    /run/user/1000/systemd/private
unix  3      [ ]         DGRAM                    11648    /run/systemd/notify
unix  2      [ ACC ]     STREAM     LISTENING     14344    /run/snapd.socket
unix  2      [ ]         DGRAM                    11649    /run/systemd/cgroups-agent
unix  2      [ ACC ]     STREAM     LISTENING     14345    /run/snapd-snap.socket
unix  2      [ ACC ]     STREAM     LISTENING     11650    /run/systemd/private

OUTPUT TRUNCATED...

root@ubuntu-new:~#
root@ubuntu-new:~# service --status-all | grep apache
 [ + ]  apache-htcacheclean
 [ + ]  apache2
root@ubuntu-new:~#

Open browser and type the IP at URL...


Now let us try stopping apache service and check again...

root@ubuntu-new:~# /etc/init.d/apache2 stop
[ ok ] Stopping apache2 (via systemctl): apache2.service.
root@ubuntu-new:~#

root@ubuntu-new:~# netstat -a | more
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State
tcp        0      0 0.0.0.0:hostmon         0.0.0.0:*               LISTEN
tcp        0      0 localhost:domain        0.0.0.0:*               LISTEN
tcp        0      0 0.0.0.0:ssh             0.0.0.0:*               LISTEN
tcp        0     64 ubuntu-new:ssh          10.0.0.43:52040         ESTABLISHED

                  ****** If you observe closely there is no Http port *******

tcp6       0      0 [::]:hostmon            [::]:*                  LISTEN
tcp6       0      0 [::]:ssh                [::]:*                  LISTEN
udp        0      0 localhost:domain        0.0.0.0:*
udp        0      0 0.0.0.0:bootpc          0.0.0.0:*
udp        0      0 0.0.0.0:hostmon         0.0.0.0:*
udp6       0      0 [::]:hostmon            [::]:*
Active UNIX domain sockets (servers and established)
Proto RefCnt Flags       Type       State         I-Node   Path
unix  2      [ ]         DGRAM                    18460    /run/user/1000/systemd/notify
unix  2      [ ACC ]     SEQPACKET  LISTENING     11655    /run/udev/control
unix  2      [ ACC ]     STREAM     LISTENING     18461    /run/user/1000/systemd/private
unix  3      [ ]         DGRAM                    11648    /run/systemd/notify
unix  2      [ ACC ]     STREAM     LISTENING     14344    /run/snapd.socket
unix  2      [ ]         DGRAM                    11649    /run/systemd/cgroups-agent
unix  2      [ ACC ]     STREAM     LISTENING     14345    /run/snapd-snap.socket
unix  2      [ ACC ]     STREAM     LISTENING     11650    /run/systemd/private
unix  2      [ ACC ]     STREAM     LISTENING     14357    /run/uuidd/request
unix  2      [ ACC ]     STREAM     LISTENING     14360    /run/acpid.socket
unix  2      [ ACC ]     STREAM     LISTENING     11656    /run/systemd/journal/stdout
unix  8      [ ]         DGRAM                    11657    /run/systemd/journal/socket
unix  2      [ ACC ]     STREAM     LISTENING     11660    /run/systemd/fsck.progress
unix  2      [ ]         DGRAM                    11824    /run/systemd/journal/syslog
unix  2      [ ACC ]     STREAM     LISTENING     11865    /run/lvm/lvmpolld.socket
unix  2      [ ACC ]     STREAM     LISTENING     11937    /run/lvm/lvmetad.socket
unix  14     [ ]         DGRAM                    11940    /run/systemd/journal/dev-log
root@ubuntu-new:~#

Let us try from the browser this time...



Let us start the service again and continue with the configuration thing....

root@ubuntu-new:~# /etc/init.d/apache2 start
[ ok ] Starting apache2 (via systemctl): apache2.service.
root@ubuntu-new:~#

root@ubuntu-new:~#
root@ubuntu-new:~# cd /var/www/
root@ubuntu-new:/var/www#
root@ubuntu-new:/var/www#
root@ubuntu-new:/var/www# ls
html
root@ubuntu-new:/var/www#
root@ubuntu-new:/var/www# cd html/
root@ubuntu-new:/var/www/html# ls
index.html
root@ubuntu-new:/var/www/html#

In this location, we have the index file where we can edit few things and check the changes in title page working...

root@ubuntu-new:/var/www/html#
root@ubuntu-new:/var/www/html# cat index.html | grep -i works
    <title>Apache2 Ubuntu Default Page: It works</title>
          It works!
root@ubuntu-new:/var/www/html#
root@ubuntu-new:/var/www/html# vi index.html
root@ubuntu-new:/var/www/html#
root@ubuntu-new:/var/www/html# cat index.html | grep -i working
         My Ubuntu Server ready installed with APACHE: Page Loaded, Its Working..
                this site is working properly. You should <b>replace this file</b> (located at
root@ubuntu-new:/var/www/html#

I edited few lines from the main index file, now when I open it in browser...



We can try designing a home page or any other pages using html, even try installing php...

#####################################################################################

Friday, 21 October 2016

LVM (Logical Volume Manager) !!!

I thought of uploading posts related to Linux since many days, all these days I have posted things related to Solaris itself, so I wanted to start Linux... So the basic thing in the Linux OS is the LVM. 

ubu@ubuntu:~$ su -
Password:
root@ubuntu:~#
root@ubuntu:~#
root@ubuntu:~# df -kh
Filesystem                   Size  Used Avail Use% Mounted on
udev                         982M     0  982M   0% /dev
tmpfs                        201M  3.3M  197M   2% /run
/dev/mapper/ubuntu--vg-root  5.4G  1.3G  3.8G  26% /
tmpfs                       1001M     0 1001M   0% /dev/shm
tmpfs                        5.0M     0  5.0M   0% /run/lock
tmpfs                       1001M     0 1001M   0% /sys/fs/cgroup
/dev/sda1                    472M   55M  393M  13% /boot
tmpfs                        100K     0  100K   0% /run/lxcfs/controllers
cgmfs                        100K     0  100K   0% /run/cgmanager/fs
tmpfs                        201M     0  201M   0% /run/user/1000
root@ubuntu:~#

For Linux machines meta devices like in Solaris we have Physical Volumes (PVs). Below is the command and output to display PV.

root@ubuntu:~# pvdisplay
  --- Physical volume ---
  PV Name               /dev/sda5
  VG Name               ubuntu-vg
  PV Size               7.52 GiB / not usable 2.00 MiB
  Allocatable           yes (but full)
  PE Size               4.00 MiB
  Total PE              1925
  Free PE               0
  Allocated PE          1925
  PV UUID               KBhVnP-30fy-u8QV-IXHK-1zLE-98kR-1Ducfa
root@ubuntu:~#

As you see I already have a PV under which a VG (Volume Group) created, this is because my root disk is under LVM. So upon a PV we will create VG...

root@ubuntu:~# vgdisplay
  --- Volume group ---
  VG Name               ubuntu-vg
  System ID
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  3
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                2
  Open LV               2
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               7.52 GiB
  PE Size               4.00 MiB
  Total PE              1925
  Alloc PE / Size       1925 / 7.52 GiB
  Free  PE / Size       0 / 0
  VG UUID               9ZjLhk-IoTQ-Qfli-j9XS-PjgW-7FDv-3SaqTa

root@ubuntu:~#

Above "ubuntu-vg" is VG for my root and swap. Now LVs (Logical Volumes) comes to the scene. So you can see my lvs for root and swap below.

root@ubuntu:~# lvdisplay
  --- Logical volume ---
  LV Path                /dev/ubuntu-vg/root
  LV Name                root
  VG Name                ubuntu-vg
  LV UUID                stDQ9W-X34I-4eFk-7rDq-SLRL-0kpv-hLki1z
  LV Write Access        read/write
  LV Creation host, time ubuntu, 2016-10-04 19:35:42 -0400
  LV Status              available
  # open                 1
  LV Size                5.52 GiB
  Current LE             1413
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           252:0

  --- Logical volume ---
  LV Path                /dev/ubuntu-vg/swap_1
  LV Name                swap_1
  VG Name                ubuntu-vg
  LV UUID                3K30n5-M7ew-Znww-km5q-IRQr-dqfz-E9Dtzr
  LV Write Access        read/write
  LV Creation host, time ubuntu, 2016-10-04 19:35:42 -0400
  LV Status              available
  # open                 2
  LV Size                2.00 GiB
  Current LE             512
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           252:1

root@ubuntu:~#

Like "format" command in Solaris, we have command "fdisk -l" to display the disks... I compare all the time because it is easy to understand somethings when we already know few similar things...

root@ubuntu:~# fdisk -l | more
Disk /dev/ram0: 64 MiB, 67108864 bytes, 131072 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes

Disk /dev/ram1: 64 MiB, 67108864 bytes, 131072 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes

Disk /dev/ram2: 64 MiB, 67108864 bytes, 131072 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes

Disk /dev/ram3: 64 MiB, 67108864 bytes, 131072 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes

Disk /dev/ram4: 64 MiB, 67108864 bytes, 131072 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes

Disk /dev/ram5: 64 MiB, 67108864 bytes, 131072 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes

Disk /dev/ram6: 64 MiB, 67108864 bytes, 131072 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes

Disk /dev/ram7: 64 MiB, 67108864 bytes, 131072 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes

Disk /dev/ram8: 64 MiB, 67108864 bytes, 131072 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes

Disk /dev/ram9: 64 MiB, 67108864 bytes, 131072 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes

Disk /dev/ram10: 64 MiB, 67108864 bytes, 131072 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes

Disk /dev/ram11: 64 MiB, 67108864 bytes, 131072 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes

Disk /dev/ram12: 64 MiB, 67108864 bytes, 131072 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes

Disk /dev/ram13: 64 MiB, 67108864 bytes, 131072 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes

Disk /dev/ram14: 64 MiB, 67108864 bytes, 131072 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes

Disk /dev/ram15: 64 MiB, 67108864 bytes, 131072 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes

Disk /dev/sda: 8 GiB, 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
Disklabel type: dos
Disk identifier: 0xa51c9f65

Device     Boot   Start      End  Sectors  Size Id Type
/dev/sda1  *       2048   999423   997376  487M 83 Linux
/dev/sda2       1001470 16775167 15773698  7.5G  5 Extended
/dev/sda5       1001472 16775167 15773696  7.5G 8e Linux LVM

Disk /dev/mapper/ubuntu--vg-root: 5.5 GiB, 5926551552 bytes, 11575296 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/ubuntu--vg-swap_1: 2 GiB, 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@ubuntu:~#

Now I will add few disks for our learning purpose...(It is so easy in Oracle Virtual box or VMware Workstation).

Again logging in,

ubu@ubuntu:~$
ubu@ubuntu:~$ su -
Password:
root@ubuntu:~#
root@ubuntu:~#
root@ubuntu:~# df -kh
Filesystem                   Size  Used Avail Use% Mounted on
udev                         982M     0  982M   0% /dev
tmpfs                        201M  3.3M  197M   2% /run
/dev/mapper/ubuntu--vg-root  5.4G  1.3G  3.8G  26% /
tmpfs                       1001M     0 1001M   0% /dev/shm
tmpfs                        5.0M     0  5.0M   0% /run/lock
tmpfs                       1001M     0 1001M   0% /sys/fs/cgroup
/dev/sda1                    472M   55M  393M  13% /boot
cgmfs                        100K     0  100K   0% /run/cgmanager/fs
tmpfs                        100K     0  100K   0% /run/lxcfs/controllers
tmpfs                        201M     0  201M   0% /run/user/1000
root@ubuntu:~#

This time let us see output which we require,

root@ubuntu:~# fdisk -l | grep /dev/sd
Disk /dev/sda: 8 GiB, 8589934592 bytes, 16777216 sectors
/dev/sda1  *       2048   999423   997376  487M 83 Linux
/dev/sda2       1001470 16775167 15773698  7.5G  5 Extended
/dev/sda5       1001472 16775167 15773696  7.5G 8e Linux LVM
Disk /dev/sdb: 100 MiB, 104857600 bytes, 204800 sectors
Disk /dev/sdc: 100 MiB, 104857600 bytes, 204800 sectors
Disk /dev/sdd: 100 MiB, 104857600 bytes, 204800 sectors
root@ubuntu:~#

root@ubuntu:~# pvdisplay
  --- Physical volume ---
  PV Name               /dev/sda5
  VG Name               ubuntu-vg
  PV Size               7.52 GiB / not usable 2.00 MiB
  Allocatable           yes (but full)
  PE Size               4.00 MiB
  Total PE              1925
  Free PE               0
  Allocated PE          1925
  PV UUID               KBhVnP-30fy-u8QV-IXHK-1zLE-98kR-1Ducfa

root@ubuntu:~#

Let us create PVs from disks we added,

root@ubuntu:~# pvcreate /dev/sdb /dev/sdc /dev/sdd
  Physical volume "/dev/sdb" successfully created
  Physical volume "/dev/sdc" successfully created
  Physical volume "/dev/sdd" successfully created
root@ubuntu:~#

root@ubuntu:~# pvdisplay /dev/sdb /dev/sdc /dev/sdd
  "/dev/sdd" is a new physical volume of "100.00 MiB"
  --- NEW Physical volume ---
  PV Name               /dev/sdd
  VG Name
  PV Size               100.00 MiB
  Allocatable           NO
  PE Size               0
  Total PE              0
  Free PE               0
  Allocated PE          0
  PV UUID               TFtlnW-ZiPx-GrQc-ws9d-md37-i8ij-QeB9gG

  "/dev/sdb" is a new physical volume of "100.00 MiB"
  --- NEW Physical volume ---
  PV Name               /dev/sdb
  VG Name
  PV Size               100.00 MiB
  Allocatable           NO
  PE Size               0
  Total PE              0
  Free PE               0
  Allocated PE          0
  PV UUID               j7O15i-NSPS-ppJO-0263-x1hP-P222-veof5g

  "/dev/sdc" is a new physical volume of "100.00 MiB"
  --- NEW Physical volume ---
  PV Name               /dev/sdc
  VG Name
  PV Size               100.00 MiB
  Allocatable           NO
  PE Size               0
  Total PE              0
  Free PE               0
  Allocated PE          0
  PV UUID               tNCHDy-8bdJ-JFS6-Zfhe-TFLK-YQgz-iDL9Lt

root@ubuntu:~#

Its time to create VG on our PV...

root@ubuntu:~# vgdisplay
  --- Volume group ---
  VG Name               ubuntu-vg
  System ID
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  3
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                2
  Open LV               2
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               7.52 GiB
  PE Size               4.00 MiB
  Total PE              1925
  Alloc PE / Size       1925 / 7.52 GiB
  Free  PE / Size       0 / 0
  VG UUID               9ZjLhk-IoTQ-Qfli-j9XS-PjgW-7FDv-3SaqTa

root@ubuntu:~#

root@ubuntu:~# vgcreate vol1 /dev/sdb /dev/sdc /dev/sdd
  Volume group "vol1" successfully created
root@ubuntu:~#

root@ubuntu:~# vgdisplay
  --- Volume group ---
  VG Name               ubuntu-vg
  System ID
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  3
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                2
  Open LV               2
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               7.52 GiB
  PE Size               4.00 MiB
  Total PE              1925
  Alloc PE / Size       1925 / 7.52 GiB
  Free  PE / Size       0 / 0
  VG UUID               9ZjLhk-IoTQ-Qfli-j9XS-PjgW-7FDv-3SaqTa

  --- Volume group ---
  VG Name               vol1
  System ID
  Format                lvm2
  Metadata Areas        3
  Metadata Sequence No  1
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                0
  Open LV               0
  Max PV                0
  Cur PV                3
  Act PV                3
  VG Size               288.00 MiB
  PE Size               4.00 MiB
  Total PE              72
  Alloc PE / Size       0 / 0
  Free  PE / Size       72 / 288.00 MiB
  VG UUID               Kpd01H-UQqs-n1f9-VVA3-6buC-f1EO-pTK7v1

root@ubuntu:~#

Then its time for LV....

root@ubuntu:~# lvdisplay
  --- Logical volume ---
  LV Path                /dev/ubuntu-vg/root
  LV Name                root
  VG Name                ubuntu-vg
  LV UUID                stDQ9W-X34I-4eFk-7rDq-SLRL-0kpv-hLki1z
  LV Write Access        read/write
  LV Creation host, time ubuntu, 2016-10-04 19:35:42 -0400
  LV Status              available
  # open                 1
  LV Size                5.52 GiB
  Current LE             1413
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           252:0

  --- Logical volume ---
  LV Path                /dev/ubuntu-vg/swap_1
  LV Name                swap_1
  VG Name                ubuntu-vg
  LV UUID                3K30n5-M7ew-Znww-km5q-IRQr-dqfz-E9Dtzr
  LV Write Access        read/write
  LV Creation host, time ubuntu, 2016-10-04 19:35:42 -0400
  LV Status              available
  # open                 2
  LV Size                2.00 GiB
  Current LE             512
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           252:1

root@ubuntu:~#

Mine is latest ubuntu server, so the default Filesystem will be ext4...

root@ubuntu:~# lvcreate -L 50M vol1 -n mydata1
  Rounding up size to full physical extent 52.00 MiB
WARNING: ext4 signature detected on /dev/vol1/mydata1 at offset 1080. Wipe it? [y/n]: y
  Wiping ext4 signature on /dev/vol1/mydata1.
  Logical volume "mydata1" created.
root@ubuntu:~#
root@ubuntu:~# lvdisplay
  --- Logical volume ---
  LV Path                /dev/ubuntu-vg/root
  LV Name                root
  VG Name                ubuntu-vg
  LV UUID                stDQ9W-X34I-4eFk-7rDq-SLRL-0kpv-hLki1z
  LV Write Access        read/write
  LV Creation host, time ubuntu, 2016-10-04 19:35:42 -0400
  LV Status              available
  # open                 1
  LV Size                5.52 GiB
  Current LE             1413
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           252:0

  --- Logical volume ---
  LV Path                /dev/ubuntu-vg/swap_1
  LV Name                swap_1
  VG Name                ubuntu-vg
  LV UUID                3K30n5-M7ew-Znww-km5q-IRQr-dqfz-E9Dtzr
  LV Write Access        read/write
  LV Creation host, time ubuntu, 2016-10-04 19:35:42 -0400
  LV Status              available
  # open                 2
  LV Size                2.00 GiB
  Current LE             512
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           252:1

  --- Logical volume ---
  LV Path                /dev/vol1/mydata1
  LV Name                mydata1
  VG Name                vol1
  LV UUID                rggxbf-Tenn-kEZA-FdkQ-aRUb-umHP-o0wLoL
  LV Write Access        read/write
  LV Creation host, time ubuntu, 2016-10-06 18:13:53 -0400
  LV Status              available
  # open                 0
  LV Size                52.00 MiB
  Current LE             13
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           252:2

root@ubuntu:~#

One more volume, 

root@ubuntu:~# lvcreate -L 150M vol1 -n mydata2
  Rounding up size to full physical extent 152.00 MiB
WARNING: ext4 signature detected on /dev/vol1/mydata2 at offset 1080. Wipe it? [y/n]: y
  Wiping ext4 signature on /dev/vol1/mydata2.
  Logical volume "mydata2" created.
root@ubuntu:~#

root@ubuntu:~# lvdisplay
  --- Logical volume ---
  LV Path                /dev/ubuntu-vg/root
  LV Name                root
  VG Name                ubuntu-vg
  LV UUID                stDQ9W-X34I-4eFk-7rDq-SLRL-0kpv-hLki1z
  LV Write Access        read/write
  LV Creation host, time ubuntu, 2016-10-04 19:35:42 -0400
  LV Status              available
  # open                 1
  LV Size                5.52 GiB
  Current LE             1413
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           252:0

  --- Logical volume ---
  LV Path                /dev/ubuntu-vg/swap_1
  LV Name                swap_1
  VG Name                ubuntu-vg
  LV UUID                3K30n5-M7ew-Znww-km5q-IRQr-dqfz-E9Dtzr
  LV Write Access        read/write
  LV Creation host, time ubuntu, 2016-10-04 19:35:42 -0400
  LV Status              available
  # open                 2
  LV Size                2.00 GiB
  Current LE             512
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           252:1

  --- Logical volume ---
  LV Path                /dev/vol1/mydata1
  LV Name                mydata1
  VG Name                vol1
  LV UUID                rggxbf-Tenn-kEZA-FdkQ-aRUb-umHP-o0wLoL
  LV Write Access        read/write
  LV Creation host, time ubuntu, 2016-10-06 18:13:53 -0400
  LV Status              available
  # open                 0
  LV Size                52.00 MiB
  Current LE             13
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           252:2

  --- Logical volume ---
  LV Path                /dev/vol1/mydata2
  LV Name                mydata2
  VG Name                vol1
  LV UUID                jjFSn5-TE2X-13fq-j9we-QCwf-7ZJk-9H6FOl
  LV Write Access        read/write
  LV Creation host, time ubuntu, 2016-10-06 18:14:10 -0400
  LV Status              available
  # open                 0
  LV Size                152.00 MiB
  Current LE             38
  Segments               2
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           252:3
root@ubuntu:~#

Once done with the LV creation we should make FS on our volume...

root@ubuntu:~# mkfs.ext4 /dev/vol1/mydata1
mke2fs 1.42.13 (17-May-2015)
Creating filesystem with 53248 1k blocks and 13328 inodes
Filesystem UUID: e49e7c09-88fa-44c1-b988-2cef549dd049
Superblock backups stored on blocks:
        8193, 24577, 40961

Allocating group tables: done
Writing inode tables: done
Creating journal (4096 blocks): done
Writing superblocks and filesystem accounting information: done

root@ubuntu:~#

FS creation for our second volume...

root@ubuntu:~# mkfs.ext4 /dev/vol1/mydata2
mke2fs 1.42.13 (17-May-2015)
Creating filesystem with 155648 1k blocks and 38912 inodes
Filesystem UUID: c5bdb3ce-eb8a-4e31-89df-33dc802548d6
Superblock backups stored on blocks:
        8193, 24577, 40961, 57345, 73729

Allocating group tables: done
Writing inode tables: done
Creating journal (4096 blocks): done
Writing superblocks and filesystem accounting information: done
root@ubuntu:~#

root@ubuntu:~# mkdir -p /data1
root@ubuntu:~#
root@ubuntu:~# mkdir -p /data2
root@ubuntu:~#

Now I will mount the FS...

root@ubuntu:~# mount /dev/vol1/mydata1 /data1
root@ubuntu:~#
root@ubuntu:~# mount /dev/vol1/mydata2 /data2
root@ubuntu:~#
root@ubuntu:~# df -kh
Filesystem                   Size  Used Avail Use% Mounted on
udev                         982M     0  982M   0% /dev
tmpfs                        201M  3.3M  197M   2% /run
/dev/mapper/ubuntu--vg-root  5.4G  1.3G  3.8G  26% /
tmpfs                       1001M     0 1001M   0% /dev/shm
tmpfs                        5.0M     0  5.0M   0% /run/lock
tmpfs                       1001M     0 1001M   0% /sys/fs/cgroup
/dev/sda1                    472M   55M  393M  13% /boot
cgmfs                        100K     0  100K   0% /run/cgmanager/fs
tmpfs                        100K     0  100K   0% /run/lxcfs/controllers
tmpfs                        201M     0  201M   0% /run/user/1000
/dev/mapper/vol1-mydata1      47M  842K   42M   2% /data1
/dev/mapper/vol1-mydata2     144M  1.6M  132M   2% /data2
root@ubuntu:~#

To make it permanent mount, to mount at boot time just add the entries in the /etc/fstab file...

root@ubuntu:~# cat /etc/fstab
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
/dev/mapper/ubuntu--vg-root /               ext4    errors=remount-ro 0       1
# /boot was on /dev/sda1 during installation
UUID=8d74a25e-fef8-45d4-ab90-1cb14910d7f0 /boot           ext2    defaults        0       2
/dev/mapper/ubuntu--vg-swap_1 none            swap    sw              0       0
root@ubuntu:~#

root@ubuntu:~# vi /etc/fstab
root@ubuntu:~#

root@ubuntu:~# cat /etc/fstab
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
/dev/mapper/ubuntu--vg-root /               ext4    errors=remount-ro 0       1
# /boot was on /dev/sda1 during installation
UUID=8d74a25e-fef8-45d4-ab90-1cb14910d7f0 /boot           ext2    defaults        0       2
/dev/mapper/ubuntu--vg-swap_1 none            swap    sw              0       0
/dev/vol1/mydata1 /data1               ext4    rw 0       1
/dev/vol1/mydata2 /data2               ext4    rw 0       1
root@ubuntu:~#

After rebooting...

login as: ubu@10.0.0.143's password:
Welcome to Ubuntu 16.04.1 LTS (GNU/Linux 4.4.0-31-generic x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage

79 packages can be updated.
41 updates are security updates.

Last login: Thu Oct  6 18:44:28 2016
ubu@ubuntu:~$
ubu@ubuntu:~$ df -kh
Filesystem                   Size  Used Avail Use% Mounted on
udev                         982M     0  982M   0% /dev
tmpfs                        201M  3.4M  197M   2% /run
/dev/mapper/ubuntu--vg-root  5.4G  1.3G  3.8G  26% /
tmpfs                       1001M     0 1001M   0% /dev/shm
tmpfs                        5.0M     0  5.0M   0% /run/lock
tmpfs                       1001M     0 1001M   0% /sys/fs/cgroup
/dev/sda1                    472M   55M  393M  13% /boot
/dev/mapper/vol1-mydata2     144M  1.6M  132M   2% /data2
/dev/mapper/vol1-mydata1      47M  842K   42M   2% /data1
cgmfs                        100K     0  100K   0% /run/cgmanager/fs
tmpfs                        201M     0  201M   0% /run/user/0
tmpfs                        201M     0  201M   0% /run/user/1000
ubu@ubuntu:~$

That's it for the volume and filesystem creation under LVM...

####################################################################################