Tuesday, July 19, 2016

How to Configure Docker with the Btrfs Storage Driver on CentOS 7

On CentOS 7, Docker initially defaulted to the devicemapper storage driver in loop-lvm mode, which suffered from high I/O latency, severe disk fragmentation, and occasional filesystem deadlocks. Configuring Docker to use the Btrfs storage driver provides native copy-on-write subvolumes, instant snapshots, and superior performance for virtualized hosts.

Prerequisites: Dedicated block device or partition formatted as Btrfs (e.g. /dev/sdb1).

1. Create and Mount the Btrfs Filesystem

# Format partition as Btrfs
mkfs.btrfs -f /dev/sdb1

# Mount at Docker root directory
mkdir -p /var/lib/docker
mount -t btrfs /dev/sdb1 /var/lib/docker

Add the mount to /etc/fstab for persistence across reboots:

/dev/sdb1  /var/lib/docker  btrfs  defaults,compress=lzo  0 0

2. Configure Docker Daemon

Specify the Btrfs driver in /etc/docker/daemon.json:

{
  "storage-driver": "btrfs"
}

Start Docker and verify the active storage engine:

systemctl start docker
docker info | grep "Storage Driver"

Tuesday, March 8, 2016

How to Use Persian and Eastern Arabic Numerals for Zotero Citations in Microsoft Word

When writing academic papers and theses in Persian or Arabic using Microsoft Word, the Zotero plugin often renders citation reference numbers (e.g. [1], [2]) using Western Arabic numerals (1, 2, 3), even when Word's numeral display setting is configured to Context under File → Options → Advanced.

Goal: Automatically convert Zotero bibliography and in-text citation numbers into Persian / Eastern Arabic digits (۱, ۲, ۳).

The Solution: Modifying the CSL Locale Style

Zotero determines numeral localization through its Citation Style Language (CSL) locale definition. You can enforce native localized digits across your document:

  1. In Zotero, navigate to Preferences → Advanced → Config Editor.
  2. Search for extensions.zotero.export.bibliographyLocale and set it to fa-IR (or your target RTL language code).
  3. Alternatively, edit the CSL style file (.csl) by adding the xml:lang="fa-IR" attribute to the root <style> element:
    <style xmlns="http://purl.org/net/xbiblio/csl" version="1.0" xml:lang="fa-IR">
  4. Return to Word and click Zotero Refresh. All bracketed citations will update to Eastern Arabic / Persian numerals smoothly.

Tuesday, February 2, 2016

Installing ShareLaTeX with Docker and CSF Firewall on Linux (CentOS & Ubuntu)

Self-hosting ShareLaTeX (now Overleaf Community Edition) enables collaborative scientific paper writing with full data privacy. Deploying ShareLaTeX via its official Docker container is straightforward, but servers protected by ConfigServer Security & Firewall (CSF) require specific iptables routing configurations to allow containerized network traffic without exposing internal services.

Components: Docker Engine • ShareLaTeX Container • CSF Firewall iptables rules

1. Deploying the Container

docker run -d   -v ~/sharelatex_data:/var/lib/sharelatex   --name=sharelatex   -p 3000:80   sharelatex/sharelatex

2. Resolving CSF Firewall and Docker Bridging Conflicts

By default, CSF disables Docker's automated iptables forwarding rules, cutting off outbound container traffic and external port mapping. Add the following exceptions to /etc/csf/csfpost.sh to restore seamless Docker connectivity:

#!/bin/bash
# Allow bridge network traffic for Docker containers
iptables -A FORWARD -i docker0 -o eth0 -j ACCEPT
iptables -A FORWARD -i eth0 -o docker0 -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -t nat -A POSTROUTING -s 172.17.0.0/16 -o eth0 -j MASQUERADE

Make /etc/csf/csfpost.sh executable and restart CSF:

chmod +x /etc/csf/csfpost.sh
csf -r

Wednesday, January 6, 2016

How to Install and Use zerofree on CentOS, RHEL, and Fedora to Compact VM Disks

When shrinking dynamic virtual machine disk images (such as VirtualBox VDI, VMware VMDK, or QEMU QCOW2), zeroing out unused filesystem blocks is essential for effective host compression. Because Enterprise Linux distributions (CentOS 6/7, RHEL) do not ship zerofree in their default package repositories, compiling from source is the quickest solution.

Environment: CentOS 6/7 • RHEL • Fedora • Ext3 / Ext4 Filesystems

1. Installing Build Headers and Compiling zerofree

Install the e2fsprogs development headers and compile:

yum install e2fsprogs-devel gcc make -y
cd /usr/src
wget http://frippery.org/uml/zerofree-1.0.3.tgz
tar -zxf zerofree-1.0.3.tgz
cd zerofree-1.0.3
make
cp zerofree /usr/bin/

2. Zeroing Out Unallocated Blocks

Important: Always remount the target filesystem in read-only mode prior to executing zerofree to prevent filesystem corruption:

# Remount filesystem as read-only:
mount -o remount,ro /

# Run zerofree on the target block partition:
zerofree -v /dev/sda1

Once complete, shut down the VM and run your hypervisor's disk compacting command (e.g. VBoxManage modifymedium --compact disk.vdi) on the host machine.

Saturday, September 19, 2015

Configuring PETSc and Eclipse Parallel Tools Platform (PTP) on macOS and Linux (C++ / Fortran)

The PETSc (Portable, Extensible Toolkit for Scientific Computation) framework provides high-performance data structures, sparse matrix operations, and scalable linear/nonlinear solvers for finite element and scientific modeling. Setting up PETSc within the Eclipse Parallel Tools Platform (PTP) IDE simplifies debugging and cross-compilation across macOS and Linux.

Platforms Verified: macOS Yosemite • Ubuntu 14.04 LTS • CentOS / RHEL (OpenMPI) • C++ and Fortran Compilers

1. Building PETSc with OpenMPI

Configure PETSc with shared libraries and debugging enabled:

./configure --with-shared-libraries=1 --with-debugging=1 PETSC_ARCH=debug
make PETSC_DIR=/path/to/petsc PETSC_ARCH=debug all
make PETSC_DIR=/path/to/petsc PETSC_ARCH=debug test

2. Eclipse Project Configuration

  1. Environment Variables: In Project Properties → C/C++ Build → Environment, add:
    • PETSC_DIR: Absolute path to your PETSc root directory.
    • PETSC_ARCH: Set to debug for Debug configurations and release for Release.
  2. Include Paths: Under C/C++ General → Paths and Symbols → Includes:
    ${PETSC_DIR}/include
    ${PETSC_DIR}/${PETSC_ARCH}/include
  3. Linker Libraries & Path: Under C/C++ Build → Settings → Linker:
    • Libraries (-l): Add petsc
    • Library search path (-L): Add ${PETSC_DIR}/${PETSC_ARCH}/lib
    • Miscellaneous Linker flags: Add runtime path binding:
      -Wl,-rpath,"${PETSC_DIR}/${PETSC_ARCH}/lib"
  4. Fortran Preprocessing Flags: If using gfortran, navigate to Fortran Build → Settings → Miscellaneous and add:
    -cpp -dM

3. Verification Test (C++)

#include <iostream>
#include "petsc.h"

int main(int argc, char *argv[]) {
    PetscInitialize(&argc, &argv, PETSC_NULL, PETSC_NULL);
    PetscPrintf(PETSC_COMM_WORLD, "PETSc successfully initialized in Eclipse!
");
    PetscFinalize();
    return 0;
}

Wednesday, October 22, 2014

Automating Low-Cost Server Backups to Amazon Glacier with glacier-cmd (cPanel & Virtualmin)

Amazon Glacier provides an extremely cost-effective cold-storage solution for archiving periodic server backups (such as weekly full-system and MySQL snapshots) without paying standard S3 active storage pricing. Here is how to configure automated Glacier uploads using the command-line utility glacier-cmd on cPanel and Virtualmin servers.

Components: Amazon Glacier Vault • glacier-cmd Python CLI • Automated root cron backup workflow

1. Installing glacier-cmd

Install Python setup tools and the Glacier command-line interface:

yum install git python python-setuptools -y
cd /usr/src

# For cPanel servers, link git to system path if needed:
[ ! -f /usr/bin/git ] && ln -s /usr/local/cpanel/3rdparty/bin/git /usr/bin/git

git clone https://github.com/uskudnik/amazon-glacier-cmd-interface
cd amazon-glacier-cmd-interface
python setup.py install

2. Configuring AWS Credentials

Create ~/.glacier-cmd in the root home directory:

[aws]
access_key=YOUR_AWS_ACCESS_KEY_ID
secret_key=YOUR_AWS_SECRET_ACCESS_KEY

[glacier]
region=us-east-1
bookkeeping=True
bookkeeping-sqlite-db=/root/.glacier-cmd-db

3. Uploading Backups to a Vault

Create your backup vault and upload archives with automatic multipart chunking:

# Create a new vault
glacier-cmd mkvault server-backups

# Upload a backup archive with description
glacier-cmd upload --description "cPanel Weekly Full Backup $(date +%Y-%m-%d)" server-backups /backup/weekly-backup.tar.gz

Monday, May 26, 2014

Essential Fortran Tips: Implicit Typing, Common Blocks, and Array Bounds

When developing or maintaining scientific simulation and finite-element codes in Fortran, understanding memory sharing semantics and legacy typing rules prevents subtle computational bugs. Here are key fundamental tips to keep in mind:

Topics: Implicit precision typing • Common block limits • Explicit bounds declarations

1. Implicit Typing and Precision Control

By default in classic Fortran, variables starting with letters I through N default to integer, while all others default to single-precision real. You can enforce double precision across designated variable prefixes using:

IMPLICIT DOUBLE PRECISION (A-H, O-Z)

Modern recommendation: In Fortran 90 and newer, always specify IMPLICIT NONE at the top of every module and subroutine, explicitly declaring types and kinds (e.g. REAL(dp)) to avoid unintended variable scoping.

2. Blank vs. Named COMMON Blocks

  • A Fortran program may contain only one blank (unnamed) COMMON block across all translation units.
  • A program can declare any number of named COMMON blocks:
    COMMON /grid_params/ nx, ny, deltax, deltay
  • Ensure that variable sizes and ordering within named COMMON blocks match identically across all subroutines that include them.

How Google Antigravity Solved the Mysterious NVIDIA Sleep Reboot on My Dell Inspiron 7567 (Ubuntu Linux)

If you run modern Ubuntu or Linux on a Dell Inspiron 15 Gaming (7567) or a similar 7th-gen Intel laptop paired with an NVIDIA GeForce GTX ...