How to mount raw (.img) images in Linux

You may have raw images in your system coming from some bare metal VM, like KVM/Vmware. You may mount them directly to the host machine without attaching them to a VM. To do so, you need two things:

  1. Partition to mount
  2. Sector size of the partition and the first position of the partition.

Both of these, can be derived using a command called fdisk with attribute l as the following:

[root@vps5 vpsextra]# fdisk -l mhdevelopment.img

Disk mhdevelopment.img: 268.4 GB, 268435456000 bytes, 524288000 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: 0x000f1752

            Device Boot      Start         End      Blocks   Id  System
mhdevelopment.img1            2048   523241471   261619712   83  Linux
mhdevelopment.img2       523241472   524287999      523264   82  Linux swap / Solaris
You have new mail in /var/spool/mail/root
[root@vps5 vpsextra]#

Here, we are trying to mount an old image of mine, called ‘mhdevelopment.img. I would like to mount the partition that is not swap, which is namely ‘mhdevelopment.img2’ here. This partition starts from 2048 and the sector size is 512 bytes.

So to mount the partition, you can now use the following command:

sudo mount -o loop,offset=$((2048 * 512)) mhdevelopment.img /mnt

This will mount the the partition mhdevelopment.img1 to /mnt. If you want to change the mount destination, you may do this at the end in replace of /mnt to wherever you want this to be.

Happy shooting.

How to add Bangla Taka (৳) currency symbol in WkHTMLtoPdf / Odoo / OpenERP Qweb Report

WkHTMLtoPDF is a tool to convert html reports to PDF. Odoo/OpenERP uses this tool to generate PDF reports. If you are using an unicode character in PDF report, that character has to be installed in font package in the system. If you are using Windows, Bangla characters are available by default. But that is not same for Linux.

Bangla & Assamese fonts are available for Linux, in a package called ‘lohit’.

To install Bangla fonts in CentOS/Redhat based system, use the following:

yum install lohit-bengali-fonts

To install in Debian/Ubuntu based system, use the following:

apt install fonts-lohit-beng-bengali

Once this is installed, PDF reports should start showing the Bangla characters properly.

Happy shooting!

The GPG keys listed for the “MySQL 5.7 Community Server” repository are already installed but they are not correct for this package.

When you try to run yum update, you see an error like the following:

The GPG keys listed for the "MySQL 5.7 Community Server" repository are already installed but they are not correct for this package.

This is coming because the GPG key for Mysql 5.7 community repo has changed. To update the GPG key, you may run the following:

rpm --import

This shall resolves the issue for you. Good luck.

How to Set Default Route Interface when there are multiple Interfaces in CentOS

Consider the following situation, you have two interfaces in your system, eth0, and eth1 (or more). Both the interfaces have a default gateway. But how can you choose which interface to follow as the default outbound requests by the server? This could be a situation like adding secondary alias IP addresses to an interface (Like eth0, eth0:0, eth0:1, eth0:2, etc).

In these cases, Linux can decide based on its own algorithm. The problem with this is in the case of Licensing. In most licensing systems these days, you need to provide an outbound IP address to your server. If this IP changes over time, you would have trouble managing the license. For these cases, you need to define your default interface to Linux.

You may set this configuration under /etc/sysconfig/network file. The ‘key’ for the settings is ‘GATEWAYDEV’.

So for example if your gatewaydev would be eth0:1, the file would look like something following:


or if it is eth1, the following:


I Hope, this helps somebody. Good luck

How to Concat/Merge/Join Two Array in Javascript ES6

Let’s say, we have two arrays:

let arr1 = [1, 2, 3]
let arr2 = [5, 6, 7]

Now, you want to have a third array that merges the two arrays:

let arr3 = [1, 2, 3, 4, 5, 6]

To achieve that, you can simply destructure the two arrays and use the result to create another array like following:

let arr3 = [...arr1, ...arr2]
[1, 2, 3, 4, 5, 6]

How to center an element in full screen with Tailwind CSS

After a lot of system administration and backend programming stuffs on this blog, let’s check some experiences with frontend and designing.

Tailwind is my favorite most used CSS framework. A common thing, I face on centering an element on the screen. There are a couple of ways to do it. First, we can actually use flex and horizontal and vertical center to put the element in the center, and use h-screen to take the height of full screen like following:

    <div class="h-screen flex justify-center items-center">
            Element on the center of the screen

There are other ways to do it as well. You can set the flex and h-screen to the container, and m-auto to allow margin to put your inside element center of the screen, like the following:

<div class="h-screen flex">
    <div class="m-auto">
        Element on the center of the screen

Then, you probably want to put the content as a modal. To use the modal, you need to set the position absolute. Here is how you may do this:

<div class="relative">
    <div class="absolute inset-0 h-screen flex">
        <div class="m-auto">
            Element on the center of the screen

or like the following:

<div class="relative">
    <div class="absolute inset-0 h-screen flex justify-center items-center">
            Element on the center of the screen

Hope this helps to someone, and myself specially when I forget after a while, on how to create a center modal in Tailwind 🙂

How to manipulate time in Odoo Qweb Report

In Odoo Qweb report, you probably want to change the time to something else, like add few hours, or change the timezone, or so on. To do that, you would need to use ‘t-esc’ template attribute of Odoo. Here is an example of how to add 6 hours to the original timestamp and then convert the time to string to show the value according to the user preference:

<span t-esc="(o.date_done + datetime.timedelta(hours=6)).strftime('%d/%m/%Y %I:%M %p')"/>

o.date_done is getting the date_done from the picking that you are visiting.

Odoo Time Showing in Form View does not match Time in Qweb Report – Timezone Mismatch


You are seeing a time in the Odoo form view, which is using the correct timezone, but when you try to download the report of the same form view data, you see, the timezone is changed to UTC or something else. How to fix this?


The issue appears when the user has configured a different timezone or has not, while the Odoo system uses a central timezone. Make sure to set the timezone for the user to same as the one Odoo uses. You may do so, from

Odoo >> Settings >> Users >> Select User >> Edit >> Preference >> Set Timezone

If this does not solve the problem, then the problem probably appears because Odoobot is set to use a different timezone, and your report is generated using ‘sudo()’ function. To set the timezone for Odoobot

Odoo >> Settings >> Users >> From the Filters, select ‘Inactive Users’ >> Click on Odoobot >> Edit >> Preference >> Set the Timezone

Hope this helps.

Email Deleted/Archived But Still Showing in Space Usage – Cpanel/Dovecot


Your customer has deleted the emails using Outlook/Imap client or may have archived them on their PC. But the space usage didn’t change in your Cpanel counterpart. What do to?


The issue arises because Dovecot Imap does soft delete when issuing delete command. They don’t necessarily get deleted, instead marked for expunge. You need to issue the expunge/purge command to get the storage cleared. In Cpanel, they usually do it on the daily upcp command they run. But if you are not running upcp daily, or would like to voluntarily do this, you can do this by running the following command:


If you do not run upcp daily, then you can run the above command using a cron, daily to make sure IMAP deletions are expunged daily to reclaim storage.

The above command expunges all the accounts that require expunge. But if you want to expunge any single account, you may do so using the following command:

doveadm purge -u [email protected]

Replace [email protected] with the email address that has issued the deletes.

How to create a CSV from MySQL Query


I have a SQL query, how can I create a CSV file from the SQL Query?


I had a customer looking for such an option. This can be easily achieved using ‘into outfile’ attribute of MySQL. Let me provide an example query like the following:

select * from wp_woocommerce_orders left join wp_posts on = wp_woocommerce_orders.order_id into outfile '/var/lib/mysql/orders_list.csv' FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '\n';

The above query is joining the order table of woocommerce with the WordPress posts table, and putting the output file in /var/lib/mysql/orders_list.csv file, in which each field is being terminated by a comma (aka comma separated file) and after each row, it is terminating with a new line separator. One thing you need to remember is if you are not root, then you should provide the path to store the file in a place where you can write the file, for example, your home directory, which could be like /home/yourusername/something.csv

Hope this helps others to know how to achieve this.