AlmaLinux: Using a USB SATA Dock (External Drive)

Commands and safe workflow for a lay-flat USB-to-SATA dock (2.5" SSD / 3.5" HDD). Built for C&C BME.

USB 3.x SATA SSD / HDD Mount / Copy / Unmount Safety First

0) Safety Rules (Read Once)

Danger zone: commands like dd, wipefs, mkfs, parted, sgdisk can destroy data instantly if you pick the wrong disk.

1) Plug In the Dock and Detect the Drive

After you power the dock and insert the drive, run:

lsusb
dmesg -T | tail -n 60
lsblk -o NAME,SIZE,TYPE,FSTYPE,LABEL,UUID,MOUNTPOINTS,MODEL,SERIAL
Tip: lsblk is your best friend. Look for a new device like /dev/sdb with partitions like /dev/sdb1, /dev/sdb2, etc.

Show partition details

sudo fdisk -l /dev/sdX
sudo blkid /dev/sdX*

Replace sdX with the correct device (example: sdb).

2) Create a Mount Point

sudo mkdir -p /mnt/dock

3) Mount the Drive

3A) Normal read-write mount (trusted drive)

sudo mount /dev/sdX1 /mnt/dock

3B) Read-only mount (recommended for unknown drives)

sudo mount -o ro /dev/sdX1 /mnt/dock

3C) If it’s NTFS or exFAT

You may need filesystem helpers installed (especially for Windows drives).

# Common helpers (availability can vary by Alma version/repos)
sudo dnf install -y ntfs-3g exfatprogs
If dnf can’t find a package, don’t force it—tell Clarus what Alma version you’re on and the exact error output.

Confirm mount

df -hT | grep -E '/mnt/dock|Filesystem'
mount | grep /mnt/dock

4) Copy Data Off the External Drive

4A) Use rsync (recommended)

# Copy everything to a local folder (preserve times/permissions where possible)
sudo mkdir -p /data/recovery
sudo rsync -aHAX --info=progress2 /mnt/dock/ /data/recovery/

4B) If permissions fight you (common with mixed filesystems)

sudo rsync -a --no-perms --no-owner --no-group --info=progress2 /mnt/dock/ /data/recovery/

4C) Quick integrity check (counts only)

find /mnt/dock -type f | wc -l
find /data/recovery -type f | wc -l

5) Health Check (Optional but Smart)

For SSD/HDD health (SMART), install tools and query:

sudo dnf install -y smartmontools
sudo smartctl -a /dev/sdX
If SMART shows lots of errors / reallocated sectors / pending sectors, treat the drive as fragile and copy data ASAP (prefer read-only mounting).

6) Unmount and Safely Remove

Unmount

sudo umount /mnt/dock

If it says “busy”

sudo lsof +f -- /mnt/dock
sudo fuser -vm /mnt/dock

Close programs using the mount, then try umount again.

Flush writes (good habit)

sync

Optional: power-off the USB device (if supported)

# Shows block devices and whether they are removable
lsblk -o NAME,RM,SIZE,MODEL,MOUNTPOINTS
After umount + sync, it’s safe to power off the dock and remove the drive.

7) Bonus: Imaging a Drive (Recovery / Forensics)

If you want a disk image (careful: requires lots of space):

Safer recovery imaging: ddrescue (recommended)

sudo dnf install -y gddrescue

# Example: image the entire disk to a file (needs large destination space)
sudo mkdir -p /data/images
sudo ddrescue -f -n /dev/sdX /data/images/disk.img /data/images/disk.log

# Optional retry pass (can take a long time)
sudo ddrescue -d -f -r3 /dev/sdX /data/images/disk.img /data/images/disk.log
Do not reverse source/destination. In these commands, /dev/sdX is the SOURCE and the .img file is the DESTINATION.