LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How do I copy specific files and dirs from partition A to B in the same Hdd in Linux? (https://www.linuxquestions.org/questions/linux-newbie-8/how-do-i-copy-specific-files-and-dirs-from-partition-a-to-b-in-the-same-hdd-in-linux-4175438000/)

AnApproach2DigestLinux 11-20-2012 01:49 PM

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)

markush 11-20-2012 01:58 PM

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
Code:

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: http://docs.slackware.com/howtos:gen...es_efficiently

There is a useful tutorial in the internet here: http://rute.2038bug.com/index.html.gz

Markus

knudfl 11-20-2012 03:04 PM

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.

.

tekhead2 11-20-2012 03:29 PM

Also you may want to consider the rsync command if these files are system files or have special permissions.

lleb 11-20-2012 04:47 PM

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.

suicidaleggroll 11-20-2012 06:05 PM

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.


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