LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware
User Name
Password
Linux - Hardware This forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?

Notices


Reply
  Search this Thread
Old 08-29-2004, 11:47 PM   #1
shaggystyle
Member
 
Registered: Dec 2003
Location: Louisville, KY
Distribution: Gentoo (desktop), Mandrake 10.0 (server)
Posts: 39

Rep: Reputation: 15
need help moving home


So I just stuck this old 40g drive in my mandrake 9x server and mounted it to /temp/ with hopes of copying all of my users home directory's over to it and then unmounting and remounting it as /home/ but I ran into a problem.
I type:
cp -a /home/* /temp/
Linux says:
cp: failed to preserve ownership for `/temp/user/somefile': Operation not permitted

What's the dealio? Thanks in advance for the help.
 
Old 08-30-2004, 12:35 AM   #2
Thoreau
Senior Member
 
Registered: May 2003
Location: /var/log/cabin
Distribution: All
Posts: 1,167

Rep: Reputation: 45
Your files have permissions on them...

chown root -R /home/*
chgrp root -R /home/*

Then your root will be able to read it proper. Or you can make it another user/group. Whatever makes ya happy.
 
Old 08-30-2004, 12:40 AM   #3
Bruce Hill
HCL Maintainer
 
Registered: Jun 2003
Location: McCalla, AL, USA
Distribution: Arch, Gentoo
Posts: 6,940

Rep: Reputation: 129Reputation: 129
Perhaps that depends upon how you partitioned and formatted
the old drive. What permissions did you give it? This is what it
says when I copy stuff to a FAT32 drive mounted as root. It still
copies the data, but the permissions are for root when it gets
there. I think if you look and find your data there, then you can
probably do a chown username.users and get it fixed.
 
Old 08-30-2004, 01:06 AM   #4
dalek
Senior Member
 
Registered: Jul 2003
Location: Mississippi USA
Distribution: Gentoo
Posts: 2,058
Blog Entries: 2

Rep: Reputation: 79
I have done this before and it works best if you boot from a CD, knoppix should work, and mount the partitions and then copy over like this:

Code:
cp -rp /mnt/path/to/data/to/move/* /mnt/path/to/where/to/put/it
That makes sure it keeps the permisions and such in tack. You ?may? be able to copy the /home from a running OS. I would NOT do that for the actual root part though. Some files are locked and will not copy at all. If they are needed at boot time, it may not work since they were not copied. Most of those files are in /proc and /sys. Just in case you need to know.

That help any?

 
Old 08-30-2004, 01:36 AM   #5
Electro
LQ Guru
 
Registered: Jan 2002
Posts: 6,042

Rep: Reputation: Disabled
For /home, you do not have to use Knoppix or any rescue CD to copy /home to another directory. At the boot loader add 3. For lilo you can type linux 3 and for grub you will have to hit e two times and add 3. It will then go into runlevel 3. Log in as root and then you can mount the drive and copy /home. If you set up ssh for your users to login, you will have to stop ssh. You can also close network too if you have any dummy terminals connected to the server. No users can not log in at the time you are copying /home to another location.

dalek, doing
cp -a /home/* /temp/
is the same as
cp -rp /mnt/path/to/data/to/move/* /mnt/path/to/where/to/put/it
 
Old 08-30-2004, 03:13 AM   #6
dalek
Senior Member
 
Registered: Jul 2003
Location: Mississippi USA
Distribution: Gentoo
Posts: 2,058
Blog Entries: 2

Rep: Reputation: 79
cp -a is suposed to be the same as -rp BUT I hade trouble with it once and started doing that way, to make certain.

It shouldn't need to be done from a CD for /home but I put that in just in case he had trouble. Most files that give trouble are in /proc and /sys, sometimes /var but usually not critical.

Now I hope he can get it copied over. Sounds like something else is in the works.

Later

 
Old 08-30-2004, 09:06 AM   #7
shaggystyle
Member
 
Registered: Dec 2003
Location: Louisville, KY
Distribution: Gentoo (desktop), Mandrake 10.0 (server)
Posts: 39

Original Poster
Rep: Reputation: 15
okay, well I tried moving them in Runlevel3, got the same error. I would have tried the knoppix idea except for the fact that all of my IDE cables are currently occupied with other HD's and I have no where to connect a CD drive (boo me all you like but really, how often do you need a cd drive on a webserver? except for right now of course ;D) Okay, so while perusing the man page for mount I noticed a --move option. Never seen it before or used it, maybe this would do what I wanted? Is this an option to mount a drive and move files to it at the same time? Sorry but I didn't see much info about it in the man.
 
Old 08-30-2004, 09:34 AM   #8
Bruce Hill
HCL Maintainer
 
Registered: Jun 2003
Location: McCalla, AL, USA
Distribution: Arch, Gentoo
Posts: 6,940

Rep: Reputation: 129Reputation: 129
Just out of sheer curiosity, this is what I did.

Code:
root@paul:/home/mingdao# mkdir /DATA/trial  <- this is /dev/hda3
root@paul:/home/mingdao# cp -a /home/* /DATA/trial   <- ~/ is /dev/hdc2
For each file it returned output like this:
cp: failed to preserve ownership for `/DATA/trial/mingdao/.gnome2/totem.pls': Operation not permitted
but all the files were copied, nonetheless. They've all got root.root but that's not really a problem. So now all that's needed is to chown the directories recursively, eh? ymmv
And of course, you could do a
tar cvf backup.tar /home (faster without compression) and then copy it over there. And if you have a different UID with the new installation, just issue a chown -R username the /home/username or whatever needs it. I've used tar czvf ~/ recently when I installed a new hard drive. Worked fine for me.

If you've already got the "new drive" in the box, give it a try. You don't have to erase your present drive...
 
Old 08-30-2004, 09:51 AM   #9
shaggystyle
Member
 
Registered: Dec 2003
Location: Louisville, KY
Distribution: Gentoo (desktop), Mandrake 10.0 (server)
Posts: 39

Original Poster
Rep: Reputation: 15
Yeah, I thought about that, but I'm a little hesitant to do it because I wasn't sure that it would work 100 %. If I screw up the permissions somehow and then wipe my current /home in order to mount the new drive as /home then I've f'ed up my box and all of my users files. I was hoping to do just a straight copy while maintaining permissions. But then again, maybe I'm just paranoid.

By the way, thanks for all of the help. I love it when I get more than just one person answering me with multiple solutions to the problem. makes me feel like less of an idiot.
 
Old 08-30-2004, 10:07 AM   #10
shaggystyle
Member
 
Registered: Dec 2003
Location: Louisville, KY
Distribution: Gentoo (desktop), Mandrake 10.0 (server)
Posts: 39

Original Poster
Rep: Reputation: 15
ok, so I tried chinaman's idea and amazingly it won't let me change the permissions back to the individual users. Right now my entire home directory is owned by root.
chown -R user /home/user = Permission denied
(and yes I'm root when I try this).
 
Old 08-30-2004, 10:11 AM   #11
Bruce Hill
HCL Maintainer
 
Registered: Jun 2003
Location: McCalla, AL, USA
Distribution: Arch, Gentoo
Posts: 6,940

Rep: Reputation: 129Reputation: 129
If you want to try the tar method, or any of them, after you've done that you can simply rename you're current /home partition something like /shaggy_test and you shouldn't have to worry about losing anything. You just need to get it straight in /etc/fstab and your bootloader, eh? Then if all is lost, shucks, man, rm -rf /home on the new drive and then mv /shaggy_test /home on the other one and fix your /etc/fstab back and do something else.

Let me tell you a funny story. You know that none of us can live without his important data, right? In early July I installed a new (3rd) hd in this box, whilst running down from the 3rd floor outside and back doing typical multi-tasking. Since I wasn't removing the drive from the box, only adding a new drive, I never bothered to backup (last one was May 22). I was going to keep Slackware 9.1 just like it was, and put Slackware 10.0 on the new drive. What I forgot was that when it came time to format a Linux partition it was going to choose ALL the Linux partitions, not just the ones I'd made with cfdisk on the new drive. I was through with all but the last one, which was /tmp, before I noticed that I was formatting /dev/hdc rather than /dev/hdd. Yep, lost all of my Slackware 9.1, and all of my data since the last time I did
root@paul:/home/mingdao# tar -czvf /DATA/backup.tgz /home
which was almost 2 months.

So now I've got Slack 10.0 and no more Slack 9.1, and I'm living without the lost data.
 
Old 08-30-2004, 10:40 AM   #12
Bruce Hill
HCL Maintainer
 
Registered: Jun 2003
Location: McCalla, AL, USA
Distribution: Arch, Gentoo
Posts: 6,940

Rep: Reputation: 129Reputation: 129
shaggystyle...

Which did you try? I've just done this:
root@paul:/# tar -czvf /DATA/backup.tgz /home
from / as root
which tarred my /home directory as backup.tgz to /DATA/
but you can put it wherever you have space. Then I moved
it to my "target drive" by issuing
root@paul:/home/mingdao# cp /DATA/backup.tgz /home/mingdao/Slack_save/
NB: This is the drive that is mounted as /home on my running system. That is
the problem you're having. You can't chown the directory that's mounted as
root.root whilst it's mounted that way.
Then I issued
mingdao@paul:~$ ls -alc ~/Slack_save/
total 1862200
drwxr-xr-x 3 mingdao users 104 Aug 30 23:24 ./
drwxr-xr-x 44 mingdao users 2464 Aug 30 23:21 ../
-rwxr-xr-x 1 root root 1906888165 Aug 30 23:23 backup.tgz*
drwxr-xr-x 4 root root 96 Aug 30 23:24 home/
mingdao@paul:~$ ls -alc ~/Slack_save/home
total 4
drwxr-xr-x 4 root root 96 Aug 30 23:24 ./
drwxr-xr-x 3 mingdao users 104 Aug 30 23:24 ../
drwxr-xr-x 2 root root 48 Aug 30 23:24 ftp/
drwxr-xr-x 42 root root 2080 Aug 30 23:27 mingdao/
to show you it's root's baby right now.
Then I issued
mingdao@paul:~$ su
Password:
root@paul:/home/mingdao# chown mingdao.users -R /home/mingdao/Slack_save/home/
root@paul:/home/mingdao# ls -alc /home/mingdao/Slack_save/home/
total 5
drwxr-xr-x 5 mingdao users 128 Aug 30 23:28 .
drwxr-xr-x 3 mingdao users 104 Aug 30 23:24 ..
drwx------ 2 mingdao users 48 Aug 30 23:28 .reiserfs_priv
drwxr-xr-x 2 mingdao users 48 Aug 30 23:28 ftp
drwxr-xr-x 43 mingdao users 2432 Aug 30 23:27 mingdao
And now my ~/mingdao directory is once again owned by the user.

Hope this helps - sorry for the confusion - I'm going to bed now.
 
Old 08-30-2004, 12:45 PM   #13
J.W.
LQ Veteran
 
Registered: Mar 2003
Location: Boise, ID
Distribution: Mint
Posts: 6,642

Rep: Reputation: 87
This article in my opinion is an excellent tutorial on how to move the /home directory. Good luck with it -- J.W.
 
Old 08-30-2004, 08:48 PM   #14
gd2shoe
Member
 
Registered: Jun 2004
Location: Northern CA
Distribution: Debian
Posts: 835

Rep: Reputation: 49
Shag, if you type
cat /etc/mtab
I bet it will tell you that the drive you have mouted is vfat (aka fat32). Fat32 doesn't keep track of ownership permissions, so linux cannot record them when the files are coppied. Linux just assumes that anything in there has the same ownership and permissions.

If you plan to use the drive in your linux box permanently, and windows will never need to read it, then I would reformat it to a linux file system. (Assumeing the drive is hdb)
umount /dev/hdb1
mkfs.ext2 -j /dev/hdb1
(remount)

If you are only planning to use the drive to transfer from one point to another (or hold your stuff while you reformat your main drive) then I would use a loop back file. Think of it as a partition (more specifically a complete filesystem) inside a file.
dd if=/dev/zero of=loopfile bs=1G count=1
mkfs.ext2 -j loopfile
mount -o loop loopfile /mnt/anywhere

This makes a 1 GB file, puts a filesystem in it, and then mounts it. You can store your stuff in there and it will remember permissions. (Bear in mind if you are reinstalling your OS, and you copy stuff back you may need to set user:group ownership if the uid or guid change.)
 
Old 08-31-2004, 01:51 AM   #15
Electro
LQ Guru
 
Registered: Jan 2002
Posts: 6,042

Rep: Reputation: Disabled
If /home is bigger than 2 gigabytes, FAT32 will not be able to hold it. You will then have to make several images and use RAID if it bigger than 2 gigabytes. You will have to use losetup to create raw loop devices and then setup RAID. Though I have not use RAID with loop devices, but I did try making loop devices using different steps that gd2shoe gave.

I do not know why copying /home to another partition is giving you trouble. I did that all day testing out different filesystems with out any problems. The steps that did to copy /home is similar to the link that J.W. gave. Though I did not go into runlevel 1 because my setup is not servering a dozen users and runlevel 3 is low enough for me to copy /home.
 
  


Reply



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
Moving /home Directory? NovaBurst DamnSmallLinux 1 04-18-2005 10:59 PM
moving /home to a new drive? tardigrade Linux - Newbie 5 10-18-2004 05:56 PM
Moving my /home directory to another hd bumpert Linux - Newbie 6 07-26-2004 03:27 AM
moving /home to / abu_abdullaah Linux - Newbie 3 07-18-2004 01:15 PM
Moving /home xodeus Slackware 7 10-06-2003 03:33 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware

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

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
Open Source Consulting | Domain Registration