Help answer threads with 0 replies.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 11-20-2012, 02:49 PM   #1
LQ Newbie
Registered: Nov 2012
Posts: 6

Rep: Reputation: Disabled
Smile How do I copy specific files and dirs from partition A to B in the same Hdd in Linux?

I am new in Red Hat linux world and would like to know

a)How I should copy specific files and dirs from one partition to another in the same hard disk in Red Hat Linux and list them after copy process?

b)How I should copy specific files and dirs from one hard disk to another hard disk in the same machine in Red Hat Linux and list them after copy process?

For windows it is very easy and straight forward but in linux I really spent alot of time but did not find what I am loking for. What I found sofar is cloning of whole partition and disk or transfer/migration of whole data. Which is not my requirement.

Any help little or big has alot of meaning for me. This forum is ocean of knowledge and I am sure you guys will not let me go empy handed.

(Thanks everybody)
Old 11-20-2012, 02:58 PM   #2
Senior Member
Registered: Apr 2007
Location: Germany
Distribution: Slackware
Posts: 3,979

Rep: Reputation: Disabled
Hello, welcome to LQ,

the most common helpsystem in Linux/Unix are the manpages. You can open a manpage for a command (for example cp) with
man cp
I would recommend that you read the manpages for "cp", "tar" and "mount" for help with your question. There is a Howto about using the manpages here:

There is a useful tutorial in the internet here:

2 members found this post helpful.
Old 11-20-2012, 04:04 PM   #3
LQ 5k Club
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2020 CentOS6.10 CentOS7.7 + 50+ other Linux OS, for test only.
Posts: 17,321

Rep: Reputation: 3581Reputation: 3581Reputation: 3581Reputation: 3581Reputation: 3581Reputation: 3581Reputation: 3581Reputation: 3581Reputation: 3581Reputation: 3581Reputation: 3581
The partitions must be mounted.

Example :
# mkdir /mnt/sda3
# mkdir /mnt/sda7

# mount -t auto /dev/sda3 /mnt/sda3/
# mount -t auto /dev/sda7 /mnt/sda7/

# cp /mnt/sda3///<file> /mnt/sda7/<destination>
# cp -a /mnt/sda3///<directory> /mnt/sda7/<destination>

.. If one of the partitions are your current working OS :
No "mount" is required.

1 members found this post helpful.
Old 11-20-2012, 04:29 PM   #4
Registered: Apr 2004
Distribution: slackware/FreeBSD/Vector
Posts: 291

Rep: Reputation: 52
Also you may want to consider the rsync command if these files are system files or have special permissions.
Old 11-20-2012, 05:47 PM   #5
Senior Member
Registered: Dec 2005
Location: Florida
Distribution: CentOS/Fedora
Posts: 2,758

Rep: Reputation: 524Reputation: 524Reputation: 524Reputation: 524Reputation: 524Reputation: 524
in addition to man cp, do man rsync.

simple example

you have files in /stuff and want them and the entire directory in /foo

rsync -aviS /suff /foo

problem solved. not only will it copy every file in /stuff to /foo, but you will preserve permissions, ownership, symlinks, and get a verbos printout on the screen of exactly what is happening during the copy.
Old 11-20-2012, 07:05 PM   #6
LQ Guru
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,573

Rep: Reputation: 2137Reputation: 2137Reputation: 2137Reputation: 2137Reputation: 2137Reputation: 2137Reputation: 2137Reputation: 2137Reputation: 2137Reputation: 2137Reputation: 2137
Copying files between different partitions on the same drive or between wholly independent drives is no different than just copying files from one directory to another.

In Linux, all files/directories, regardless of what partition or drive they physically sit on, live under ONE tree. This is very different than in Windows where each drive/partition has its OWN tree. In linux, you mount a drive/partition to a specific directory on your existing tree. From then on, anything copied to that directory will be copied to the drive that is mounted there.

So, if you have partition A mounted at /mnt/A, and you have partition B mounted at /mnt/B, you can copy back and forth between the directories however you want. "cp /mnt/A/file /mnt/B", or you can use rsync, or you can even do it graphically in the file browser.


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
[SOLVED] copy all partition contents from one HDD to another cccc Debian 4 10-20-2012 08:55 PM
copy svn working dir without svn hidden dirs and files? erinspice Linux - Software 4 03-29-2011 06:58 PM
Copy files from windows to linux partition nataly Linux - Newbie 6 10-09-2007 12:08 PM
Copy files from Windows partition to Linux partition Shibumgeorge Linux - Software 3 04-20-2007 11:08 AM
Canīt see certain files/dirs in debian partition jimdaworm Slackware 2 10-11-2004 07:54 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:34 PM.

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