Does mv on a FAT filesystem actually rename or does it copy and delete?

classic Classic list List threaded Threaded
19 messages Options
Reply | Threaded
Open this post in threaded view
|

Does mv on a FAT filesystem actually rename or does it copy and delete?

Chris Green
I want to rename some picture files on a mounted digital camera
filesystem.  It is a VFAT filesystem.

If I rename one of the files using 'mv <xxxx.yyy>' will the file
*actually* be renamed by changing the directory entry only or will
mv copy the file to one with the new name and then delete the old one?

--
Chris Green

--
ubuntu-users mailing list
[hidden email]
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
Reply | Threaded
Open this post in threaded view
|

Re: Does mv on a FAT filesystem actually rename or does it copy and delete?

Ralf Mardorf-5
On Sat, 3 Feb 2018 09:50:31 +0000, Chris Green wrote:
>I want to rename some picture files on a mounted digital camera
>filesystem.  It is a VFAT filesystem.
>
>If I rename one of the files using 'mv <xxxx.yyy>' will the file
>*actually* be renamed by changing the directory entry only or will
>mv copy the file to one with the new name and then delete the old one?

"mv" is atomic, you could verify, if I'm mistaken by using strace. "mv"
sometimes is used to workaround the non-atomic operation "ln".

However, I suspect you aren't asking if "mv" works atomic.
"mv <xxxx.yyy>" isn't a complete command. Take a look at the manpage:

http://manpages.ubuntu.com/manpages/xenial/man1/mv.1.html

"SYNOPSIS

       mv [OPTION]... [-T] SOURCE DEST
       mv [OPTION]... SOURCE... DIRECTORY
       mv [OPTION]... -t DIRECTORY SOURCE..."

So using your syntax it means

mv </path/from/xxxx.yyy> </path/to/pppp.qqq>

[rocketmouse@archlinux ~]$ cd /tmp/
[rocketmouse@archlinux tmp]$ mkdir dir_1 dir_2
[rocketmouse@archlinux tmp]$ ls -hAl dir_1 dir_2
dir_1:
total 0

dir_2:
total 0
[rocketmouse@archlinux tmp]$ touch dir_1/test
[rocketmouse@archlinux tmp]$ ls -hAl dir_1 dir_2
dir_1:
total 0
-rw-r--r-- 1 rocketmouse rocketmouse 0 Feb  3 11:46 test

dir_2:
total 0
[rocketmouse@archlinux tmp]$ mv -i dir_1/test dir_2/
[rocketmouse@archlinux tmp]$ ls -hAl dir_1 dir_2
dir_1:
total 0

dir_2:
total 0
-rw-r--r-- 1 rocketmouse rocketmouse 0 Feb  3 11:46 test
[rocketmouse@archlinux tmp]$ mv -i dir_2 dir_3
[rocketmouse@archlinux tmp]$ ls -hAl dir_1 dir_2 dir_3
ls: cannot access 'dir_2': No such file or directory
dir_1:
total 0

dir_3:
total 0
-rw-r--r-- 1 rocketmouse rocketmouse 0 Feb  3 11:46 test
[rocketmouse@archlinux tmp]$

To some extent "-i" ensures that you don't overwrite something by
accident.



--
ubuntu-users mailing list
[hidden email]
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
Reply | Threaded
Open this post in threaded view
|

Re: Does mv on a FAT filesystem actually rename or does it copy and delete?

Ralf Mardorf-5
On Sat, 3 Feb 2018 11:51:18 +0100, Ralf Mardorf wrote:

>On Sat, 3 Feb 2018 09:50:31 +0000, Chris Green wrote:
>>I want to rename some picture files on a mounted digital camera
>>filesystem.  It is a VFAT filesystem.
>>
>>If I rename one of the files using 'mv <xxxx.yyy>' will the file
>>*actually* be renamed by changing the directory entry only or will
>>mv copy the file to one with the new name and then delete the old
>>one?  
>
>"mv" is atomic, you could verify, if I'm mistaken by using strace. "mv"
>sometimes is used to workaround the non-atomic operation "ln".
>
>However, I suspect you aren't asking if "mv" works atomic.
>"mv <xxxx.yyy>" isn't a complete command. Take a look at the manpage:
>
>http://manpages.ubuntu.com/manpages/xenial/man1/mv.1.html
>
>"SYNOPSIS
>
>       mv [OPTION]... [-T] SOURCE DEST
>       mv [OPTION]... SOURCE... DIRECTORY
>       mv [OPTION]... -t DIRECTORY SOURCE..."
>
>So using your syntax it means
>
>mv </path/from/xxxx.yyy> </path/to/pppp.qqq>
>
>[rocketmouse@archlinux ~]$ cd /tmp/
>[rocketmouse@archlinux tmp]$ mkdir dir_1 dir_2
>[rocketmouse@archlinux tmp]$ ls -hAl dir_1 dir_2
>dir_1:
>total 0
>
>dir_2:
>total 0
>[rocketmouse@archlinux tmp]$ touch dir_1/test
>[rocketmouse@archlinux tmp]$ ls -hAl dir_1 dir_2
>dir_1:
>total 0
>-rw-r--r-- 1 rocketmouse rocketmouse 0 Feb  3 11:46 test
>
>dir_2:
>total 0
>[rocketmouse@archlinux tmp]$ mv -i dir_1/test dir_2/
>[rocketmouse@archlinux tmp]$ ls -hAl dir_1 dir_2
>dir_1:
>total 0
>
>dir_2:
>total 0
>-rw-r--r-- 1 rocketmouse rocketmouse 0 Feb  3 11:46 test
>[rocketmouse@archlinux tmp]$ mv -i dir_2 dir_3
>[rocketmouse@archlinux tmp]$ ls -hAl dir_1 dir_2 dir_3
>ls: cannot access 'dir_2': No such file or directory
>dir_1:
>total 0
>
>dir_3:
>total 0
>-rw-r--r-- 1 rocketmouse rocketmouse 0 Feb  3 11:46 test
>[rocketmouse@archlinux tmp]$
>
>To some extent "-i" ensures that you don't overwrite something by
>accident.

Within the same directory, which actually seems to be your question:

[rocketmouse@archlinux ~]$ cd /tmp/dir_3/
[rocketmouse@archlinux dir_3]$ ls -hAl
total 0
-rw-r--r-- 1 rocketmouse rocketmouse 0 Feb  3 11:46 test
[rocketmouse@archlinux dir_3]$ mv -i /tmp/dir_3/test /tmp/dir_3/test_new
[rocketmouse@archlinux dir_3]$ ls -hAl
total 0
-rw-r--r-- 1 rocketmouse rocketmouse 0 Feb  3 11:46 test_new
[rocketmouse@archlinux dir_3]$

IOW it does "rename", since the operation is atomic.


--
ubuntu-users mailing list
[hidden email]
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
Reply | Threaded
Open this post in threaded view
|

Re: Does mv on a FAT filesystem actually rename or does it copy and delete?

Ralf Mardorf-5
On Sat, 3 Feb 2018 11:55:47 +0100, Ralf Mardorf wrote:

>On Sat, 3 Feb 2018 11:51:18 +0100, Ralf Mardorf wrote:
>>On Sat, 3 Feb 2018 09:50:31 +0000, Chris Green wrote:  
>>>I want to rename some picture files on a mounted digital camera
>>>filesystem.  It is a VFAT filesystem.
>>>
>>>If I rename one of the files using 'mv <xxxx.yyy>' will the file
>>>*actually* be renamed by changing the directory entry only or will
>>>mv copy the file to one with the new name and then delete the old
>>>one?    
>>
>>"mv" is atomic, you could verify, if I'm mistaken by using strace.
>>"mv" sometimes is used to workaround the non-atomic operation "ln".
>>
>>However, I suspect you aren't asking if "mv" works atomic.
>>"mv <xxxx.yyy>" isn't a complete command. Take a look at the manpage:
>>
>>http://manpages.ubuntu.com/manpages/xenial/man1/mv.1.html
>>
>>"SYNOPSIS
>>
>>       mv [OPTION]... [-T] SOURCE DEST
>>       mv [OPTION]... SOURCE... DIRECTORY
>>       mv [OPTION]... -t DIRECTORY SOURCE..."
>>
>>So using your syntax it means
>>
>>mv </path/from/xxxx.yyy> </path/to/pppp.qqq>
>>
>>[rocketmouse@archlinux ~]$ cd /tmp/
>>[rocketmouse@archlinux tmp]$ mkdir dir_1 dir_2
>>[rocketmouse@archlinux tmp]$ ls -hAl dir_1 dir_2
>>dir_1:
>>total 0
>>
>>dir_2:
>>total 0
>>[rocketmouse@archlinux tmp]$ touch dir_1/test
>>[rocketmouse@archlinux tmp]$ ls -hAl dir_1 dir_2
>>dir_1:
>>total 0
>>-rw-r--r-- 1 rocketmouse rocketmouse 0 Feb  3 11:46 test
>>
>>dir_2:
>>total 0
>>[rocketmouse@archlinux tmp]$ mv -i dir_1/test dir_2/
>>[rocketmouse@archlinux tmp]$ ls -hAl dir_1 dir_2
>>dir_1:
>>total 0
>>
>>dir_2:
>>total 0
>>-rw-r--r-- 1 rocketmouse rocketmouse 0 Feb  3 11:46 test
>>[rocketmouse@archlinux tmp]$ mv -i dir_2 dir_3
>>[rocketmouse@archlinux tmp]$ ls -hAl dir_1 dir_2 dir_3
>>ls: cannot access 'dir_2': No such file or directory
>>dir_1:
>>total 0
>>
>>dir_3:
>>total 0
>>-rw-r--r-- 1 rocketmouse rocketmouse 0 Feb  3 11:46 test
>>[rocketmouse@archlinux tmp]$
>>
>>To some extent "-i" ensures that you don't overwrite something by
>>accident.  
>
>Within the same directory, which actually seems to be your question:
>
>[rocketmouse@archlinux ~]$ cd /tmp/dir_3/
>[rocketmouse@archlinux dir_3]$ ls -hAl
>total 0
>-rw-r--r-- 1 rocketmouse rocketmouse 0 Feb  3 11:46 test
>[rocketmouse@archlinux dir_3]$ mv
>-i /tmp/dir_3/test /tmp/dir_3/test_new [rocketmouse@archlinux dir_3]$
>ls -hAl total 0
>-rw-r--r-- 1 rocketmouse rocketmouse 0 Feb  3 11:46 test_new
>[rocketmouse@archlinux dir_3]$
>
>IOW it does "rename", since the operation is atomic.

PPS: IOW I was mistaken, you seemingly ask, if the operation is atomic.
Yes, "mv" within the same partition/directory does "rename", it does not
copy and remove (delete).

However, I might be mistaken, so use google, or much better run strace.

[rocketmouse@archlinux ~]$ cd /tmp/dir_3/
[rocketmouse@archlinux dir_3]$ ls -hAl
total 0
-rw-r--r-- 1 rocketmouse rocketmouse 0 Feb  3 11:46 test_new
[rocketmouse@archlinux dir_3]$ strace mv -i test_new test_new_2
[snip]
rename("test_new", "test_new_2")        = 0
[snip]
+++ exited with 0 +++
[rocketmouse@archlinux dir_3]$ ls -hAl
total 0
-rw-r--r-- 1 rocketmouse rocketmouse 0 Feb  3 11:46 test_new_2
[rocketmouse@archlinux dir_3]$


--
ubuntu-users mailing list
[hidden email]
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
Reply | Threaded
Open this post in threaded view
|

Re: Does mv on a FAT filesystem actually rename or does it copy and delete?

Ralf Mardorf-5
>PPS: IOW I was mistaken, you seemingly ask, if the operation is atomic.
>Yes, "mv" within the same partition/directory does "rename", it does
>not copy and remove (delete).
>
>However, I might be mistaken, so use google, or much better run strace.
>
>[rocketmouse@archlinux ~]$ cd /tmp/dir_3/
>[rocketmouse@archlinux dir_3]$ ls -hAl
>total 0
>-rw-r--r-- 1 rocketmouse rocketmouse 0 Feb  3 11:46 test_new
>[rocketmouse@archlinux dir_3]$ strace mv -i test_new test_new_2
>[snip]
>rename("test_new", "test_new_2")        = 0
>[snip]
>+++ exited with 0 +++
>[rocketmouse@archlinux dir_3]$ ls -hAl
>total 0
>-rw-r--r-- 1 rocketmouse rocketmouse 0 Feb  3 11:46 test_new_2

My apologize for the confusion, sometimes it's not easy to understand
a novice's request at the first time ;). As already pointed out above,
it does change the directory entry, it does not copy and rename
(delete). It plausibly shouldn't work that way, when coping a dir or
file to another partition/mount point. Anyway, "strace" still is your
friend to verify or falsify my claim.


--
ubuntu-users mailing list
[hidden email]
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
Reply | Threaded
Open this post in threaded view
|

Re: Does mv on a FAT filesystem actually rename or does it copy and delete?

Ralf Mardorf-5
On Sat, 3 Feb 2018 12:23:57 +0100, Ralf Mardorf wrote:

>>PPS: IOW I was mistaken, you seemingly ask, if the operation is
>>atomic. Yes, "mv" within the same partition/directory does "rename",
>>it does not copy and remove (delete).
>>
>>However, I might be mistaken, so use google, or much better run
>>strace.
>>
>>[rocketmouse@archlinux ~]$ cd /tmp/dir_3/
>>[rocketmouse@archlinux dir_3]$ ls -hAl
>>total 0
>>-rw-r--r-- 1 rocketmouse rocketmouse 0 Feb  3 11:46 test_new
>>[rocketmouse@archlinux dir_3]$ strace mv -i test_new test_new_2
>>[snip]
>>rename("test_new", "test_new_2")        = 0
>>[snip]
>>+++ exited with 0 +++
>>[rocketmouse@archlinux dir_3]$ ls -hAl
>>total 0
>>-rw-r--r-- 1 rocketmouse rocketmouse 0 Feb  3 11:46 test_new_2  
>
>My apologize for the confusion, sometimes it's not easy to understand
>a novice's request at the first time ;). As already pointed out above,
>it does change the directory entry, it does not copy and rename
                                                          ^^^^^^
                                                          a typo, this
                                                          should read
                                                          "remove" :D
>(delete). It plausibly shouldn't work that way, when coping a dir or
>file to another partition/mount point. Anyway, "strace" still is your
>friend to verify or falsify my claim.



--
https://www.schneier.com/blog/archives/2018/01/spectre_and_mel_1.html


--
ubuntu-users mailing list
[hidden email]
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
Reply | Threaded
Open this post in threaded view
|

Re: Does mv on a FAT filesystem actually rename or does it copy and delete?

Ralf Mardorf-5
On Sat, 3 Feb 2018 12:25:15 +0100, Ralf Mardorf wrote:
>>My apologize for the confusion, sometimes it's not easy to understand
>>a novice's request at the first time ;). As already pointed out above,
>>it does change the directory entry, it does not copy and rename  
>                                                          ^^^^^^
>                                                          a typo, this
>                                                          should read
>                                                          "remove" :D
>>(delete). It plausibly shouldn't work that way, when coping a dir or
                                                       ^^^^^^
                                                       moving ;)
>>file to another partition/mount point. Anyway, "strace" still is your
>>friend to verify or falsify my claim.


--
https://www.schneier.com/blog/archives/2018/01/spectre_and_mel_1.html


--
ubuntu-users mailing list
[hidden email]
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
Reply | Threaded
Open this post in threaded view
|

Re: Does mv on a FAT filesystem actually rename or does it copy and delete?

Oliver Grawert
In reply to this post by Chris Green
hi,
Am Samstag, den 03.02.2018, 09:50 +0000 schrieb Chris Green:
> I want to rename some picture files on a mounted digital camera
> filesystem.  It is a VFAT filesystem.
>
> If I rename one of the files using 'mv <xxxx.yyy>' will the file
> *actually* be renamed by changing the directory entry only or will
> mv copy the file to one with the new name and then delete the old
> one? 
>

at [1] is a nice FAQ about mv an how it works ...

ciao
        oli

[1] http://www.theunixschool.com/2012/08/move-files-and-directories-ino
des-part-3.html
--
ubuntu-users mailing list
[hidden email]
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users

signature.asc (188 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Does mv on a FAT filesystem actually rename or does it copy and delete?

Chris Green
In reply to this post by Chris Green
On Sat, Feb 03, 2018 at 09:50:31AM +0000, Chris Green wrote:
> I want to rename some picture files on a mounted digital camera
> filesystem.  It is a VFAT filesystem.
>
> If I rename one of the files using 'mv <xxxx.yyy>' will the file

Typo of course, I meant 'mv file1 file2'.

> *actually* be renamed by changing the directory entry only or will
> mv copy the file to one with the new name and then delete the old one?
>
Thanks for the answers so far but to re-emphasise why I asked the
question:-

    I know that mv of a file in a directory on a Linux type filesystem
    will just write the new name of a file in the directory without
    moving the data/contents of the file.

    However in different circumstances (e.g. across filesystems) it
    *can't* do this and has to copy/delete.  I was just asking if
    anyone knows if 'mv file1 file2' on a VFAT (i.e. not native Linux)
    filesystem does the 'easy' thing (copy/delete) or not.

--
Chris Green

--
ubuntu-users mailing list
[hidden email]
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
Reply | Threaded
Open this post in threaded view
|

Re: Does mv on a FAT filesystem actually rename or does it copy and delete?

Ken D'Ambrosio
Definitive answer: I created a loopback FAT32 filesystem, mounted it,
and did a "strace mv file file2":
[...]
rename("file", "file2")               = 0

-Ken


On 2018-02-03 07:29, Chris Green wrote:

> On Sat, Feb 03, 2018 at 09:50:31AM +0000, Chris Green wrote:
>> I want to rename some picture files on a mounted digital camera
>> filesystem.  It is a VFAT filesystem.
>>
>> If I rename one of the files using 'mv <xxxx.yyy>' will the file
>
> Typo of course, I meant 'mv file1 file2'.
>
>> *actually* be renamed by changing the directory entry only or will
>> mv copy the file to one with the new name and then delete the old one?
>>
> Thanks for the answers so far but to re-emphasise why I asked the
> question:-
>
>     I know that mv of a file in a directory on a Linux type filesystem
>     will just write the new name of a file in the directory without
>     moving the data/contents of the file.
>
>     However in different circumstances (e.g. across filesystems) it
>     *can't* do this and has to copy/delete.  I was just asking if
>     anyone knows if 'mv file1 file2' on a VFAT (i.e. not native Linux)
>     filesystem does the 'easy' thing (copy/delete) or not.
>
> --
> Chris Green

--
ubuntu-users mailing list
[hidden email]
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
Reply | Threaded
Open this post in threaded view
|

Re: Does mv on a FAT filesystem actually rename or does it copy and delete?

Oliver Grawert
In reply to this post by Chris Green
hi,
Am Samstag, den 03.02.2018, 12:29 +0000 schrieb Chris Green:

> Thanks for the answers so far but to re-emphasise why I asked the
> question:-
>
>     I know that mv of a file in a directory on a Linux type
> filesystem
>     will just write the new name of a file in the directory without
>     moving the data/contents of the file.

one would hope that the kernel abstracts the filesystem layer enough
that a command like mv works the same everywhere, regardless of the
underlying filesystem ;)

i.e. the kernel should manage that on a lower layer without you having
to care (an mv on the same filesystem should always just modify the
(directory) metadata for the file, not the payload data itself)

ciao
        oli
--
ubuntu-users mailing list
[hidden email]
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users

signature.asc (188 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Does mv on a FAT filesystem actually rename or does it copy and delete?

Little Girl
In reply to this post by Chris Green
Hey there,

Chris Green wrote:

> I want to rename some picture files on a mounted digital camera
> filesystem.  It is a VFAT filesystem.
>
> If I rename one of the files using 'mv <xxxx.yyy>' will the file
> *actually* be renamed by changing the directory entry only or will
> mv copy the file to one with the new name and then delete the old
> one?

This page might be useful:

https://unix.stackexchange.com/questions/149795/move-preserves-ownership-of-source-files-not-allowing-writes

--
Little Girl

There is no spoon.

--
ubuntu-users mailing list
[hidden email]
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
Reply | Threaded
Open this post in threaded view
|

Re: Does mv on a FAT filesystem actually rename or does it copy and delete?

Chris Green
On Sat, Feb 03, 2018 at 09:14:39AM -0500, Little Girl wrote:

> Hey there,
>
> Chris Green wrote:
>
> > I want to rename some picture files on a mounted digital camera
> > filesystem.  It is a VFAT filesystem.
> >
> > If I rename one of the files using 'mv <xxxx.yyy>' will the file
> > *actually* be renamed by changing the directory entry only or will
> > mv copy the file to one with the new name and then delete the old
> > one?
>
> This page might be useful:
>
> https://unix.stackexchange.com/questions/149795/move-preserves-ownership-of-source-files-not-allowing-writes 
>

It doesn't really address my issue which is whether mv will work the
same on FAT/VFAT as it does on 'native' Linux filesystems.

--
Chris Green

--
ubuntu-users mailing list
[hidden email]
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
Reply | Threaded
Open this post in threaded view
|

Re: Does mv on a FAT filesystem actually rename or does it copy and delete?

Ken D'Ambrosio
On 2018-02-03 10:09, Chris Green wrote:

> On Sat, Feb 03, 2018 at 09:14:39AM -0500, Little Girl wrote:
>> Hey there,
>>
>> Chris Green wrote:
>>
>> > I want to rename some picture files on a mounted digital camera
>> > filesystem.  It is a VFAT filesystem.
>> >
>> > If I rename one of the files using 'mv <xxxx.yyy>' will the file
>> > *actually* be renamed by changing the directory entry only or will
>> > mv copy the file to one with the new name and then delete the old
>> > one?
>>
>> This page might be useful:
>>
>> https://unix.stackexchange.com/questions/149795/move-preserves-ownership-of-source-files-not-allowing-writes
>>
>
> It doesn't really address my issue which is whether mv will work the
> same on FAT/VFAT as it does on 'native' Linux filesystems.

I already answered that a few hours ago:

Definitive answer: I created a loopback FAT32 filesystem, mounted it,
and did a "strace mv file file2":
[...]
rename("file", "file2")               = 0

Likewise, from a directory "mv":

rename("foo", "foodir")                 = 0

Same thing.  It's rename().

-Ken

--
ubuntu-users mailing list
[hidden email]
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
Reply | Threaded
Open this post in threaded view
|

Re: Does mv on a FAT filesystem actually rename or does it copy and delete?

Ralf Mardorf-5
In reply to this post by Chris Green
On Sat, 3 Feb 2018 12:29:10 +0000, Chris Green wrote:

>On Sat, Feb 03, 2018 at 09:50:31AM +0000, Chris Green wrote:
>> I want to rename some picture files on a mounted digital camera
>> filesystem.  It is a VFAT filesystem.
>>
>> If I rename one of the files using 'mv <xxxx.yyy>' will the file  
>
>Typo of course, I meant 'mv file1 file2'.
>
>> *actually* be renamed by changing the directory entry only or will
>> mv copy the file to one with the new name and then delete the old
>> one?
>Thanks for the answers so far but to re-emphasise why I asked the
>question:-
>
>    I know that mv of a file in a directory on a Linux type filesystem
>    will just write the new name of a file in the directory without
>    moving the data/contents of the file.
>
>    However in different circumstances (e.g. across filesystems) it
>    *can't* do this and has to copy/delete.  I was just asking if
>    anyone knows if 'mv file1 file2' on a VFAT (i.e. not native Linux)
>    filesystem does the 'easy' thing (copy/delete) or not.

As already pointed out, you still could run "strace" ;).


--
ubuntu-users mailing list
[hidden email]
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
Reply | Threaded
Open this post in threaded view
|

Re: Does mv on a FAT filesystem actually rename or does it copy and delete?

Paul Smith-2
On Sat, 2018-02-03 at 16:46 +0100, Ralf Mardorf wrote:

> > Thanks for the answers so far but to re-emphasise why I asked the
> > question:-
> >
> >     I know that mv of a file in a directory on a Linux type filesystem
> >     will just write the new name of a file in the directory without
> >     moving the data/contents of the file.
> >
> >     However in different circumstances (e.g. across filesystems) it
> >     *can't* do this and has to copy/delete.  I was just asking if
> >     anyone knows if 'mv file1 file2' on a VFAT (i.e. not native Linux)
> >     filesystem does the 'easy' thing (copy/delete) or not.
>
> As already pointed out, you still could run "strace" ;).

That doesn't answer the question.

Obviously the mv(1) command is always going to run the same system
call, regardless of the underlying filesystem.  It's not going to try
to look up the type of the filesystem and behave differently [1]: it's
going to rely on the published kernel interface to move a file, e.g.
invoke the rename(2) system call.

However, that doesn't mean that the actual behavior of that system call
is the same on a VFAT filesystem: a typical filesystem will allow the
directory entry for the file to be changed without actually copying
bytes around on the hardware.

The question is not what system call is invoked, but rather does the
implementation of the filesystem in the kernel allow for the rename
operation to simply change the directory to implement the move, or does
it require the actual contents of the file to be copied to a different
location on the underlying media?


[1] mv _will_ check whether the source and destination are on the same
partition or not, since rename(2) is not supported across different
partitions.

--
ubuntu-users mailing list
[hidden email]
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
Reply | Threaded
Open this post in threaded view
|

Re: Does mv on a FAT filesystem actually rename or does it copy and delete?

Ralf Mardorf-5
On Sat, 03 Feb 2018 11:30:28 -0500, Paul Smith wrote:
>That doesn't answer the question.

The question already was mostly answered, by underpinning it with an
strace output, just not on a VFAT, because not that many subscribers
might use this file system.

>it's going to rely on the published kernel interface to move a file,
>e.g. invoke the rename(2) system call.
>
>However, that doesn't mean that the actual behavior of that system call
>is the same on a VFAT filesystem

Indeed, strace might fool us. Fair enough, that's one reason why I
mentioned Google.

I wonder why it could be much important that the rename operation on
VFAT is or isn't atomic, when renaming files or dirs on the same
partition. First coping and then removing does have at least two
pitfall, since an accident could lead to duplicated files and
temporarily requires double the free diskspace, but this actually isn't
catastrophic.


--
ubuntu-users mailing list
[hidden email]
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
Reply | Threaded
Open this post in threaded view
|

Re: Does mv on a FAT filesystem actually rename or does it copy and delete?

Ralf Mardorf-5
On Sat, 3 Feb 2018 18:14:11 +0100, Ralf Mardorf wrote:

>On Sat, 03 Feb 2018 11:30:28 -0500, Paul Smith wrote:
>>That doesn't answer the question.  
>
>The question already was mostly answered, by underpinning it with an
>strace output, just not on a VFAT, because not that many subscribers
>might use this file system.
>
>>it's going to rely on the published kernel interface to move a file,
>>e.g. invoke the rename(2) system call.
>>
>>However, that doesn't mean that the actual behavior of that system
>>call is the same on a VFAT filesystem  
>
>Indeed, strace might fool us. Fair enough, that's one reason why I
>mentioned Google.
>
>I wonder why it could be much important that the rename operation on
>VFAT is or isn't atomic, when renaming files or dirs on the same
>partition. First coping and then removing does have at least two
>pitfall, since an accident could lead to duplicated files and
>temporarily requires double the free diskspace, but this actually isn't
>catastrophic.

PS: Maybe a power outage in the middle of an atomic rename could cause
data loss. While "atomic" quasi is for done or not done, there
might be situations where even an atomic operation could be half-done.
Taking a look at a seemingly perfect circle under a scanning tunneling
microscope, it isn't a circle anymor at all.


--
ubuntu-users mailing list
[hidden email]
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
Reply | Threaded
Open this post in threaded view
|

Re: Does mv on a FAT filesystem actually rename or does it copy and delete?

Ralf Mardorf-5
In reply to this post by Ralf Mardorf-5
On Sat, 3 Feb 2018 18:14:11 +0100, Ralf Mardorf wrote:
>temporarily requires double the free diskspace

This pharse is also broken (wrong) translated from/to my native
language, but I suspect you understand what I want to point out :D.


--
ubuntu-users mailing list
[hidden email]
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users