Showing posts with label Storage. Show all posts
Showing posts with label Storage. Show all posts

Monday, February 7, 2022

How to Set Up a Samba Network Storage Drive on Raspberry Pi for Hikvision IP Cameras

Hikvision value IP cameras (such as the IPC-B120, IPC-B121H, and IPC-B120-D-W) feature onboard motion detection, infrared night vision, and H.265+ compression, but lack internal hard drives. Rather than purchasing an expensive commercial NVR, you can attach an external USB hard disk to a Raspberry Pi configured as an SMB/CIFS Network Attached Storage (NAS) target for continuous or motion-triggered video archiving.

Stack: Raspberry Pi 4 • External USB HDD (ext4) • Samba Server (SMBv2/v3) • Hikvision Storage Management

1. Installing and Configuring Samba on the Raspberry Pi

sudo apt-get update
sudo apt-get install samba samba-common-bin -y

# Create recording directory on mounted external drive
sudo mkdir -p /media/cctv_storage/hikvision
sudo chown -R nobody:nogroup /media/cctv_storage/hikvision
sudo chmod -R 0777 /media/cctv_storage/hikvision

2. Samba Share Definition (/etc/samba/smb.conf)

Hikvision firmware requires specific Samba dialect and locking settings to format network drives successfully:

[hikvision]
   comment = Hikvision CCTV Storage
   path = /media/cctv_storage/hikvision
   browseable = yes
   writeable = yes
   guest ok = yes
   read only = no
   create mask = 0777
   directory mask = 0777
   force user = nobody

Restart Samba:

sudo systemctl restart smbd

3. Mounting the Drive in Hikvision Web GUI

  1. Log into your camera's web interface → Configuration → Storage → Storage Management → Net HDD.
  2. Set Type to NAS / SMB/CIFS, enter the Raspberry Pi's IP address, set File Path to /hikvision, and save.
  3. Under HDD Management, select the newly added network disk and click Format / Init. Once status changes to Normal, motion recordings will save directly to your Pi.

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"

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.

Monday, December 24, 2012

Linux Server Performance Tuning: Reducing Disk I/O and System Load

When optimizing a high-traffic dedicated Linux server, disk I/O bottlenecks are often the primary cause of sluggish response times and elevated load averages. Here are several practical server-tuning techniques I applied to a heavily loaded production server, resulting in a dramatic reduction in disk I/O and much faster throughput.

Key Optimizations: RAM-backed /tmp mount • Dedicated SSD for MySQL data • FastCGI process management with Nginx + PHP-FPM

1. Mount /tmp as a Ramdisk (tmpfs)

Many web stacks heavily utilize /tmp for transient disk writes:

  • PHP Sessions: Default PHP configurations store active session files in /tmp (session.save_path).
  • MySQL Temporary Tables: Heavy queries with extensive JOIN or GROUP BY clauses frequently write temporary on-disk tables to /tmp (verify your path using mysqladmin variables | grep tmpdir).

Mounting /tmp directly into RAM eliminates spinning disk access for these operations. Add the following entry to your /etc/fstab:

none /tmp tmpfs nr_inodes=200k,mode=01777,nosuid,nodev 0 0

Remount or apply without rebooting:

mount -o remount /tmp

2. Isolate MySQL Datadir to High-Performance Storage (SSD)

Moving the MySQL database directory (/var/lib/mysql) to dedicated high-speed SSD storage removes the database write bottleneck and dramatically lowers IO wait times (%iowait) during peak traffic.

3. Adopt Nginx with PHP-FPM

Switching from Apache's traditional prefork MPM / mod_php handler to Nginx + PHP-FPM significantly cuts memory footprint per connection, handles concurrency gracefully, and frees up system resources for database caching.

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 ...