Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
It is not a normal latency for that operation. Deleting files should be fairly instant. Try removing one file at a time and use strace. With strace you'll be able to see which system call the command is hanging up on. Iostat can show you some statistics as well. If top looks normal then there is no good reason for an rm operation to take longer than a copy operation unless it is enumerating of millions of tiny files.
So there's a good possibility that all files were copied successfully?
Unfortunately my crystal ball is in the shop :-). If you're concerned about the integrity of a file copy operation then you can do a few things.
If it's only a single file or a few files then run a checksum on the source/destination (md5sum command or any of the *sum commands). Find command one liner works well here for many files.
If you're copying copious amounts of files then you're better off using a utility which checks the integrity as part of the copying/syncing process. Rsync comes to mind for that.
Code:
rsync -av /src /dst
See rsync man page for option explanation. With rsync you can cancel the copy operation half way through and start it again later; it will pick up where it left off.
If you're possibly using putty over a flakey network consider using a terminal multiplexer such as screen or tmux. If you get disconnected from your session the copy operation will continue and when you connect to the server again you can resume the disconnected session to view the result of said operation.
But to my surprise it takes more than I expected. cp does it in few minutes and rm does it on hours.
Anyway, if user complains time to pull the backup. Thanks for the help.
To me it sounds like there is a more serious underlying problem worth investigating. I recommend consulting with peers on the issue or continue hashing it out on LQ until you discover the source of the slow rm operation. What system call did the operation hang up on with strace? What type of file system do the files reside? What type of storage is the filesystem located? Is it a network file share mount? There's a lot more which could be investigated.
To me it sounds like there is a more serious underlying problem worth investigating. I recommend consulting with peers on the issue or continue hashing it out on LQ until you discover the source of the slow rm operation. What system call did the operation hang up on with strace? What type of file system do the files reside? What type of storage is the filesystem located? Is it a network file share mount? There's a lot more which could be investigated.
haven't run any diagnostic tool, the folder in which the file resides was running under Kerio user email folder.
I'm not really sure whether Kerio services was interfering with the rm command.
I did not try stopping the Kerio service and deleting the files. I remove the files while Kerio service was running.
haven't run any diagnostic tool, the folder in which the file resides was running under Kerio user email folder.
I'm not really sure whether Kerio services was interfering with the rm command.
I did not try stopping the Kerio service and deleting the files. I remove the files while Kerio service was running.
lsof is a good command to list any open file handles. Though in Linux you can delete a file and said file still takes up space as long as there's an open file handle. For that reason deleted files which have open file handles from programs can be recovered from /proc.
Most linux native filesystems are quite fast at delete (using a tree or sparse list).
But non-native filesystems aren't so efficient - These usually (not always) store files in a directory as a simple linear file. Deleting a bunch of files in the wrong order (like always deleting the file at the beginning of the directory list) is slow. This is because the directory gets repacked for every delete. This is usually not a problem... unless you have thousands of files in a directory.
Now sometimes it can be due to the deallocation of data blocks - especially on a disk that is 100% full.
How large are the files in question? More details about precisely what you are trying to accomplish might help clarify this: are the files are on the same or separate partitions, in a remote location, etc.
As a general observation, if you are copying a file to another location on the same partition, the file does not actually get rewritten. The pointers to the location of the file are simply changed. That's why the copy process appears to complete so quickly--nothing really gets copied, it just gets a new address.
If you copy a file to another partition or another physical device, that takes some time because the file must be written to the target partition and then removed from the source partition. It's recreating the data that takes time.
How large are the files in question? More details about precisely what you are trying to accomplish might help clarify this: are the files are on the same or separate partitions, in a remote location, etc.
As a general observation, if you are copying a file to another location on the same partition, the file does not actually get rewritten. The pointers to the location of the file are simply changed. That's why the copy process appears to complete so quickly--nothing really gets copied, it just gets a new address.
If you copy a file to another partition or another physical device, that takes some time because the file must be written to the target partition and then removed from the source partition. It's recreating the data that takes time.
Hi Frankbell, this would explain why copying was very fast. Thank you so much. It's good to know how the system works, but of course it would be the best to know how the developer did it.
Files were copied in the same partition but to a different location only.
Hi Frankbell, this would explain why copying was very fast. Thank you so much. It's good to know how the system works, but of course it would be the best to know how the developer did it.
It's been like that since I first started mucking about with computers with DOS 3.2.
File information is stored in a table at the beginning of each partition. In NTFS, it's called a Master File Table. In Linux file systems, it's called inodes. In other file systems, it might be called something else.
When you move a file on a partition, all that happens is that that table gets changed. There's no reason the physically move the bits and bytes when changing a database entry (the table is ultimately a database) has the same result for, as my father would have said, all practical purposes.
As to who came up with the idea and why, I don't know. It's shrouded in the mists of Unix history.
A web search for "how file systems work" will turn up many useful links, if you want to pursue this further.
Unfortunately my crystal ball is in the shop :-). If you're concerned about the integrity of a file copy operation then you can do a few things.
If it's only a single file or a few files then run a checksum on the source/destination (md5sum command or any of the *sum commands). Find command one liner works well here for many files.
If you're copying copious amounts of files then you're better off using a utility which checks the integrity as part of the copying/syncing process. Rsync comes to mind for that.
Code:
rsync -av /src /dst
See rsync man page for option explanation. With rsync you can cancel the copy operation half way through and start it again later; it will pick up where it left off.
If you're possibly using putty over a flakey network consider using a terminal multiplexer such as screen or tmux. If you get disconnected from your session the copy operation will continue and when you connect to the server again you can resume the disconnected session to view the result of said operation.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.