The Linux partition on my triple boot Windows/Linux PC has gradually been filling up over the past few months and is now 98% full with just 40MB remaining. I have therefore had a clear out on my Windows partition to create some free space and have been able to create two new small partitions which I can now use with Linux to ease some of the strain.
My current setup is:
/dev/hda1 Windows /dev/hda2 swap /dev/hda5 /boot /dev/hda7 /
I would like to change this to:
/dev/hda1 Windows /dev/hda2 swap /dev/hda5 /boot /dev/hda7 /usr /dev/hda12 / /dev/hda13 /home
I have formatted these two new partitions and moved /home from hda7 to hda13 ok and deleted it from hda7. I now want to move everything else apart from the /usr directory from hda7 to hda12. What is the best way to tell Linux to move everything except this one directory from one partition to another (hda12 is a lot smaller than hda7 and is not big enough to hold /usr even temporarily)?
Ian.
On Sun, 22 Dec 2002 10:15:20 -0000 "Ian Douglas" alug@the-zub.demon.co.uk wrote:
... What is the best way to tell Linux to move everything except this one directory from one partition to another (hda12 is a lot smaller than hda7 and is not big enough to hold /usr even temporarily)?
I can't say for sure if this the best way, but what I have always done for a situation like this is to use filename patterns to match the things I want to copy and exclude the one I don't.
As an example, my root directory looks like this:
bin dev home lost+found proc tmp vmlinuz boot etc initrd mnt root usr vmlinuz.old cdrom floppy lib opt sbin var
so assuming the new partition is mounted on /mnt/root I would say:
cp -a [b-l]* [o-t]* v* /mnt/root
I am specifying those directories I want to copy by range, based on the first letter. I am excluding the /mnt directory as I don't want the copy to get into an infinite loop by trying to make a copy of the copy etc. As you have a separate /boot partition you may not want to copy that at the same time so you could say:
cp -a bin [c-l]* [o-t]* v* /mnt/root
As there is /bin and /boot both beginning with 'b' I omit the 'b' from the wildcard expression and specify bin as a separate argument.
Hope this helps. Steve.
On Sunday, December 22, 2002 11:59 AM, Steve Fosdick wrote:
I can't say for sure if this the best way, but what I have always done for a situation like this is to use filename patterns to match the things I want to copy and exclude the one I don't.
As an example, my root directory looks like this:
bin dev home lost+found proc tmp vmlinuz boot etc initrd mnt root usr vmlinuz.old cdrom floppy lib opt sbin var
so assuming the new partition is mounted on /mnt/root I would say:
cp -a [b-l]* [o-t]* v* /mnt/root
I am specifying those directories I want to copy by range, based on the first letter...
Thanks for the suggestion Steve. I must admit I did actually use the cp command to copy /home to the new partition without problems but have a nagging worry in the back of my head that someone on the list had loads of hassle trying to copy system directories earlier in the year. I seem to remember it was symbolic links and special system files which didn't copy correctly and caused the problems. Unfortunately, although I found the message thread interesting I forgot to write down the eventual solution but I *think* in the end they used a short shell script which used ls to read in the directory names, the resulting list being tweaked somehow within the script before being passed to tar (or may have been cpio???) to do the actual copying. Unfortunately I forgot to write the script down. I guess though you are correct and the simplest thing would be for me to try the cp command string you suggested first and see what happens on the subsequent bootup (after editing fstab and rerunning lilo).
Thanks for your help,
Ian.
On Sun, 22 Dec 2002, Ian Douglas wrote:
Thanks for the suggestion Steve. I must admit I did actually use the cp command to copy /home to the new partition without problems but have a nagging worry in the back of my head that someone on the list had loads of hassle trying to copy system directories earlier in the year. I seem to remember it was symbolic links and special system files which didn't copy correctly and caused the problems. Unfortunately, although I found the message thread interesting I forgot to write down the eventual solution but I *think* in the end they used a short shell script which used ls to read in the directory names, the resulting list being tweaked somehow within the script before being passed to tar (or may have been cpio???) to do the actual copying. Unfortunately I forgot to write the script down. I guess though you are correct and the simplest thing would be for me to try the cp command string you suggested first and see what happens on the subsequent bootup (after editing fstab and rerunning lilo).
When you isue the cp command use cp -pd WHATEVER...
-p keeps ownership permissions the same -d is no dereference, ie it copies sym links as symlinks, and doesn't convert them to regular files, so by the time you've got everything to where you want it, it should all work.
Hope that helps
Chris
On Sun, 22 Dec 2002 13:33:00 +0000 (GMT) Chris Glover chris@glovercc.clara.co.uk wrote:
When you isue the cp command use cp -pd WHATEVER...
-p keeps ownership permissions the same -d is no dereference, ie it copies sym links as symlinks, and doesn't convert them to regular files, so by the time you've got everything to where you want it, it should all work.
Actually it may have been me that expressed concern about links, born of experience of some other Unixes. The GNU cp command as supplied with Linux seems to be OK though provided you give it the right options. Chris says include -p and -d, and of course you need -r for recursive. The -a I suggested is equivalent to those three in combination.
Steve.
"Ian Douglas" alug@the-zub.demon.co.uk writes:
Steve Fosdick wrote:
so assuming the new partition is mounted on /mnt/root I would say:
cp -a [b-l]* [o-t]* v* /mnt/root
I am specifying those directories I want to copy by range, based on the first letter...
Thanks for the suggestion Steve. I must admit I did actually use the cp command to copy /home to the new partition without problems but have a nagging worry in the back of my head that someone on the list had loads of hassle trying to copy system directories earlier in the year. I seem to remember it was symbolic links and special system files which didn't copy correctly and caused the problems.
"cp -a" should work fine. Other possible invocations of cp might well cause problems, and AFAIK all the non-GNU versions of cp don't have the feature at all...
on Sun, Dec 22, 2002 at 01:54:31PM +0000, Richard Kettlewell wrote:
"cp -a" should work fine. Other possible invocations of cp might well cause problems, and AFAIK all the non-GNU versions of cp don't have the feature at all...
they do. SuSv3 has it -- just not as -a, which is a gnu extension. cp -RPp is the SuSv3 and POSIX way.
another way of doing it in a POSIX/SuSv3 environment is using pax. e.g. pax -rw -pe foo* bar* /mnt/root
or if you lack pax, tar -cf - foo | (cd /mnt/root; tar -xf -)
xs@kittenz.org writes:
Richard Kettlewell wrote:
"cp -a" should work fine. Other possible invocations of cp might well cause problems, and AFAIK all the non-GNU versions of cp don't have the feature at all...
they do. SuSv3 has it -- just not as -a, which is a gnu extension. cp -RPp is the SuSv3 and POSIX way.
K3wl.
another way of doing it in a POSIX/SuSv3 environment is using pax. e.g. pax -rw -pe foo* bar* /mnt/root
or if you lack pax, tar -cf - foo | (cd /mnt/root; tar -xf -)
Should be "cd /mnt/root && tar -xf -": if the cd fails, you don't want to do the unpack half. (You probably won't be running with "set -e" in an interactive shell.)
xs@kittenz.org writes:
Richard Kettlewell wrote:
"cp -a" should work fine. Other possible invocations of cp might well cause problems, and AFAIK all the non-GNU versions of cp don't have the feature at all...
they do. SuSv3 has it -- just not as -a, which is a gnu extension. cp -RPp is the SuSv3 and POSIX way.
...in fact looking at the spec I can't see anything about -P which guarantees hard links to be preserved, which is part of the requirement (and part of what GNU cp -a does). Indeed it says:
in particular, pax maintains the hard-link structure of the hierarchy, while cp does not.
i.e. POSIX cp is not up to the job.
Richard Kettlewell wrote:
...in fact looking at the spec I can't see anything about -P which guarantees hard links to be preserved, which is part of the requirement (and part of what GNU cp -a does). Indeed it says:
in particular, pax maintains the hard-link structure of the hierarchy, while cp does not.
i.e. POSIX cp is not up to the job.
ah! i apologise. the man page for gnu cp i have access to makes no mention of hard links, just symlinks for -d, but the info page does mention hard links. so you are indeed correct. sorry for wasting your time.
Steve Fosdick fozzy@pelvoux.demon.co.uk wrote:
cp -a [b-l]* [o-t]* v* /mnt/root
Do you know if this is a bash-ism or do all POSIX sh do ranges like that?