I was just moving some stuff around on my Windows XP machine. So that I wouldn't run out of room moving between partitions, I moved a bunch of stuff to a Samba share on my Linux machine (via My Network Places in WinXP).

I had thought I had moved the files back and deleted them off the Linux box via My Network Places. But -- oops! -- I hadn't finished moving them. Therefore, I lost half my files.

Now my question ... does Linux by any chance put these files in a trash folder or something, or are they gone forever?

Dani AI

Generated

Short answer: no — deleting a file from a Samba share via Windows does not send it to your local Windows Recycle Bin; by default Samba simply performs the server-side delete (the file is unlinked on the Linux filesystem). To get a “trash” for network deletes you must enable a server-side recycle/trash feature (Samba provides a VFS module for this) or rely on server snapshots/backups. (learn.microsoft.com)

To enable a Samba-side recycle bin use the vfs_recycle module in the share stanza. Minimal example (add to the share in smb.conf):

[shared]
   path = /srv/samba/shared
   read only = no
   vfs objects = recycle
   recycle:repository = /srv/samba/recycle/%U
   recycle:keeptree = yes
   recycle:versions = yes
   recycle:touch = yes

Put the recycle root outside the share (or give the base folder permissive ownership/mode) so Samba can create per-user directories reliably. See the vfs_recycle option list for behaviour and tuning. (samba.org)

If vfs_recycle was not enabled when the files were deleted: stop writing to that filesystem immediately (to avoid overwriting blocks), image the device, then attempt recovery from the image. For ext3/4 try tools such as extundelete or ext3grep; for a broader “carve” approach use TestDisk/PhotoRec. If the server used LVM/btrfs/ZFS snapshots you may be able to mount a snapshot and copy files back instead. Recovery is not guaranteed and is much harder after a reinstall. (manpages.ubuntu.com)

Best practice: enable vfs_recycle (or vendor NAS recycle), keep automated snapshots or backups, and add a scheduled prune for the recycle repo (example cron to remove files older than 30 days):

0 3 * * * find /srv/samba/recycle -type f -mtime +30 -delete

As and noted, the default behaviour is permanent server-side deletion — configure a server-side trash or snapshots to avoid the same loss. (samba.org)

Recommended Answers

All 8 Replies

Hey kaynine, thanx for the reply ... but (unfortunately) I couldnt find the answer anywhere :( . I ended up reformatting the Linux box last night anyway (so it doesn't even matter anymore).

First thing's first ... those files weren't ultra important b/c they were ... how should I say ... warez ;)

The box was running RedHat 7.3 and I figured I might as well upgrade to Redhat 8 ... so I did an upgrade. But a lot of the underlying structure changed, and it screwed a lot of proggies I already had installed up. So I figured I'd do a nice clean install with RedHat 8.

(I know, I know ... Linux is supposed to last, but, eh ... oh well!)

Sorry it didn't help you tho.

No prob ... I was almost positive they were gone for good anyways. It's a similar scenerio to lets say you use Network Neighborhood to delete files off a remote pc. They are permanently deleted - not in either recycle bin. It was the same thing only the remote pc was a Linux box.

Oh well.

In any case ... I'm just havin' a good ol' time playing around with RedHat 8. Quick question though ... does anyone know why KPackage doesn't come with KDE for RedHat 8? It's included with all previous versions?

because redhat8 sucks! hehe

This topic took a real weird turn to a debate about RedHat 8, so I split it off into a separate topic entitled "RedHat 8"

[thread]378[/thread]

Linux doesn't use a "Recycle Bin" when deleting files, including files that are stored in a shared directory using Samba. If you delete files in a shared directory on a *nix machine, they're gone, just as if you typed rm -rf in a shell.

While the later version of 2.x and the newest version (3.01) add an option in smb.conf to include a "Recycle Bin" in the directory, I haven't yet got it to work on either Linux or FreeBSD. (Hey, it's not perfect yet, but they're working on it:)

My suggestion would be to COPY them back to your XP box, then once you're sure you have everything, wipe 'em from the *nix box. This is also good practice, in the event you have a sudden power loss and both boxes shut down (or something along those lines, like the power supply blowing chunks or the motherboard cracking in half) you'll have two copies of the files. Then you can safely remove the unwanted copies.

Member Avatar for Member #2466

No samba does not send anything to a recycle bin. For the main reason that the daemon is running on the linux machine which of course does not have a recycle bin.


What I do is store an image of my hard disk as a backup on a network drive. That way if I ever need to do a reinstall...I can get my files from my backup.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.