LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   cp command Howto copy files from /home of one distro to another in a multiboot mach (https://www.linuxquestions.org/questions/linux-newbie-8/cp-command-howto-copy-files-from-home-of-one-distro-to-another-in-a-multiboot-mach-731151/)

borgibo 06-06-2009 01:51 PM

cp command Howto copy files from /home of one distro to another in a multiboot mach
 
Hello,

I want to copy some files from Sidux, its "/" is installed in /dev/hda13" its "/home" in lvm, to Lenny, installed "/" in hda5 its "/home" in hda6, in a multiboot machine.

Those are very small files of some written documents.

I am lost as I cannot instruct cp to use another /dev . I try from Sidux where the files are: "cp /home/jv/x /dev/hda5/home/jv but get errors.

The files reside in Sidux's /home and must be copied to Lenny's /home.

Please instruct me if possible.

In the meantime I have copied them to a cd using k3b and will try to copy them over from the cd to Lenny's /home.

Thank you for your attention,

borgibo

colucix 06-06-2009 01:56 PM

You have to mount the device to get access to its directory tree. Create a mount point or use an existing one if empty. For example:
Code:

# mkdir /mnt/lenny
# mount /dev/hda6 /mnt/lenny
# cp -p file_to_copy /mnt/lenny/path/to/dir/in/lenny/home/


borgibo 06-07-2009 05:08 AM

@colucix

I had made a mistake, Lenny's home is hda5 and / hda6, not the other way around.

So I tried first the wrong one and then the correct one and got the following: jv@siduxbox:~$ su
Password:
root@siduxbox:/home/jv# mkdir /mnt/Lenny
root@siduxbox:/home/jv# mkdir /mnt/lenny
root@siduxbox:/home/jv# mount /dev/hda6 /mnt/lenny
mount: special device /dev/hda6 does not exist
root@siduxbox:/home/jv# mount /dev/hda5 /mnt/lenny
mount: special device /dev/hda5 does not exist
root@siduxbox:/home/jv#

So it seems I am doing something wrong.

Thank you very much for your help. Waiting for more instructions?

borgibo

colucix 06-07-2009 05:13 AM

Well, it looks like /dev/hda5 and /dev/hda6 don't exist. Check the partition layout of the disk using fdisk -l as root and post the output so we can see it together.

borgibo 06-07-2009 05:19 AM

I tried sda5 instead of hda5 and got the following:jv@siduxbox:~$ su
Password:
root@siduxbox:/home/jv# mkdir /mnt/Lenny
root@siduxbox:/home/jv# mkdir /mnt/lenny
root@siduxbox:/home/jv# mount /dev/hda6 /mnt/lenny
mount: special device /dev/hda6 does not exist
root@siduxbox:/home/jv# mount /dev/hda5 /mnt/lenny
mount: special device /dev/hda5 does not exist
root@siduxbox:/home/jv# mkdir /mnt/lenny
mkdir: cannot create directory `/mnt/lenny': File exists
root@siduxbox:/home/jv# mount /dev/sda5 /mnt/lenny
root@siduxbox:/home/jv# cp -p /home/jv/Polski_κόκκινο/ /mnt/lenny/home/jv
cp: omitting directory `/home/jv/Polski_κόκκινο/'
root@siduxbox:/home/jv# cp -p /home/jv/Polski_κόκκινο/ /mnt/lenny/path/to/dir/in/lenny/home/
cp: omitting directory `/home/jv/Polski_κόκκινο/'
root@siduxbox:/home/jv#

hope that is of some help,

borgibo, thanks again

sycamorex 06-07-2009 05:52 AM

You need to use the -r (=recursive) flag with cp to copy directories.

colucix 06-07-2009 06:03 AM

As sycamorex said. Now you should know that /dev/sda5 is a valid partition, but have you checked if it is the lenny's home partition?

sycamorex 06-07-2009 06:18 AM

Quote:

Originally Posted by colucix (Post 3565823)
As sycamorex said. Now you should know that /dev/sda5 is a valid partition, but have you checked if it is the lenny's home partition?

IMO you should first identify all the partitions you've got on your computer. Check fdisk -l and then mount them one by one (apart from swap) and make sure you know what they contain, eg.

/dev/sda1 - fedora 10 /
/dev/sda2 - fedora 10 /home
/dev/sda3 - swap
/dev/sda5 - debian /
/dev/sda6 - debian /home
/dev/sda7 - slackware /boot
/dev/sda8 - slackware /
/dev/sda9 - slackware /home
/dev/sda10 - data partition
I always write it down in my little notepad and update it whenever I change something. Knowing your system/partition table will make things easier for you.

borgibo 06-08-2009 01:47 AM

I do keep a copy of Gparted printed where I note all the partitions.

re cycamorex: "You need to use the -r (=recursive) flag with cp to copy directories." should I use "r" instead of "p" in the command: " # mkdir /mnt/lenny
# mount /dev/hda6 /mnt/lenny
# cp -p file_to_copy /mnt/lenny/path/to/dir/in/lenny/home/" ?

Using the correct sda partitions: (jv is user, sda5=lennys's/home, sda6=lenny's/, /home/jv/Polski=path of Polski file residing in sidux( sda13=/ lvm=/home) to be transferred to lenny.:

I.e. # mkdir /mnt/lenny
# mount /dev/sda5 /mnt/lenny
# cp -r /home/jv/Polski /mnt/lenny/path/to/dir/in/lenny/home/

Or am I very wrong in the last lines ? Should rather be: "/mnt/lenny/home/jv" ?


borgibo

colucix 06-08-2009 02:50 AM

Quote:

Originally Posted by borgibo (Post 3566509)
I.e. # mkdir /mnt/lenny
# mount /dev/sda5 /mnt/lenny
# cp -r /home/jv/Polski /mnt/lenny/path/to/dir/in/lenny/home/

Or am I very wrong in the last lines ? Should rather be: "/mnt/lenny/home/jv" ?

Of course. Since I didn't know what is the exact path, I put something dummy to be substituted with the actual path. It should be ok now, with recursive option, right?

borgibo 06-08-2009 04:51 AM

I have tried without success. This is what I got:

jv@siduxbox:~$ su
Password:
root@siduxbox:/home/jv# mkdir /mnt/lenny
root@siduxbox:/home/jv# mount /sda5/mnt /mnt/lenny
mount: special device /sda5/mnt does not exist
root@siduxbox:/home/jv# mount /sda5 mnt/lenny
mount: mount point mnt/lenny does not exist
root@siduxbox:/home/jv# mount /sda5
mount: can't find /sda5 in /etc/fstab or /etc/mtab
root@siduxbox:/home/jv#

It seems I am unlucky.

I will try to copy the files using the cd that I burned with them, have not done it before, I think I will manage, using k3b.
Another way I tried was using knoppix live cd but unfortunately the files are in a lvm partition which knoppix does not recognize.


thank you everybody.

borgibo

colucix 06-08-2009 07:20 AM

In post #5 you already succeeded in mounting the partition:
Code:

mount /dev/sda5 /mnt/lenny
what is the problem now? What is the output of
Code:

ls /mnt/lenny
after mounting it?

borgibo 06-08-2009 08:39 AM

Well I am sorry colucix, things are very confusing for me. I tried again and this time I got a step further then post 11.:
jv@siduxbox:~$ su
Password:
root@siduxbox:/home/jv# mkdir /mnt/lenny
mkdir: cannot create directory `/mnt/lenny': File exists
root@siduxbox:/home/jv# mount /dev/sda5 /mnt/lenny
mount: /dev/sda5 already mounted or /mnt/lenny busy
mount: according to mtab, /dev/sda5 is already mounted on /mnt/lenny
root@siduxbox:/home/jv# cp -r /home/jv/Polski_κόκκινο/ /mnt/lenny/home/jv
cp: cannot create directory `/mnt/lenny/home/jv': No such file or directory
root@siduxbox:/home/jv#

I am amazed with such inconsistency, I mean between post's #11 line "root@siduxbox:/home/jv# mount /sda5 mnt/lenny
mount: mount point mnt/lenny does not exist" and the present one's "root@siduxbox:/home/jv# mount /dev/sda5 /mnt/lenny
mount: /dev/sda5 already mounted or /mnt/lenny busy "

And you are right that in post #5 I managed better than in #11.

Which means that I now get stuck further down the line !

Anyway just to keep me and probably you also happy, I have managed to copy the files in Lenny's /home/jv using the cd I had burned with them. Extremely easy, I could not believe my eyes. The files emerged in the desktop as soon as I put the cd in, while in Lenny, complete as they were in sidux and I copied and pasted them in /home/jv. That sounds silly but for me it is unbelievable ! I even opened them and checked them !!!!

Of course I wish I could have done it as you suggested but my lack of knowledge is to blame for the inconsistencies and mistakes I presume.

Thanks a lot,

have a nice time,

borgibo


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