LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware
User Name
Password
Linux - Hardware This forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?

Notices


Reply
  Search this Thread
Old 11-27-2010, 07:21 PM   #1
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 4,442

Rep: Reputation: 76
Does mv do a lot of work (not a joke)?


Kernel 2.6.21.5, Slackware 12.0

Hi:
Suppose I use the mv command to move certain subtree within the tree rooted at /. May I expect only a very small quantity of sectors will be involved in the process? Or, on the contrary, it is probable that a large amount of data will be transfered from sector to sector? Assume ext2.

If any of you is wondering why such a theoretical question, I am ready to translate it to practical terms: I have just created a directory called /home/john/mic2 which I expect to grow until reaching over a thousand nodes (nodes in the sense given to this word when studying lattices, trees and the like). But maybe later I will change its name to /home/john/mic1 for which, I think, mv is the usual tool in Linux.

mic2 is just a file. As such, there is a set of sectors associated with it. When I rename, these sectors will be left vacant and a new set of sectors will be written. Or maybe the same set shall be rewritten. And is that all? Remember mic2 is by now about a thousand nodes "large". Any hint will be welcome.

P.S.: If this does not belong to the forum, please tell me so or press the REPORT button and ask for the thread to be moved.

Last edited by stf92; 11-27-2010 at 07:24 PM.
 
Old 11-27-2010, 07:52 PM   #2
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,128

Rep: Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120
Nothing will "move". A new name will be created pointing to the same inode.
Presuming same filesystem, and no oddities like symlinks.
 
Old 11-27-2010, 08:00 PM   #3
stress_junkie
Senior Member
 
Registered: Dec 2005
Location: Massachusetts, USA
Distribution: Ubuntu 10.04 and CentOS 5.5
Posts: 3,873

Rep: Reputation: 335Reputation: 335Reputation: 335Reputation: 335
I just performed an experiment that confirms syg00's assertions.
Code:
$ mkdir test1
$ mkdir test2
$ mkdir test1/move-me
$ touch test1/move-me/1
$ touch test1/move-me/2
$ touch test1/move-me/3
$
$ ls -id test1/move-me
3244084 test1/move-me
$ ls -i test1/move-me
3244085 1  3244086 2  3244087 3
$ 
$ mv test1/move-me test2
$ 
$ ls -id test2/move-me
3244084 test2/move-me
$ ls -i test2/move-me
3244085 1  3244086 2  3244087 3
The inodes remain the same for the directory that was moved and for the three files.
 
Old 11-27-2010, 08:09 PM   #4
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 4,442

Original Poster
Rep: Reputation: 76
I think I understand. In the "directory" for /home/john, the entry for mic2 will have the name field changed to mic1. That will be the only change in the whole of /. Thanks. And BTW, the file in which mic2 consists (every thing in linux is a file) IS the inode, I now see.
 
  


Reply

Tags
mv, sector



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
A joke at work.... honeybadger General 18 11-27-2010 10:53 AM
I deleted my /etc/alternatives directory. Now a lot of programs do not work. Help? tpsomers Linux - Newbie 3 06-05-2008 09:43 AM
Joke about M$ MensaWater General 4 04-21-2008 06:24 PM
Get the joke? Darin General 18 02-03-2006 08:19 PM
Joke davee General 9 02-20-2003 06:55 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware

All times are GMT -5. The time now is 07:14 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