Re: Question about mv operation.
On Tue, Aug 4, 2015 at 4:11 AM, Magicloud Magiclouds magicloud.magiclo...@gmail.com wrote: Hi, Say I am moving a file between two harddisks. Both filesystems are Ext4. During the operation, I cut off the power. Then boot the host, and fix the filesystems. Now, I see in both locations, there are the file. My question is, is it safe to remove file in dest, and move to it again from src? One way to be completely sure is to compare the hash of the two files with SHA or MD5 and ensure they match. -- To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org Archive: https://lists.debian.org/capjaxen17xickpzmcm5wslnrz4t80-4vbqfbhu+olzvyefs...@mail.gmail.com
Re: Question about mv operation.
Le mardi 04 août 2015 à 16:11 +0800, Magicloud Magiclouds a écrit : Now, I see in both locations, there are the file. My question is, is it safe to remove file in dest, and move to it again from src? I think that if you were just reading files from src, there is no reason for the source to be corrupted. I would consider it's safe. If you don't want to take a risk, couldn't you copy the files in dest in another folder, or in a .tar archive, in order to have a backup if you need one ? -- To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org Archive: https://lists.debian.org/1438676758.10987.3.ca...@gmail.com
Question about mv operation.
Hi, Say I am moving a file between two harddisks. Both filesystems are Ext4. During the operation, I cut off the power. Then boot the host, and fix the filesystems. Now, I see in both locations, there are the file. My question is, is it safe to remove file in dest, and move to it again from src? Thanks. -- 竹密岂妨流水过 山高哪阻野云飞 And for G+, please use magiclouds#gmail.com.
Re: Question about mv operation.
Le mardi 04 août 2015 à 16:11 +0800, Magicloud Magiclouds a écrit : Hi, Hello. Say I am moving a file between two harddisks. Both filesystems are Ext4. During the operation, I cut off the power. Then boot the host, and fix the filesystems. Now, I see in both locations, there are the file. My question is, is it safe to remove file in dest, and move to it again from src? Your source file should be safe if the move operation wasn't finished. Normally, the source file will be removed once the dest file is complete, as removing the source as and when the dest is written is more complicated than dropping the source completely once the dest is written. That said, I didn't read the source code of mv, it's only that I find this process logical. Regards. -- David Guyot Administrateur système, réseau et télécom / Sysadmin Europe Camions Interactive / Stockway Moulin Collot F-88500 Ambacourt 03 29 30 47 85 signature.asc Description: This is a digitally signed message part
Re: Question about mv operation.
Quoting Magicloud Magiclouds magicloud.magiclo...@gmail.com: Hi, Say I am moving a file between two harddisks. Both filesystems are Ext4. During the operation, I cut off the power. Then boot the host, and fix the filesystems. Now, I see in both locations, there are the file. My question is, is it safe to remove file in dest, and move to it again from src? Logically the source shouldn't be deleted until target has been confirmed valid. It seems this never happened here, so the source should be safe. The be even more safe I'd copy the source somewhere, delete the target and redo the move operation. If all is well delete the copy. /Martin S
Re: Question about mv operation.
On Aug 4, 2015 1:26 AM, Some Body somebody.mo...@gmail.com wrote: Le mardi 04 août 2015 à 16:11 +0800, Magicloud Magiclouds a écrit : Now, I see in both locations, there are the file. My question is, is it safe to remove file in dest, and move to it again from src? If you don't want to take a risk, couldn't you copy the files in dest in another folder, or in a .tar archive, in order to have a backup if you need one ? Yeah, unless you're moving on the same fs (because changing inode info is faster than data copy and delete) don't use mv. It's not atomic - rsync at least tries to be atomic with a temp file that gets moved into place but mv isn't that smart (what you want on the same fs).
Re: Question about mv operation.
Le mardi 04 août 2015 à 08:49 -0400, James Montgomery a écrit : On Tue, Aug 4, 2015 at 4:11 AM, Magicloud Magiclouds magicloud.magiclo...@gmail.com wrote: Hi, Say I am moving a file between two harddisks. Both filesystems are Ext4. During the operation, I cut off the power. Then boot the host, and fix the filesystems. Now, I see in both locations, there are the file. My question is, is it safe to remove file in dest, and move to it again from src? One way to be completely sure is to compare the hash of the two files with SHA or MD5 and ensure they match. From what I understood, there is a lot of files. And more importantly, the operation was interrupted, so there is a part of the source that is not in the destination. I think saving the current destination, removing it, and doing again the whole move is the easiest and safest solution. -- To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org Archive: https://lists.debian.org/1438692916.22860.3.ca...@gmail.com
Re: Question about mv operation.
On Tuesday 04 August 2015 09:11:38 Magicloud Magiclouds wrote: Now, I see in both locations, there are the file. My question is, is it safe to remove file in dest, and move to it again from src? Why not rename it (mv it to another name) in dest before mv-ing it again from src? Lisi -- To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org Archive: https://lists.debian.org/201508041630.10271.lisi.re...@gmail.com
Re: Question about mv operation.
On Tue, Aug 4, 2015 at 5:11 PM, Magicloud Magiclouds magicloud.magiclo...@gmail.com wrote: Hi, Say I am moving a file between two harddisks. Now you know. You don't want to do that. (Although I just did that. It was a notebook, I knew the battery was good, and I was only mv-ing, uhm, well, it was more than one file. I was doing it for the thrills. I got lucky. I think. Come to think of it, this may have something to do with why X11 didn't work afterwards.) If you have a small number of files, are really sure you won't lose power or hit some OS error, and know you have no hard links or symbolic links or file:/// urls in anything, mv should do the job. But if something happens, it does leave things in a partial state that you then have to figure out. At least, for a single file, current implementations of mv that I am familiar with, if the source and destination are on different file systems, mv copies and then deletes the source. (Deleting the bytes from the source of a single file as you copy them to the destination requires so much juggling it's generally not considered worth it. It is done in some special utilities that you probably have never used.) cp is better equipped to handle some corner cases, but it's a little hard to understand what you are doing with the options about soft and hard links. The big advantage is that you, yourself, delete the source after you are (pretty) sure the cp completed successfully. tar and rsync are more likely to produced the desired results, in no small part because you have to think out what you are doing. (The magic underlying drag-and-drop on the Mac OS is not insignificant, and even that is by no means foolproof.) Both filesystems are Ext4. During the operation, I cut off the power. I assume that you mean you lost power. If not, you're asking the wrong question. Then boot the host, and fix the filesystems. filesystems are designed to be somewhat robust against accidents. Not so much against deliberate abuse. Power dying in the middle of a raw mv is one thing that is basically impossible to guarantee results across. Now, I see in both locations, there are the file. My question is, is it safe to remove file in dest, and move to it again from src? I would not do that. I would first use cmp to see if the destination and result are the same. If the files are the same, I would only have to check one file. If different, I would have to look at both. Then I would have to make a judgement call as to what to do with the two pieces. That's not something you want to have to do. (hexdump -C can be of use if the files contain only 7-bit ascii and some minimal arbitrary binary data. If there are Chinese or such multibyte characters in the file, you may have to find or write a special dump utility. I have written such a utility for shift-JIS characters. It took me something like eight hours across several days, not including the time it took me to write the ctype library, which was more than 40 hours across several months. If you want the source, I'll post a URL, but can you read C? do you understand the structure of your character encoding? are you willing to walk through understanding the bizarreness of shift-JIS? ...) In short, don't do that. It hurts. At minimum, cp, then rm after you check the copy. Better to learn and use tar, rsync, and/or other similar tools. Thanks. -- 竹密岂妨流水过 山高哪阻野云飞 And for G+, please use magiclouds#gmail.com. -- Joel Rees Be careful when you look at conspiracy. Arm yourself with knowledge of yourself, as well: http://reiisi.blogspot.jp/2011/10/conspiracy-theories.html -- To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org Archive: https://lists.debian.org/CAAr43iN9XoUJL9O+5GqcSmRdNOyF-8R8EQ8-=uCEQmOzjtD=w...@mail.gmail.com
Re: Question about mv operation.
On 20150804_1611+0800, Magicloud Magiclouds wrote: Hi, Say I am moving a file between two harddisks. Both filesystems are Ext4. During the operation, I cut off the power. Then boot the host, and fix the filesystems. Now, I see in both locations, there are the file. My question is, is it safe to remove file in dest, and move to it again from src? No, it is NOT safe. The power interruption might have happened after the data transfer was completed, while the deletion of the source file was in progress. I think there is some way to protect against this possibility already built into the gnu coreutils version of mv, but I don't know for sure. Ask this question at: GNU coreutils online help: http://www.gnu.org/software/coreutils/ (near the bottom of man mv) I have found the people at that site helpful and polite. And, perhaps, OP can make this query and post the response here. HTH Thanks. -- 竹密岂妨流水过 山高哪阻野云飞 And for G+, please use magiclouds#gmail.com. -- Paul E Condon pecon...@mesanetworks.net -- To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org Archive: https://lists.debian.org/20150804182230.ga19...@big.lan.gnu