LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > General
User Name
Password
General This forum is for non-technical general discussion which can include both Linux and non-Linux topics. Have fun!

Notices


Reply
  Search this Thread
Old 06-26-2012, 08:13 PM   #1
the dsc
Member
 
Registered: May 2009
Distribution: Debian
Posts: 175
Blog Entries: 244

Rep: Reputation: 47
Question Moving a folder, versus moving its contents (within the same partition)


I only know very superficially about "how a file system works". The basic thing I know is that when you move a "file", but still within the same partition, it is not being really "physically" moved anywhere, but just having some filesystem path information changed, so it's "displayed" at a different location, changing almost only to the user's perspective.

But what about moving an entire folder (still within the same partition)? Each individual file has the full path information which got to be changed, or does it "inherit" most of the path from its container folder, so that when you move a folder, only the folder is really changed?

Does it change in different file systems?
 
Old 06-26-2012, 08:36 PM   #2
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,148
Blog Entries: 2

Rep: Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886
Most filesystems are organized in a tree-structure, IIRC, so if you move a folder only the folders information has to be connected to the new place, not its contents.
 
Old 06-26-2012, 09:06 PM   #3
jefro
Moderator
 
Registered: Mar 2008
Posts: 22,008

Rep: Reputation: 3629Reputation: 3629Reputation: 3629Reputation: 3629Reputation: 3629Reputation: 3629Reputation: 3629Reputation: 3629Reputation: 3629Reputation: 3629Reputation: 3629
"Each individual file has the full path information which got to be changed, or does it "inherit" most of the path from its container folder, so that when you move a folder, only the folder is really changed?"

For the most part path is absolute. When you move a folder along with its contents the path changes. There some exceptions but a move is a real move to the OS and user. A subdirectory is stored the same as a file entry in the part or parts of a disk that hold it's location. Think of it as a two part process. A collection of names (file names and subdirectoies) and locations exist on the drive. That is separate from the data area. Wish I could give a real world example but I am stumped.

The term change in different file systems may be too complex. There are filesystems from decades ago to new ones and odd ones. They all act differently. Settle on one and we might know the answer.

Last edited by jefro; 06-26-2012 at 09:08 PM.
 
Old 06-26-2012, 09:06 PM   #4
the dsc
Member
 
Registered: May 2009
Distribution: Debian
Posts: 175

Original Poster
Blog Entries: 244

Rep: Reputation: 47
Heh, I was thanking for the first answer when someone was typing/had just typed another, with a different answer.

I'm not actually doubting the second answer, but in my layman's mind it seems weird that the location address got to be changed in every file. Does not seem very useful, at a superficial/nearly null inspection. But perhaps that's one of those things where the intuitive alternative is simply impossible.

I get that there's the actual data in one part and their indexing in another, what we really see is a virtual, "make believe" path, while a single file may actually even be fragmented on several parts of the disk (at least in some file systems where fragmentation occurs, I guess it's quite common). What I meant that the move is somewhat "fake" is that only this representation that changed, not the actual location of the stored data. I just thought that the indexing system could be such that the "virtual paths" needed not to be absolute, in order to reduce amount of change needed.

Last edited by the dsc; 06-26-2012 at 09:21 PM.
 
Old 06-28-2012, 11:18 AM   #5
just a man
Member
 
Registered: Feb 2009
Posts: 37

Rep: Reputation: 15
What, three replies and nobody's mentioned inodes yet? :-/
 
Old 06-28-2012, 01:12 PM   #6
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
I don't think data physically moves unless the target directory is on a different physical device (that includes a different partition within the same physical disk)
 
Old 06-29-2012, 12:22 AM   #7
the dsc
Member
 
Registered: May 2009
Distribution: Debian
Posts: 175

Original Poster
Blog Entries: 244

Rep: Reputation: 47
That's my understanding as well, and pretty much the only thing I'm "sure".

The doubt is in regard to whether or not the "virtual moving"/"edit on 'virtual path' information" of a folder is inherited by its contents without the contents themselves being "edited" with a new "virtual path" information. (The "contents" meaning not the actual data, but some sort of indexing/virtual representation thing)

Got to read about the "inode" thing on wikipedia.

Last edited by the dsc; 06-29-2012 at 12:25 AM.
 
Old 06-29-2012, 04:46 AM   #8
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,928

Rep: Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612
Only the file(s) and dir(s) meta-data has to be re-written -in just the same way it would be re-written if the data itself was being moved. For each item, the new index entry is written first. If that succeeds then the old one is 'erased'. And so on for each item. In this case all 'entries' are on the same disk so it happens quickly. If data has to be moved, it takes longer. 'mv' figures out on-the-fly whether data has to really be moved or not. Of course, if a new entry fails, then nothing happens to the old data or metadata at all.
 
  


Reply

Tags
filesystems



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Seeing Hard drive contents; moving OS to another HDD RealGomer Linux - Software 3 11-12-2010 10:47 AM
Moving a folder to a different partition Arituay Linux - Newbie 13 09-08-2007 06:59 PM
moving contents of one directory to another linuxuser00 Linux - Newbie 8 01-04-2007 03:19 PM
reading contents of a folder and moving that content vb.net mrobertson Programming 0 02-17-2006 08:14 AM
Moving contents of /var to separate partition TexasDex Linux - Software 2 03-01-2004 08:30 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > General

All times are GMT -5. The time now is 01:06 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration