dataDesk BLOG

Welcome to the blog of Mr.G

Nature
Posts: 2

Blog 1: Useful_USB_disk_monitoring.md | (Open) | (Share)

▲ Previous | Next ▼

/Dev/DietPi

(Last modified: May 18 2026 01:05:26)

Useful USB disk monitoring

Useful USB disk monitoring and power-management commands on Linux/DietPi.

Show disks and UUIDs:

lsblk -f

Show currently mounted filesystems:

findmnt

Show all active mounts:

mount

Show detailed disk IDs:

ls -l /dev/disk/by-id/

Show filesystem UUIDs:

sudo blkid

Live kernel USB/disk events:

sudo dmesg -w

Filter USB-related kernel messages:

sudo dmesg -T | grep -iE "usb|reset|disconnect|uas|error"

Watch disks appear/disappear live:

watch -n1 lsblk

Show USB topology and drivers:

lsusb -t

Check current disk power state:

sudo hdparm -C /dev/sda

Possible outputs:

  • active/idle
  • standby
  • sleeping

Disable automatic disk standby temporarily:

sudo hdparm -S 0 /dev/sda

Check whether standby is disabled:

sudo hdparm -I /dev/sda | grep level

Test wake-up delay:

time ls /mnt/wd500 >/dev/null

Disable USB autosuspend temporarily until reboot:

echo -1 | sudo tee /sys/module/usbcore/parameters/autosuspend

Restore default USB autosuspend behavior:

echo 2 | sudo tee /sys/module/usbcore/parameters/autosuspend

Check current autosuspend setting:

cat /sys/module/usbcore/parameters/autosuspend

Watch raw disk activity counters:

watch -n1 'cat /proc/diskstats | grep sda'

Install iostat tools:

sudo apt install sysstat

Live disk I/O statistics:

iostat -xm 1

Manually mount a UUID-defined disk from /etc/fstab:

sudo mount /mnt/usb

Mount all entries from /etc/fstab:

sudo mount -a

Repair NTFS filesystem after unsafe disconnect:

sudo ntfsfix /dev/sdb2

Install NTFS driver support:

sudo apt install ntfs-3g

Create mount directory:

sudo mkdir -p /mnt/wd500

Example /etc/fstab entry using UUID:

UUID=9408023C08021E3C /mnt/wd500 ntfs defaults,nofail,noatime,rw,uid=1000,gid=1000,umask=0022 0 0

Example keepalive cronjob to prevent drive sleep:

*/5 * * * * /bin/ls /mnt/wd500 >/dev/null 2>&1



Blog 2: DietPI_NAS.md | (Open) | (Share)

▲ Previous

/Dev

Last modified: April 14 2026 03:18:37

DietPi NAS

complete setup from start to finish, only the necessary parts.


1. Install NTFS support (once)

sudo apt update
sudo apt install ntfs-3g

2. Samba setup

Edit config

sudo nano /etc/samba/smb.conf

Add this

[share]
   path = /home/dietpi
   browseable = yes
   read only = no
   guest ok = no
   valid users = dietpi
   force user = dietpi

Apply

sudo systemctl restart smbd

Add user

sudo smbpasswd -a dietpi

3. Fix permissions (once)

sudo chown -R dietpi:dietpi /home/dietpi
sudo chmod -R 775 /home/dietpi

4. Create USB mount point

sudo mkdir -p /mnt/usb

5. Find USB device

lsblk

Examples:

sdb      30G
└─sdb1   30G     → use /dev/sdb1
sda      232G
├─sda1   16M
└─sda2   232G    → use /dev/sda2

👉 always use the largest partition


6. Test mount (manual)

sudo mount -t ntfs-3g -o uid=1000,gid=1000 /dev/sdXn /mnt/usb

Check:

df -h | grep /mnt/usb

7. Auto-mount on boot

Edit

sudo nano /etc/fstab

Add

/dev/sdXn /mnt/usb ntfs-3g uid=1000,gid=1000,remove_hiberfile,nofail 0 0

Apply

sudo systemctl daemon-reload
sudo mount -a

8. If USB becomes read-only

sudo ntfsfix /dev/sdXn

If still locked:

sudo umount /mnt/usb
sudo mount -t ntfs-3g -o uid=1000,gid=1000,remove_hiberfile /dev/sdXn /mnt/usb

9. Connect from Windows

Open Explorer:

\\192.168.1.48\share

Login:

192.168.1.48\dietpi

10. What happens now

  • Boot → USB auto-mounts at /mnt/usb
  • Samba → always available
  • Windows → access via network path

11. Simple usage flow

  1. Plug USB
  2. Reboot (or mount -a)
  3. Access from Windows

Done

This is the full working setup.

UUID version

Step 1 - Find the USB partition UUID

lsblk -f

Look for the USB partition, for example:

sda
├─sda1
└─sda2  ntfs  8E2A7E432A7E287B

In this example, the USB partition is:

/dev/sda2

and the UUID is:

8E2A7E432A7E287B

You can also confirm it with:

blkid /dev/sda2

Step 2 - Add the UUID mount entry to /etc/fstab

Open /etc/fstab:

sudo nano /etc/fstab

Add this line:

UUID=8E2A7E432A7E287B /mnt/usb ntfs-3g defaults,nofail,noatime,rw,uid=1000,gid=1000,umask=0022 0 0

The fstab line depends mainly on the filesystem type.

For NTFS:

UUID=YOUR-NTFS-UUID /mnt/usb ntfs-3g defaults,nofail,noatime,rw,uid=1000,gid=1000,umask=0022 0 0

For ext4:

UUID=YOUR-EXT4-UUID /mnt/usb2 ext4 defaults,nofail,noatime,rw 0 2

Main difference:

ntfs-3g  = for NTFS drives, usually Windows-compatible USB drives
ext4     = for Linux-native drives

The uid=1000,gid=1000,umask=0022 part is mostly needed for NTFS/FAT/exFAT because those filesystems do not store Linux ownership/permissions the same way ext4 does.

For ext4, permissions are stored on the disk itself, so after mounting you may need to set ownership once:

sudo chown -R dietpi:dietpi /mnt/usb2

or, if your user is not dietpi:

whoami
id

Then use the correct user/group.

Make sure the mount folder exists:

sudo mkdir -p /mnt/usb

Test without rebooting:

sudo mount -a
df -h

Who I am

"Just me, myself, and I, exploring the universe of unknownment, embracing the mystery of what lies beyond, one star at a time."

Share this page on Facebook | X.com | Reddit

Page Content

  • Image Useful USB disk monitoring
    Published: 2026-05-18
    Read
  • Image DietPI NAS
    Published: 2026-05-03
    Read

Tags

WebDev New York London AI NORWAY DIY Ideas Life Family News Clothing Invest Sports Health