Linode.com Forum Forum Index Linode.com Forum
Linode Community Forums
 


HOWTO - Transfering /whatever to a new disk image

Click here to go to the original topic

 
       Linode.com Forum Forum Index -> Linux Tips, Tricks, Tutorials
Author Message
wap



Joined: 03 Nov 2003
Posts: 12
Location: Paris, France

Posted: Fri Nov 07, 2003 3:26 am    Post subject: HOWTO - Transfering /whatever to a new disk image  

Thanks to the help of other users (special thanks go to EFudd), I succeeded yesterday to create a disk image and move the /usr directory onto it. I did it with a Debian (small) install, but I guess it should work with just any distribution and with any other subdirectory of /, as long as the directory you want to move is not a mount but a regular subdir of the root file system.

I'm new to Linux and to UML hosting, so there might be better ways to procede. Criticisms and tips are welcome!

NB: In the following instructions, you will obvisouly want to adapt usr and udbc to your own case!

Step 1: Create a hard drive image and update your configuration profile accordingly.

Step 2: Log in as user root, and use the following commands:
- mkdir /newusr
- mount /dev/ubdc /newusr
- cd /usr
- find . -print | cpio -pdmuv /newusr (that's the trick! take care with -v as it may take a _long_ time)
- cd /
- mv usr usr.old
- umount newusr
- rmdir newusr && mkdir usr
- mount /dev/ubdc /usrStep 3: Edit /etc/fstab and add the following line: /dev/ubdc /usr ext3 defaults 0 0

Step 4: Reboot and make sure everything works fine

Step 5: Delete usr.old

I hope it will help :)
Back to top  
sunny



Joined: 27 Jul 2003
Posts: 42
Location: New York, NY

Posted: Fri Nov 07, 2003 10:13 am    Post subject:  

tar, the 8th wonder of the world, can do the above too :^)

Code: ( cd $OLD_DIR ; tar cf - . ) | ( cd $NEW_DIR ; tar xvfpB - )

Also, some of you guys might lack the diskspace to copy around large directories and such. So you can simply use tar and ssh to copy large files home, and then back to your linode

Code:
Linode --> Some other computer on earth
cd $SOME_DIR ; tar -cf - . | ssh host.com tar -xf - -C /destination


Just use it the same command to transfer files back to your linode.

Sunny Dubey
Back to top  
Geoff



Joined: 22 Jun 2003
Posts: 8

Posted: Fri Nov 07, 2003 2:46 pm    Post subject:  

Thanks wap and Sunny - I was just about to figure out how to do this, read the latest messages in the forums, and there it is :D

I now have /usr, /var and /home directories on their own disk images

Geoff
Back to top  
wap



Joined: 03 Nov 2003
Posts: 12
Location: Paris, France

Posted: Sat Nov 08, 2003 3:22 am    Post subject:  

I'm glad I could help :)
Back to top  
efudd



Joined: 27 Oct 2003
Posts: 17

Posted: Sat Nov 08, 2003 8:13 pm    Post subject:  

sunny wrote: tar, the 8th wonder of the world, can do the above too :^)

Code: ( cd $OLD_DIR ; tar cf - . ) | ( cd $NEW_DIR ; tar xvfpB - )

Also, some of you guys might lack the diskspace to copy around large directories and such. So you can simply use tar and ssh to copy large files home, and then back to your linode

Code:
Linode --> Some other computer on earth
cd $SOME_DIR ; tar -cf - . | ssh host.com tar -xf - -C /destination

Just use it the same command to transfer files back to your linode.

Sunny Dubey

Fok tar. gnutar version X != X.1 != X3, etc. Not to mention non gnu versions of tar.

the cpio and find scenario i gave to wap will work on every unix i've ever seen.....

-e
Back to top  
sunny



Joined: 27 Jul 2003
Posts: 42
Location: New York, NY

Posted: Sun Nov 09, 2003 6:06 am    Post subject:  

efudd wrote:
Fok tar. gnutar version X != X.1 != X3, etc. Not to mention non gnu versions of tar.

the cpio and find scenario i gave to wap will work on every unix i've ever seen.....

-e

Once again, get a clue, the above *DO* work in this magical thing called "UNIX". You think the GNU guys pulled obscure and illogical tar options out of their asses, or used what already existed ?

You should go back to your hole, where you can have your UNIX, your standardized csh*COUGH**COUGH*, with nice wiff of CDE, nasty looking Motif, near dead X implementations, lousy C compilers, non dynamically-linkable binaries, obscure and outright illogical package management, and a world where telnet is still the defacto standard. *cough*

Sunny Dubey

csh .... bahahaha .. oh please stop!!
Back to top  
bji



Joined: 27 Aug 2003
Posts: 182

Posted: Sun Nov 09, 2003 12:04 pm    Post subject:  

sunny wrote: efudd wrote:
Fok tar. gnutar version X != X.1 != X3, etc. Not to mention non gnu versions of tar.

the cpio and find scenario i gave to wap will work on every unix i've ever seen.....

-e

Once again, get a clue, the above *DO* work in this magical thing called "UNIX". You think the GNU guys pulled obscure and illogical tar options out of their asses, or used what already existed ?

You should go back to your hole, where you can have your UNIX, your standardized csh*COUGH**COUGH*, with nice wiff of CDE, nasty looking Motif, near dead X implementations, lousy C compilers, non dynamically-linkable binaries, obscure and outright illogical package management, and a world where telnet is still the defacto standard. *cough*

Sunny Dubey

csh .... bahahaha .. oh please stop!!

Well I guess the Linode message boards have fully come of age, it looks like we have our first real flame. How repulsive.

I was going to respond to efudd and note that I have been using Unix/Linux for over 12 years and have never, ever once ran into compatibility problems between tar or gzip, gnu or otherwise.

I would just suggest that you use whatever you are most comfortable with, tar or cpio, just keep in mind that both are equally good for the job. Compatibility issues are generally not a problem.
Back to top  
schof



Joined: 18 Sep 2003
Posts: 46
Location: Los Angeles

Posted: Sun Nov 09, 2003 1:23 pm    Post subject:  

sunny wrote: efudd wrote:
Fok tar. gnutar version X != X.1 != X3, etc. Not to mention non gnu versions of tar.

the cpio and find scenario i gave to wap will work on every unix i've ever seen.....

-e

Once again, get a clue, the above *DO* work in this magical thing called "UNIX". You think the GNU guys pulled obscure and illogical tar options out of their asses, or used what already existed ?

You should go back to your hole, where you can have your UNIX, your standardized csh*COUGH**COUGH*, with nice wiff of CDE, nasty looking Motif, near dead X implementations, lousy C compilers, non dynamically-linkable binaries, obscure and outright illogical package management, and a world where telnet is still the defacto standard. *cough*

Sunny Dubey

csh .... bahahaha .. oh please stop!!

After rereading this, I got the feeling Sunny thought it would be funnier than it is. (I've had the same thing happen with a lot of things I write.)

At least, I hope it was an error in tone. Sunny's been real cool elsewhere in these forums.


Schof
Back to top  
wazdog



Joined: 10 Nov 2003
Posts: 57
Location: Japan

Posted: Mon Nov 24, 2003 7:29 am    Post subject:  

I did this before I found this thread, but instead of:

- find . -print | cpio -pdmuv /newusr (that's the trick! take care with -v as it may take a _long_ time)

I did:

# cd /var
# cp -ax * /mnt/var.new

It seems to have worked fine, any thoughts? Did I screw something up that I find out later?

Thanks from a genuine newbie running Debian...

- j
Back to top  
bji



Joined: 27 Aug 2003
Posts: 182

Posted: Mon Nov 24, 2003 1:35 pm    Post subject:  

wazdog wrote: I did this before I found this thread, but instead of:

- find . -print | cpio -pdmuv /newusr (that's the trick! take care with -v as it may take a _long_ time)

I did:

# cd /var
# cp -ax * /mnt/var.new

It seems to have worked fine, any thoughts? Did I screw something up that I find out later?

Thanks from a genuine newbie running Debian...

- j

Your simpler command works just fine. The tar/cpio method has some advantages as it is a streaming method which can be used to copy files from one system to another over ssh, and do other neat tricks, but if you're just copying files from one directory/partition on a host to another on the same host, the cp -ax will have the same effect, and it's much easier to type. I think that people (me included) like to use the more complicated tar/cpio commands even when copying within a single host, because it's simpler to use the same (more complicated) command in all situations, with slight variations, then to use a different command depending upon the situation. But it doesn't really matter either way, use whatever you find easiest and most comfortable.
Back to top  
Bill Clinton



Joined: 23 Nov 2003
Posts: 79

Posted: Mon Nov 24, 2003 1:38 pm    Post subject:  

wazdog wrote:
# cd /var
# cp -ax * /mnt/var.new


The problem with this is that cp will not copy special files, sockets, etc. This is why tar or cpio is used.

I personally suggest using tar because tar is not limited to a 2 gig transfer size as UNIX cpio is.

Bill Clinton
Back to top  
vitre0us



Joined: 22 Jul 2003
Posts: 32
Location: Southern California

Posted: Mon Nov 24, 2003 5:12 pm    Post subject:  

Bill Clinton wrote: wazdog wrote:
# cd /var
# cp -ax * /mnt/var.new


The problem with this is that cp will not copy special files, sockets, etc. This is why tar or cpio is used.

I personally suggest using tar because tar is not limited to a 2 gig transfer size as UNIX cpio is.

Bill Clinton


So Mr President, I assume you have taken up Linux System Administration as a hobby in your retirement? :twisted:
Back to top  
alphonso



Joined: 03 Sep 2003
Posts: 19

Posted: Tue Nov 25, 2003 11:32 am    Post subject:  

I'll bet I know the reason:

Babes!
Back to top  
 
       Linode.com Forum Forum Index -> Linux Tips, Tricks, Tutorials
Page 1 of 1