Archive for category Linux

How to load VirtualBox driver

VirtualBox
If for any reason (for instance Genymotion complaining about not finding VirtualBox) and you need to reload the VirtualBox driver keep in mind that the script that do this has been moved in newest Debian/Ubuntu versions, so if you used to run this:

/etc/init.d/vboxdrv.sh setup

Now you must reload the module this way:

/usr/lib/virtualbox/vboxdrv.sh setup


,

No Comments

How to update Linux time zones

time zone map
On May 1st, Venezuela will change its time zone to UTC-4, therefore in Linux you must update your tzdata package to be ready to this change. To do so just just follow these steps:

Debian/Ubuntu

aptitude update
aptitude safe-upgrade tzdata

Red Hat

yum check-update
yum update tzdata

In order to check whether the update has the time zone changes you can run this command:

zdump -v /usr/share/zoneinfo/right/America/Caracas  | grep 2016

/usr/share/zoneinfo/right/America/Caracas  Sun May  1 06:59:59 2016 UT = Sun May  1 02:29:59 2016 VET isdst=0 gmtoff=-16200
/usr/share/zoneinfo/right/America/Caracas  Sun May  1 07:00:00 2016 UT = Sun May  1 03:00:00 2016 VET isdst=0 gmtoff=-14400

Reference: How to check if the Time Zone database

2 Comments

Installing Java on Debian

centOS 6

If you need to install Oracle Java on Debian, you can follow the next steps once the binary file had been downloaded from Oracles’s download page:

Once it has been downloaded, proceed to extract it into the /opt directory:

# tar xvzf jdk-8u45-linux-x64.tar.gz

First let’s check the current java version:

# java -version
java version "1.7.0_79"
OpenJDK Runtime Environment (IcedTea 2.5.5) (7u79-2.5.5-0ubuntu0.14.04.2)
OpenJDK 64-Bit Server VM (build 24.79-b02, mixed mode)

Here you can see it points to OpenJDK’s 1.7.0_79 version. Now let’s add a path to the version to use:

# update-alternatives --install /usr/bin/java java /opt/jdk1.8.0_45/bin/java 1

Last line adds the /opt/jdk1.8.0_45/bin/java path to /usr/bin/java java  binary, in other words, it creates a symbolic link to use in case that options is chosen. Let’s set an alternative that points to the new path:

# update-alternatives --config java
  Selection Path Priority Status
------------------------------------------------------------
* 0 /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java 1071 auto mode
 1 /opt/jdk1.8.0_45/bin/java 1 manual mode
 2 /usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java 1061 manual mode
 3 /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java 1071 manual mode
 Enter to keep the current selection[+], or type selection number: |

After choosing the option 1, check the java version one more time:

# java -version
java version "1.8.0_45"
Java(TM) SE Runtime Environment (build 1.8.0_45-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)

Now the binary points to the Oracle’s version. You can check it with the symbolic links:

# ls -l /usr/bin/java
lrwxrwxrwx 1 root root 22 jun  9  2014 /usr/bin/java -> /etc/alternatives/java

# ls -l /etc/alternatives/java
lrwxrwxrwx 1 root root 25 jun 15 09:21 /etc/alternatives/java -> /opt/jdk1.8.0_45/bin/java

 

 

,

2 Comments

It’s back…

Luis’ Blog is back after some months in pause, and thanks to a friend of mine who is hosting the site. Several people asked me about the blog or information that only can find in my blog, therefore I decided to reactivate again. I hope it helps you, you learn something new or just be a way to change information. Enjoy it!

, , ,

2 Comments

How to enable the Web UI on qBittorrent

If you want to manage your qBittorrent server using a web interface, follow these steps:

  1. On the menu bar, go to Tools > Options qBittorrent WEB UI
  2. In the new window, choose Web UI option
  3. Check Enable the Web User Interface (Remote control) option
  4. Choose a port (default 8080)
  5. Set username and password (default username: admin / password: adminadmin) WEB UI
  6. Click on Ok to save settings.

Now in a browser you can check your qBittorrent server if you put your server’s IP address and port, example: 192.168.1.100:8080 as show below: qBittorrent Web UI You can also access it from your Android device by installing qBittorrent Client or qBittorrent Client Pro: qBitttoren Client Pro

, ,

No Comments

How to extend a volume on LVM

Sometimes it is necessary to extend a logical volume, expanding the physical volume where it is hosted. If this is the case, you can follow this example extending a volume of 450 GB to 500 GB: First, Let’s check the disk geometry:

:~# fdisk -l /dev/sdb
Disk /dev/sdb: 483.2 GB, 483183820800 bytes
 255 heads, 63 sectors/track, 58743 cylinders, total 943718400 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 identifier: 0x0001178e

After expanding the volume you must make the system to rescan the volume:

:~# echo 1 > /sys/block/sdb/device/rescan

Then check the disk geometry one more time:

:~# fdisk -l /dev/sdb
Disk /dev/sdb: 536.9 GB, 536870912000 bytes
 255 heads, 63 sectors/track, 65270 cylinders, total 1048576000 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 identifier: 0x0001178e

As you can see, the disk size grew up but this is only known by the operating system, because the LVM still has the same information since the physical volume hasn’t been expanded yet:

:~# pvs
 PV VG Fmt Attr PSize PFree
 /dev/sda5 debian lvm2 a-- 3.76g 0
 /dev/sda6 debian lvm2 a-- 13.00g 0
 /dev/sdb svn_vg lvm2 a-- 450.00g 0

If you extend the physical volume with the following command:

:~# pvresize /dev/sdb
 Physical volume "/dev/sdb" changed
 1 physical volume(s) resized / 0 physical volume(s) not resized

And check the physical volume sizes you will see the added space:

:~# pvs
 PV VG Fmt Attr PSize PFree
 /dev/sda5 debian lvm2 a-- 3.76g 0
 /dev/sda6 debian lvm2 a-- 13.00g 0
 /dev/sdb svn_vg lvm2 a-- 500.00g 50.00g

Now you have to extend the logical volume and the system file size on the fly. You can do both actions using just one command:

:~# lvresize -r -L +50G /dev/mapper/svn_vg-svn
 Extending logical volume svn to 500.00 GiB
 Logical volume svn successfully resized
 resize2fs 1.42.5 (29-Jul-2012)
 Filesystem at /dev/mapper/svn_vg-svn is mounted on /var/data/svn; on-line resizing required
 old_desc_blocks = 29, new_desc_blocks = 32
 Performing an on-line resize of /dev/mapper/svn_vg-svn to 131070976 (4k) blocks.
 The filesystem on /dev/mapper/svn_vg-svn is now 131070976 blocks long.

Finally, check the free space available to see the added 50 GB in the system file:

:~# df -h
 Filesystem Size Used Avail Use% Mounted on
 rootfs 993M 287M 655M 31% /
 udev 10M 0 10M 0% /dev
 tmpfs 397M 228K 397M 1% /run
 /dev/mapper/debian-root 993M 287M 655M 31% /
 tmpfs 5.0M 0 5.0M 0% /run/lock
 tmpfs 794M 0 794M 0% /run/shm
 /dev/sda1 228M 34M 183M 16% /boot
 /dev/mapper/debian-home 2.0G 39M 1.9G 3% /home
 /dev/mapper/debian-tmp 3.9G 7.1M 3.7G 1% /tmp
 /dev/mapper/debian-usr 2.0G 869M 1.1G 46% /usr
 /dev/mapper/debian-var 6.7G 2.1G 4.3G 33% /var
 /dev/mapper/svn_vg-svn 493G 432G 62G 88% /var/data/svn

,

2 Comments

How to install VMWare Tools on Red Hat and CentOS

 

VMWare how to install VMWare tools on CentOS and Red Hat - running If you need to install VMWare Tools on virtual machines running Red Hat or CentOS as operating system, you can follow the procedure described next:

Procedure

First of in VMWare vSphere locate the virtual machine you want to install the VMWare Tools and click on “Install VMWare Tools” as shown in the next image: VMWare how to install VMWare tools on CentOS and Red Hat You will see a dialog window indicating that the VMWare Tools will be mounted by clicking on the “mount” button. Then in the virtual machine where you want to install the VMWare Tools you must do the following in the terminal:

# mount /dev/cdrom /mnt/
mount: block device /dev/sr0 is write-protected, mounting read-only

# cp /mnt/VMwareTools-9.0.0-782409.tar.gz /opt/

# cd /opt/
# tar xvzf VMwareTools-9.0.0-782409.tar.gz

# cd vmware-tools-distrib/

#./vmware-install.pl

The latter is a script which will ask you questions related to the VMWare Tools intallation. In genersl terms the default option are okay, but if you want to modify any parameter you can change any value according to your needs:

Creating a new VMware Tools installer database using the tar4 format.

Installing VMware Tools.

In which directory do you want to install the binary files?
[/usr/bin]

What is the directory that contains the init directories (rc0.d/ to rc6.d/)?
[/etc/rc.d]

What is the directory that contains the init scripts?
[/etc/rc.d/init.d]

In which directory do you want to install the daemon files?
[/usr/sbin]

In which directory do you want to install the library files?
[/usr/lib/vmware-tools]

The path "/usr/lib/vmware-tools" does not exist currently. This program is
going to create it, including needed parent directories. Is this what you want?
[yes]

In which directory do you want to install the documentation files?
[/usr/share/doc/vmware-tools]

The path "/usr/share/doc/vmware-tools" does not exist currently. This program
is going to create it, including needed parent directories. Is this what you
want? [yes]

The installation of VMware Tools 9.0.0 build-782409 for Linux completed
successfully. You can decide to remove this software from your system at any
time by invoking the following command: "/usr/bin/vmware-uninstall-tools.pl".

Before running VMware Tools for the first time, you need to configure it by
invoking the following command: "/usr/bin/vmware-config-tools.pl". Do you want
this program to invoke the command for you now? [yes]
Initializing...

Making sure services for VMware Tools are stopped.

The VMware FileSystem Sync Driver (vmsync) allows external third-party backup
software that is integrated with vSphere to create backups of the virtual
machine. Do you wish to enable this feature? [no]

Found a compatible pre-built module for vmci. Installing it...

Found a compatible pre-built module for vsock. Installing it...

The module vmxnet3 has already been installed on this system by another
installer or package and will not be modified by this installer. Use the flag
--clobber-kernel-modules=vmxnet3 to override.

The module pvscsi has already been installed on this system by another
installer or package and will not be modified by this installer. Use the flag
--clobber-kernel-modules=pvscsi to override.

The module vmmemctl has already been installed on this system by another
installer or package and will not be modified by this installer. Use the flag
--clobber-kernel-modules=vmmemctl to override.

The VMware Host-Guest Filesystem allows for shared folders between the host OS
and the guest OS in a Fusion or Workstation virtual environment. Do you wish
to enable this feature? [no]

Found a compatible pre-built module for vmxnet. Installing it...

The vmblock enables dragging or copying files between host and guest in a
Fusion or Workstation virtual environment. Do you wish to enable this feature?
[no]

!!! [EXPERIMENTAL] !!!
VMware automatic kernel modules enables automatic building and installation of
VMware kernel modules at boot that are not already present. By selecting yes,
you will be enabling this experimental feature. You can always disable this
feature by re-running vmware-config-tools.pl.

Would you like to enable VMware automatic kernel modules?
[no]

No X install found.

Creating a new initrd boot image for the kernel.
vmware-tools start/running
The configuration of VMware Tools 9.0.0 build-782409 for Linux for this running
kernel completed successfully.

You must restart your X session before any mouse or graphics changes take
effect.

You can now run VMware Tools by invoking "/usr/bin/vmware-toolbox-cmd" from the
command line.

To enable advanced X features (e.g., guest resolution fit, drag and drop, and
file and text copy/paste), you will need to do one (or more) of the following:
1. Manually start /usr/bin/vmware-user
2. Log out and log back into your desktop session; and,
3. Restart your X session.

Enjoy,

--the VMware team

Found VMware Tools CDROM mounted at /mnt. Ejecting device /dev/sr0 ...
No eject (or equivilant) command could be located.
Eject Failed: If possible manually eject the Tools installer from the guest
cdrom mounted at /mnt before canceling tools install on the host.

When the script had finished the VMWare Tools will be installed on the virtual machine. Now you can umount the ISO by doing:

# umount /mnt

Theb in VSphere you can check that VMWare Tools are running as shown in the first picture of this articl.

,

No Comments

How to move a physical volume on LVM

LVM move

If you need to move data from one disk to another one you could think in copying the data with cp, rsync, or any other tool, and then umount the partition, edit the /etc/fstab file to point to the new path, and all that involve to remove a disk or partition for another one. But if you forcasted and partitioned using LVM, there is a cleaner way of changing partitions on the fly, I mean, without umounting partitions and even leaving the same references in the /etc/file, because the same LVM partition will be used. Let’s see an example: if you have a 50 GB disk as a physical volume in /dev/sdb, which is set in a volume grup called data, and you need to move all data to another disk /dev/sdc, just do the following. First the initial distribution si shown:

LVM concepts

You can check the current state of the physical volumes using the pvs command:

# pvs
PV VG Fmt Attr PSize PFree
 /dev/sda2 system lvm2 a- 19.77g 0 
 /dev/sdb data lvm2 a- 50.00g 0

Then create the physical volume where the data will be moved:

# pvcreate /dev/sdc
 Physical volume "/dev/sdc" successfully created

Check the physical volumes again:

# pvs
PV VG Fmt Attr PSize PFree 
 /dev/sda2 system lvm2 a- 19.77g 0 
 /dev/sdb data lvm2 a- 50.00g 0 
 /dev/sdc lvm2 a- 50.00g 50.00g

Now check the volume groups:

# vgs
VG #PV #LV #SN Attr VSize VFree
 data 1 1 0 wz--n- 50.00g 0 
 system 1 6 0 wz--n- 19.77g 0

As you can see the volume group called data sizes 50 GB. Because this is the volume group which have the physical volume you want to move (/dev/sdb), you must add the physical volume to this group:

# vgextend data /dev/sdc
 Volume group "data" successfully extended

If you check it one more time you will see that the volume group has 100 GB  which correspond to  /dev/sdb (0 GB free) y /dev/sdc ( 50 GB free):

# pvs
PV VG Fmt Attr PSize PFree 
 /dev/sda2 system lvm2 a- 19.77g 0 
 /dev/sdb data lvm2 a- 50.00g 0 
 /dev/sdc data lvm2 a- 50.00g 50.00g
# vgs
 VG #PV #LV #SN Attr VSize VFree 
 data 2 1 0 wz--n- 99.99g 50.00g
 system 1 6 0 wz--n- 19.77g 0

Now let’s proceed to move the data from the physical volume  /dev/sdb to /dev/sdc:

LVM move

# pvmove /dev/sdb
/dev/sdb: Moved: 0.0%
/dev/sdb: Moved: 11.8%
/dev/sdb: Moved: 30.5%
/dev/sdb: Moved: 75.7%
/dev/sdb: Moved: 95.0%
/dev/sdb: Moved: 99.3%
/dev/sdb: Moved: 100.0%

There is not need to specify the other volume because the data will be distributed among the remaining physical volumes of the volume group, and in this case it is just /dev/sdc. Now, let’s check the distribution of the physical volumes:

# pvs
PV VG Fmt Attr PSize PFree 
 /dev/sda2 system lvm2 a- 19.77g 0 
 /dev/sdb data lvm2 a- 50.00g 50.00g
 /dev/sdc data lvm2 a- 50.00g 0

As you can see the /dev/sdb has no data (50 GB free) while /dev/sdc has the data (0 GB free). Just

Como puede verse el disco /dev/sdb no tiene datos (50 GB libres) mientras que /dev/sdc tiene los datos (0 GB libres). Now remove the physical volume to disincorporate from the volume group:

# vgreduce data /dev/sdb
 Removed "/dev/sdb" from volume group "data"

Now check the volume groups and the physical volumes:

# pvs
PV VG Fmt Attr PSize PFree 
 /dev/sda2 system lvm2 a- 19.77g 0 
 /dev/sdb lvm2 a- 50.00g 50.00g
 /dev/sdc data lvm2 a- 50.00g 0
# vgs
VG #PV #LV #SN Attr VSize VFree
 data 1 1 0 wz--n- 50.00g 0 
 system 1 6 0 wz--n- 19.77g 0

Finally proceed to wipe the physical volume::

# pvremove /dev/sdb
 Labels on physical volume "/dev/sdb" successfully wiped
# pvs
PV VG Fmt Attr PSize PFree
 /dev/sda2 system lvm2 a- 19.77g 0
 /dev/sdc data lvm2 a- 50.00g 0

This allows data to be moved from one disk to another without copying the data on operating system level, without interrupting services or restarting the computer. At the end we will have the disk /dev/sdc as the physical volume of the volume data as shown below:

LVM final

Reference: http://www.tldp.org/HOWTO/LVM-HOWTO/removeadisk.html

,

2 Comments

LPIC-2 certification

LPIC-2 diploma  LPIC-2 credential card

At last my certificate and card ID for LPIC-2 have arrived, which involve exams 201 and 202.  Unlike the LPIC-1 certification, it took more time to arrive (in fact I had to insist in delivering them) but finally they already arrived.

If you are interested in achieving this certification you can get further info at LPI ‘s page for LPIC-2

, , ,

4 Comments

Gitlab full Postgresql backup and restore

GitLab and Posgresql

GitLab can be used with Postgresql as its database engine  (beside MySQL),  and all come ready to make backups and restores of its databases and git repositories by using a ruby script (rake). This is the recommended way because it lets you recover everything wit not pending transactiond on database and Git sides.

The problem

The documentation explains all you have to perform a manual backup and restore, but the latter fails because it tries to insert existing registers that generate conflicts like this one:

ALTER SEQUENCE
psql:/home/git/gitlab/tmp/backups/db/database.sql:812: ERROR: relation "users" already exists

The Solution

The postgresql backup must erase all tables before trying to recreate them and insert the registers. That can be done by including the  –clean r -c  to the pg_dump command. This option must be edited in the ruby script that makes the backup, which is  /home/git/gitlab/lib/backup/database.rb by default. In this file you have to find this part of code and substitute the following bold line:

require 'yaml'
module Backup
 class Database
 attr_reader :config, :db_dir
def initialize
 @config = YAML.load_file(File.join(Rails.root,'config','database.yml'))[Rails.env]
 @db_dir = File.join(Gitlab.config.backup.path, 'db')
 FileUtils.mkdir_p(@db_dir) unless Dir.exists?(@db_dir)
 end
def dump
 success = case config["adapter"]
 when /^mysql/ then
 print "Dumping MySQL database #{config['database']} ... "
 system('mysqldump', *mysql_args, config['database'], out: db_file_name)
 when "postgresql" then
 print "Dumping PostgreSQL database #{config['database']} ... "
 pg_env
 system('pg_dump', config['database'], out: db_file_name)
 end
 report_success(success)
 end

This line must be replaced with this other line:

system('pg_dump', config['database'], '-c', out: db_file_name)

Here you can see that option -c is passed as argument to command pg_dump. This will force to include all DROPS needed in the generated .sql  for the GitLab backup.

,

No Comments