Pages

Friday, October 8, 2021

Increase the space of live ubuntu vmdk file with VM ware

 1. Increase space of disk using VM player option 




Increased from 20 GB to 25 GB 


2. Start VM image 


3. Check the disk space 




ubuntu@oktest:~$ sudo fdisk -l


Disk /dev/sda: 25 GiB, 26843545600 bytes, 52428800 sectors

Disk model: VMware Virtual S

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: gpt

Disk identifier: F036E5A6-57F5-4AB8-8E22-2D4EAE295D62


Device       Start      End  Sectors Size Type

/dev/sda1     2048     4095     2048   1M BIOS boot

/dev/sda2     4096  2101247  2097152   1G Linux filesystem

/dev/sda3  2101248 41940991 39839744  19G Linux filesystem



Disk /dev/mapper/ubuntu--vg-ubuntu--lv: 19 GiB, 20396900352 bytes, 39837696 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


Current disk space is only 19 GB . It need to increase to 25 GB

4. Create new dummy disk to attach to volume 


ubuntu@oktest:~$ sudo fdisk /dev/sda

Welcome to fdisk (util-linux 2.36.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

GPT PMBR size mismatch (41943039 != 52428799) will be corrected by write.

Command (m for help): n
Partition number (4-128, default 4): 
First sector (41940992-52428766, default 41940992): 
Last sector, +/-sectors or +/-size{K,M,G,T,P} (41940992-52428766, default 52428766): 

Created a new partition 4 of type 'Linux filesystem' and of size 5 GiB.

Command (m for help): t
Partition number (1-4, default 4): 4
Partition type or alias (type L to list all): 8e

Type of partition 4 is unchanged: Linux filesystem.

Command (m for help):w
The partition table has been altered.
Syncing disks.

8e is for linux 


5. After writing reboot the VM 


ubuntu@oktest:~$ sudo reboot

Connection to 192.168.132.132 closed by remote host.

Connection to 192.168.132.132 closed.

sterin@sterin-thinkpad:~$ ssh -l ubuntu 192.168.132.132

ubuntu@192.168.132.132's password: 

Welcome to Ubuntu 21.04 (GNU/Linux 5.11.0-36-generic x86_64)


6. pvcreate 

ubuntu@oktest:~$ sudo pvcreate /dev/sda4

[sudo] password for ubuntu: 

  Physical volume "/dev/sda4" successfully created.


7. Get volume details 

ubuntu@oktest:~$ sudo vgdisplay
  --- Volume group ---
  VG Name               ubuntu-vg
  System ID             
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  2
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                1
  Open LV               1
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               <19.00 GiB
  PE Size               4.00 MiB
  Total PE              4863
  Alloc PE / Size       4863 / <19.00 GiB
  Free  PE / Size       0 / 0   
  VG UUID               c77G0M-adxg-UXNw-FOGC-pnyH-RXkW-PY4LAN


8.  Extend the   volume 

ubuntu@oktest:~$ sudo vgextend ubuntu-vg /dev/sda4
  Volume group "ubuntu-vg" successfully extended

9. LV path 

   

ubuntu@oktest:~$ sudo lvdisplay
  --- Logical volume ---
  LV Path                /dev/ubuntu-vg/ubuntu-lv
  LV Name                ubuntu-lv
  VG Name                ubuntu-vg
  LV UUID                KZD61K-RS0V-MZ2L-2j3J-sR1w-LPSS-R88Arg
  LV Write Access        read/write
  LV Creation host, time ubuntu-server, 2021-09-25 15:37:47 +0000
  LV Status              available
  # open                 1
  LV Size                <19.00 GiB
  Current LE             4863
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:0


10.     Extend the volume , by attaching new sda4
ubuntu@oktest:~$ sudo lvextend /dev/ubuntu-vg/ubuntu-lv /dev/sda4
  Size of logical volume ubuntu-vg/ubuntu-lv changed from <19.00 GiB (4863 extents) to 23.99 GiB (6142 extents).
  Logical volume ubuntu-vg/ubuntu-lv successfully resized.



11. resize

ubuntu@oktest:~$ sudo resize2fs /dev/ubuntu-vg/ubuntu-lv 
resize2fs 1.45.7 (28-Jan-2021)

Filesystem at /dev/ubuntu-vg/ubuntu-lv is mounted on /; on-line resizing required
old_desc_blocks = 3, new_desc_blocks = 3
The filesystem on /dev/ubuntu-vg/ubuntu-lv is now 6289408 (4k) blocks long.


12.  check new size 

ubuntu@oktest:~$ df -h
Filesystem                         Size  Used Avail Use% Mounted on
tmpfs                              793M  1.7M  791M   1% /run
/dev/mapper/ubuntu--vg-ubuntu--lv   24G   16G  7.1G  69% /
tmpfs                              3.9G     0  3.9G   0% /dev/shm
tmpfs                              5.0M     0  5.0M   0% /run/lock
tmpfs                              4.0M     0  4.0M   0% /sys/fs/cgroup
/dev/sda2                          976M  130M  780M  15% /boot
overlay                             24G   16G  7.1G  69% /var/lib/docker/overlay2/cee83ea550ff578659803d97c911c2d0b5053fb1881d335fa630e609a41f52f1/merged
shm                                 64M   16K   64M   1% /var/lib/docker/containers/c3969a253df470b33fe4814443059ac9b7d398a345b81972705449806ef3494e/mounts/shm
tmpfs                              793M  4.0K  793M   1% /run/user/1000


Sunday, September 12, 2021

Things to do aftrer installing zorin OS

 

For VM player :

 

sudo apt-get install build-essential linux-headers-$(uname -r)
 
Download : https://download3.vmware.com/software/player/file/VMware-Player-16.1.2-17966106.x86_64.bundle

 sudo ./VMware-Player-16.1.2-17966106.x86_64.bundle

 

Gnome Extension

 https://extensions.gnome.org/

 

 sudo apt-get install chrome-gnome-shell
 
Slack
 
https://downloads.slack-edge.com/releases/linux/4.19.2/prod/x64/slack-desktop-4.19.2-amd64.deb 
sudo dpkg -i   slack-desktop-4.19.2-amd64.deb 
 
Zoom 

 

  1. Download the DEB installer file from our Download Center

 

Chrome

 

Alerts for long running commands


sudo apt-get install undistract-me

echo 'source /etc/profile.d/undistract-me.sh' >> ~/.bashrc


docker


     sudo apt-get install     apt-transport-https     ca-certificates     curl     gnupg     lsb-release

     curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg

     echo   "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \
     $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

     sudo apt-get update

     sudo apt-get install docker-ce docker-ce-cli containerd.io

     sudo docker run hello-world




 

Monday, August 24, 2020

Python script to cut and merge videos using ffmpeg

Python script to help cut and merge multiple videos .



Script : https://github.com/sterin501/PythonScripts/tree/master/cutMergeVideo

Install :
Install the ffmpeg



Config :
a. Copy the videos to same folder
b. Put the details in details.txt

Like :
VideoFilename startpoint endpoint
c. Run the script -- cutMerge.py





#!/bin/python

import time,subprocess

## ffmpeg -i 2.mkv -ss 00:10:03.500 -to 00:20:08.500 -async 1 cut.mp4 -y
## ffmpeg -i "concat:input1|input2" -codec copy output

#subprocess.Popen("pwd", shell=True)

processList=[]

def creatCutCommad(inputfile,time1,time2,outputfile):
    return "ffmpeg -i "+inputfile+"  -ss "+time1+ "  -to "+time2+"  -async 1   "+ outputfile+" -y"

def runCommand(comand):
        print "running __________________________________"+comand
        subprocess.Popen(comand+" ; echo '1' >> done ",shell=True,stdout=subprocess.PIPE)




if __name__ == '__main__':
    #print creatCutCommad("2.mkv","00:10:03.500","00:20:08.500","cut.mp4")
    filename="details.txt"
    temp=[]
    comands=[]
    part=0
    paS=""

    with open (filename) as engfin:
        for line in engfin:
           if line.startswith('#'):
                 continue
           else:
                cc=line.split()
                comands.append(creatCutCommad(cc[0],cc[1],cc[2],"part"+str(part)+".mp4")    )
                paS=paS+"file part"+str(part)+".mp4\n"
                part=part+1

    f = open("mylist.txt", "w")
    f.write(paS)
    ca='ffmpeg -f concat -safe 0 -i mylist.txt -c copy output.mp4'
    #comands.append(ca)
    #print comands
    f = open("done", "w")
    f.write("")

    for kk in comands:
        runCommand(kk)
    while True:
        print "checking cut job  status\n\n\n "
        time.sleep (2)
        num_lines = sum(1 for line in open('done'))
        print "number of lines " + str (num_lines)
        print "part " + str (part)
        if num_lines == part:
            runCommand(

Monday, July 13, 2020

Python client for ssh


Sample code to access ssh by providing username and password 
#!/usr/bin/python3

#from __future__ import print_function

import os
import socket
from ssh2.session import Session


host = 'myserver'
user = os.getlogin()

sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect((host, 22))

session = Session()
session.handshake(sock)
session.userauth_password('oracle', 'mypassword')

channel = session.open_session()
channel.execute('date ')
print (channel.read())

#size, data = channel.read()   ## More managed reading like size etc 
#while size > 0:
#    print(data)
#    size, data = channel.read()

channel.close()



#print("Exit status: %s" % channel.get_exit_status())  ## Shows exit status
## pip install ssh2-python

Wednesday, May 6, 2020

Python script to download and run UCM 12c applet

Python script to  download and run admin 
applets of WCC 12c 



#!/usr/bin/python3

import requests,sys,os


## Pass the UCM URL like http://UCMIP:PORT
USERNAME = "weblogic"
PASSWORD = "xx"

print ('run like ./appletDownload.py  http://UCMIP:PORT  <username> <password>' )
print (sys.argv[1])
if (sys.argv[1]):
    URL = sys.argv[1]
else:
    print ('run like ./appletDownload.py  http://UCMIP:PORT  <username> <password>')
    exit()



if (len (sys.argv) ==3 ):
  if (sys.argv[2]):
     USERNAME=sys.argv[2]
  if (sys.argv[3]):
     PASSWORD=sys.argv[3]

LOGIN_URL= URL+"/cs/login/j_security_check?j_username="+USERNAME+"&j_password="+PASSWORD
session_requests = requests.session()

response=session_requests.post(LOGIN_URL)
cookie = response.headers.get('Set-Cookie')
print (cookie)
if ('IntradocLoginState=1' in cookie):
     print ('Authenticated')
     response=session_requests.get(URL+'/cs/idcplg?IdcService=GET_JNLP&App=RepoMan')
     file = open("/tmp/applet.jnlp", 'wb+')
     file.write(response.content)
     file.close()
     print ('applet saved & Starting ')
     os.popen("javaws /tmp/applet.jnlp")

else:
    print ('In Valid login')
#print (response.info())

Monday, March 30, 2020

How to increase space of / mount based on btrfs in Oracle Linux 7?


How to increase space of / mount based on btrfs in Oracle Linux 7?

It provide the step of active img file .
It additional step to increase the space of / mount . Because all OS module located in the mount


1. Stop VM

2. From Host OS , increase the size of img file using resize command

qemu-img resize new.img +11G

Output :
#qemu-img resize new.img +11G
Image resized.

3. Start VM

4. Check the current space

df -h

Output :
df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 2.4G 0 2.4G 0% /dev
tmpfs 2.4G 0 2.4G 0% /dev/shm
tmpfs 2.4G 8.3M 2.4G 1% /run
tmpfs 2.4G 0 2.4G 0% /sys/fs/cgroup
/dev/xvda3 11G 2.4G 6.3G 28% / ----> Size is 11G
/dev/xvda1 499M 115M 384M 24% /boot
tmpfs 489M 0 489M 0% /run/user/0
[root@dhcp-10-184-38-40 ~]#

5. Verify the resize command using fdisk -l

fdisk -l /dev/xvda

Output :
Disk /dev/xvda: 27.9 GB, 27917287424 bytes, 54525952 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: 0x000e4e76

Device Boot Start End Blocks Id System
/dev/xvda1 * 2048 1030143 514048 83 Linux
/dev/xvda2 1030144 9418751 4194304 82 Linux swap / Solaris
/dev/xvda3 9418752 31457279 11019264 83 Linux

it shows img size is increased by /dev/xvd3 not increased .

Our aim to increase the space of /dev/xvd3

if you run below command now , it will fail , so there is no free space in in partition


btrfs filesystem resize +11G /
Resize '/' of '+11G'
ERROR: unable to resize '/': no enough free space


6. run fdisk command on active / mount

d
3 ( mount on /)
n
p
a
p
w


fdisk /dev/xvda

Output :
fdisk /dev/xvda
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): d
Partition number (1-3, default 3): 3
Partition 3 is deleted

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

Command (m for help): a
Partition number (1-3, default 3): 3

Command (m for help): p

Disk /dev/xvda: 27.9 GB, 27917287424 bytes, 54525952 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: 0x000e4e76

Device Boot Start End Blocks Id System
/dev/xvda1 * 2048 1030143 514048 83 Linux
/dev/xvda2 1030144 9418751 4194304 82 Linux swap / Solaris
/dev/xvda3 * 9418752 54525951 22553600 83 Linux

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.


7. partprobe to check

partprobe

Output :
Error: Partition(s) 3 on /dev/xvda have been written, but we have been unable to inform the kernel of the change, probably because it/they are in use. As a result, the old partition(s) will remain in use. You should reboot now before making further changes.


8. resize using btrfs

btrfs filesystem resize max /

Output :
Resize '/' of 'max'.

9. partx -u -n 2 /dev/xvda

partx -u -n 2 /dev/xvda

Output :
no output .

10. checking partitions

cat /proc/partitions

Output :
major minor #blocks name

202 0 27262976 xvda
202 1 514048 xvda1
202 2 4194304 xvda2
202 3 11019264 xvda3.

11. Reboot of VM

12.resize using btrfs

btrfs filesystem resize max /

Output :
Resize '/' of 'max'.

13.check the file system

df -h .

Output :
Filesystem Size Used Avail Use% Mounted on
/dev/xvda3 22G 2.4G 18G 13% /

it is increased from 11G to 22G