LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-24-2007, 02:13 PM   #1
Yes
LQ Newbie
 
Registered: Feb 2007
Posts: 19

Rep: Reputation: 0
Simple copy question


How do I copy the contents of a folder(files and subfolders) to a directory or a mount point?

For example; I want to move /usr to a new partition, without altering permissions, symlinks or anything else, so I would then write:

cp -av /usr /mnt/newpartition

However, this will create a usr-directory on newpartition, which I don't want(because if I then mount the new partition in /usr the path to all the files would be /usr/usr).

I bet its so simple its embarassing, but I really cant figure it out...
 
Old 02-24-2007, 02:21 PM   #2
MS3FGX
LQ Guru
 
Registered: Jan 2004
Location: NJ, USA
Distribution: Slackware, Debian
Posts: 5,852

Rep: Reputation: 356Reputation: 356Reputation: 356Reputation: 356
Sounds like what you want to do would be:

Code:
cp -avr /usr/* /mnt/newpartition/
Note the added -r. That will make the copy recursive so that not only files will be copied, but any directories and the files they contain will be copied as well. Since you are copying /usr, I am assuming you want every file and directory under it as well.

Last edited by MS3FGX; 02-24-2007 at 02:23 PM.
 
Old 02-24-2007, 02:22 PM   #3
macemoneta
Senior Member
 
Registered: Jan 2005
Location: Manalapan, NJ
Distribution: Fedora x86 and x86_64, Debian PPC and ARM, Android
Posts: 4,593
Blog Entries: 2

Rep: Reputation: 332Reputation: 332Reputation: 332Reputation: 332
You want to copy the contents, not the directory:

cp -av /usr/* /mnt/newpartition
 
Old 02-24-2007, 02:40 PM   #4
Yes
LQ Newbie
 
Registered: Feb 2007
Posts: 19

Original Poster
Rep: Reputation: 0
Ah, thank you! It really was embarassingly simple... I was thinking more along the lines of old DOS with *.*, but that got me nowhere.

MS3FGX, I think the -a flag is the same as -dpr, so it should be recursive already.
 
Old 02-24-2007, 02:50 PM   #5
MS3FGX
LQ Guru
 
Registered: Jan 2004
Location: NJ, USA
Distribution: Slackware, Debian
Posts: 5,852

Rep: Reputation: 356Reputation: 356Reputation: 356Reputation: 356
Ah yes, so it is. My mistake I didn't notice that.
 
Old 02-24-2007, 08:30 PM   #6
Yes
LQ Newbie
 
Registered: Feb 2007
Posts: 19

Original Poster
Rep: Reputation: 0
Heres a bit of an unrelated question, but I dont want to start a new topic just for this...

The thing is I have moved my Gentoo installation to different harddrives. I have pretty much backed up /, /usr and /home, switched harddrives and moved the files back again. Hopefully this will work. One thing that remains though is installing Grub to /dev/hda(one of the drives that were replaced).

When I installed Gentoo I ran this command, before installing Grub, in a chrooted environment:

grep -v rootfs /proc/mounts > /etc/mtab

Now im just booting from a livecd. Can I run this even though im not chrooted? That would make my life a bit easier as im feeling quite unsure of how the chrooting is done properly.
 
Old 02-24-2007, 08:36 PM   #7
macemoneta
Senior Member
 
Registered: Jan 2005
Location: Manalapan, NJ
Distribution: Fedora x86 and x86_64, Debian PPC and ARM, Android
Posts: 4,593
Blog Entries: 2

Rep: Reputation: 332Reputation: 332Reputation: 332Reputation: 332
You want to start a new topic, so that those that have the answer will see the question. Burying it at the bottom of a solved thread will get no attention. It also makes it much harder for people to search, to find the answer themselves (which I assume you'll do, since installing grub from a bootcd is a common question).
 
Old 02-24-2007, 09:21 PM   #8
Yes
LQ Newbie
 
Registered: Feb 2007
Posts: 19

Original Poster
Rep: Reputation: 0
Oh, sorry - I forgot to search. Happens easily when I start to approach things in an unnecessarily complicated way(that is, looking in the Gentoo handbook about installing Grub... reading strange commandlines and "chroot" - uh oh! confusion, etc. et al - "I better ask on this board"!). Yeah, well, sometimes my brain works that way so I need to be reminded to search. Thanks!

It was really a piece of cake. Mount root-partition, cd to /boot/grub, run 'grub' the, 'root (hd, partition)' and 'setup (hd)'(where you want Grub installed in mbr).
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 simple question on copy and paste satimis Fedora 4 06-02-2006 07:13 AM
Ubuntu Fluxbox simple question, simple answer? generallimptoes Linux - Software 3 09-26-2005 03:03 PM
Installing Programs - A simple question from my simple mind jmp875 Linux - Newbie 6 02-18-2004 10:03 PM
simple one: how to copy audio-cd-s on gnometoaster jaan kaer Linux - Newbie 12 11-16-2003 04:21 PM
Help I need a simple DVD copy/rip/player package kkempter Linux - Software 2 08-16-2003 05:04 AM


All times are GMT -5. The time now is 04:21 PM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration