Thursday, April 11, 2019

How to configure shared folder with VM and HOST machine in oracle virtual machine?

For easily transferring files between VM and HOST, you need to setup a shared folder between them. this is very convenient while working in VM environment.

You can do that, by just following below few steps -


1)   Need to add the current user in /etc/group  file  (for Centons 6.7 or redhat ) 

cmd>  sudo gedit /etc/group

vboxsf:x:474:(currect_user_name)

example:   vboxsf:x:474:halim

save.
 
2)  From VM menu-   

Devices--> shared folders --> shared folder settings--> add you folder location

  Mark it as :   auto-mount  and Make Permanent

3) Restart the VirtualBox machine.  

4) Find in file browser   sf_folder_name

             

Or  Try Another way as below-




1) First of all, for getting VBoxLinuxAdditions.run , need to install VBOXADDITIONS_CD   as like below- (very simple, straigt forward)

--Devices ---> insert guest addition CD image ----> install

2) Then follow below steps in the VM (commands) - 
(vm_share is our folder/mount point name in both vm and host) for host we create later.

[root@cs6010grp1 ~]#
[root@cs6010grp1 ~]# mkdir /vm_share
[root@cs6010grp1 ~]#
[root@cs6010grp1 ~]# mount /dev/cdrom /vm_share
mount: block device /dev/sr0 is write-protected, mounting read-only
[root@cs6010grp1 ~]#
[root@cs6010grp1 ~]# cd /vm_share
[root@cs6010grp1 vm_share]#
[root@cs6010grp1 vm_share]# sudo ./VBoxLinuxAdditions.run
Verifying archive integrity... All good.
Uncompressing VirtualBox 4.3.30 Guest Additions for Linux............
VirtualBox Guest Additions installer
Removing installed version 4.3.30 of VirtualBox Guest Additions...
Copying additional installer modules ...
add_symlink: link file /usr/lib/VBoxGuestAdditions already exists
Installing additional modules ...
Removing existing VirtualBox non-DKMS kernel modules       [  OK  ]
Building the VirtualBox Guest Additions kernel modules
The headers for the current running kernel were not found. If the following
module compilation fails then this could be the reason.
The missing package can be probably installed with
yum install kernel-uek-devel-2.6.39-200.24.1.el6uek.i686

Building the main Guest Additions module                   [  OK  ]
Building the shared folder support module                  [  OK  ]
Building the OpenGL support module                         [  OK  ]
Doing non-kernel setup of the Guest Additions              [  OK  ]
You should restart your guest to make sure the new modules are actually used

Installing the Window System drivers
Installing X.Org Server 1.10 modules                       [  OK  ]
Setting up the Window System to use the Guest Additions    [  OK  ]
You may need to restart the the Window System (or just restart the guest system)
to enable the Guest Additions.

Installing graphics libraries and desktop services componen[  OK  ]
[root@cs6010grp1 vm_share]#
[root@cs6010grp1 vm_share]#
[root@cs6010grp1 vm_share]#

3) Create a folder in your host windows machine as below


C:\vm_share

4) In VM, add a link in the vm by selecting below menus  

see in below image- 

Devices--> shared_folder_setting--> Machine Folders --> vm_share
Auto-mount , Access should be YES.



5) Restart the VM





(vm_share (folder name), need to be correct folder name in below command)

6) Then Mount it with vboxsf command with root user- done
[root@cs6010grp1 Desktop]#
[root@cs6010grp1 Desktop]# mount -t vboxsf vm_share /vm_share

7) check it -

[root@cs6010grp1 Desktop]# cd /vm_share
[root@cs6010grp1 Desktop]# ls

Done. cheers ..Halim

How to split a string into rows by separating with any value (such as comma) in oracle sql ?

I am sure, you will find ton of articles, blogs or codes on this topics. but this one is unique in the sence of performance with lot of data.  Normally use of CONNECT BY keyword is very costly but try this one with large set of data.

Note: you need to minimize your data set as needed by using the sub-query as like I did otherwize CONNECT BY will hurt your performance a lot when you will applied into a full table.

(Change the red marked places with any other values as per your requirement)


SELECT *
FROM
  (SELECT a.before_split ,
    trim(regexp_substr(a.before_split, '[^,]+', 1, LEVEL)) after_split
  FROM
    (SELECT 'a,b,c,de,ff,gh,i,kl,l,m' before_split
    FROM dual ---or you can use a big table here a as source
    -- where ...
    ) a
    CONNECT BY instr(before_split, ',', 1, LEVEL-1) > 0
  ) ;




Output- as below- 

 

Cheers..Halim