Operations 10 min read

Accelerate Linux Ops: Fast Deletion, iSCSI Detection & Quick Group Management

This guide presents practical Linux and vSphere techniques—including using rsync for rapid bulk file deletion, detecting newly added iSCSI disks without reboot, safeguarding rm commands, mounting remote filesystems with SSHFS, and quickly adding users to supplementary groups via gpasswd—to boost operational efficiency.

Efficient Ops
Efficient Ops
Efficient Ops
Accelerate Linux Ops: Fast Deletion, iSCSI Detection & Quick Group Management

1. Fast Deletion of Large Number of Files in Linux

Using rm to delete many small files or large files can be slow and may leave disk space unreleased because each entry is unlinked individually. Replacing rm with rsync improves performance by creating an empty directory and syncing it over the target, avoiding extensive traversal.

Key rsync delete options:

rsync --help | grep delete
     --del                   an alias for --delete-during
     --delete                delete files that don't exist on the sending side
     --delete-before         receiver deletes before transfer (default)
     --delete-during         receiver deletes during transfer, not before
     --delete-after          receiver deletes after transfer, not before
     --delete-excluded       also delete excluded files on the receiving side
     --ignore-errors         delete even if there are I/O errors
     --max-delete=NUM        don't delete more than NUM files

Typical fast‑delete command:

mkdir -p /del_tmp
rsync --delete-before -a -H -v --progress --stats ./del_tmp/ ./del_dest/

2. Detect New iSCSI Disk in vSphere Without Reboot

When a new iSCSI disk is added to a VM, the filesystem can be refreshed without reboot using either of two methods.

Method 1 – add the device via the SCSI host interface:

echo 'scsi add-single-device 2 0 1 0' > /proc/scsi/scsi

Parameters: HOST=2 (adapter), Channel=0, ID=1 (new disk).

Method 2 – trigger a SCSI bus scan for each host:

# Refresh SCSI; repeat for each host
echo "- - -" > /sys/class/scsi_host/host0/scan
echo "- - -" > /sys/class/scsi_host/host1/scan
echo "- - -" > /sys/class/scsi_host/host2/scan

Either method makes the new disk visible without restarting the VM.

3. Prevent Accidental Deletion with rm

The colon ( :) in Bash is a built‑in command that can be used for parameter expansion. By leveraging the `${parameter:-default}` syntax, you can avoid dangerous empty variables in rm commands.

# Dangerous example (may delete root if $dest is empty)
rm -rf ${dest:-test}

# Safer version
rm -rf /${dest:-test}

4. Fast Mount Between Linux Servers

While NFS is common for sharing directories, sshfs provides a quick, SSH‑based alternative.

# Install SSHFS
yum install sshfs

# Create mount point
mkdir /mnt/data

# Mount remote directory
sshfs [email protected]:/home/test/ /mnt/data

# Use key‑based authentication (optional)
sshfs -o IdentityFile=~/.ssh/id_rsa [email protected]:/home/test/ /mnt/data

This approach is simple and works well for ad‑hoc data sharing.

5. Quickly Add Users to Supplementary Groups

Using usermod -G overwrites existing groups. The gpasswd command can add a user to an additional group without needing to know the current group list.

# Add test1 to test2 group
gpasswd -a test1 test2

# Add test1 to test3 group
gpasswd -a test1 test3

Summary

By applying these straightforward Linux and vSphere techniques—rsync for bulk deletion, SCSI rescanning for iSCSI disks, safe rm patterns, SSHFS for rapid mounts, and gpasswd for group management—operations teams can improve efficiency and reduce manual overhead.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

OperationslinuxrsynciSCSIvSpheregpasswdsshfs
Efficient Ops
Written by

Efficient Ops

This public account is maintained by Xiaotianguo and friends, regularly publishing widely-read original technical articles. We focus on operations transformation and accompany you throughout your operations career, growing together happily.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.