Reclaiming disk space for USB storage - HDD

Bishop27

Member
Jul 3, 2024
41
1
8
Hello all,
I have a situation I could use some assistance with, I have a usb storage box that has 3 hard drive inside that totals 6TB the file system is set to ext4. Well now its 98% full so I've decided to remove files from the disk and reclaim that space. This usb storage box is mounted to a LXC and I've tried using fstrim -a from within the LXC with no success.

/dev/sdg2 5.5T 5.4T 75G 99% /media/MEDIA-STACK

Thanks in advance.
 
I've tried using fstrim -a from within the LXC with no success.
On an unprivileged CT, you won't be able to run fstrim AFAIK. However (& depending on how you've mounted that disk inside the CT) you could possibly try pct fstrim <ctid> from the host node as shown here:
pct fstrim <vmid> [OPTIONS]

Run fstrim on a chosen CT and its mountpoints, except bind or read-only mountpoints.
 
  • Like
Reactions: alexskysilk
I've tried running the above command from the host with no success. This is the disk from which I've removed some data (old files) and want to reclaim the space :
sdg 8:96 0 5.5T 0 disk
├─sdg1 8:97 0 200M 0 part
└─sdg2 8:98 0 5.5T 0 part /media/MEDIA-STACK
 
/media/MEDIA-STACK is a bind mount. pct fstrim does not apply here. I'm curious why you picked exfat.
Please try this on the node to see what the space is used by
Bash:
apt install gdu
gdu /media/MEDIA-STACK
 
AFAIK this should normally work for any mounted FSs on the host:

1. Shutdown all VMs & CTs which use the /media/MEDIA-STACK mount, so all MEDIA-STACK storage devices. This may not be absolutely necessary.
2. Run fstrim -av on the host, which should work for ALL its mounted FSs.
3. Or you could just run fstrim -v /media/MEDIA-STACK for that mount.

You may want to check that all volumes within PVE that use the MEDIA-STACK storage have discard enabled.


However in your OP you state that the USB enclosure has 3 hard disks that total 6TB, so 3 things stand out here:

  • Firstly are these hard disks & not SSD's. They may not support trim.
  • Secondly there must be some HW raid controller in that box for the 3 disks. Does this support trim commands - IDK.
  • Trim over USB in general does not always function - usually being dependent on the underlying bus being used. See here for example.