I have two unix partitions under debian which I would like to merge (disk space problems :/). What would be the easiest way to do it? I think it would be best to tar or copy files from one partition to the other, delete one and resize the other. I will use parted to resize but how should I copy the files? There are links, permissions and devices which need to be moved without change.
+2
A:
You could run the following (as root) to copy the files. It works for symlinks, devices and ordinary files.
cd /partition2
tar cf - . | ( cd /partition1 && tar xf - )
Another way is to use cpio, but I never remember the correct syntax.
Anders Westrup
2008-12-10 10:11:07
Matt Gardner
2009-04-22 15:52:15
+1
A:
Since this is Debian with GNU fileutils, cp --archive
should work fine.
cp --archive --sparse=always --verbose --one-file-system --target-directory=/TARGET /ORIGIN
If for some reason you’d want to go via GNU tar
, you’d need to do something like this:
cd /origin
find . -xdev -depth -not -path ./lost+found -print0 \
| tar --create --atime-preserve=system --null --files-from=- \
--format=posix --no-recursion --sparse \
| { cd /target; tar --extract --overwrite --preserve-permissions --sparse; }
(I’ve done this so many times that I’ve got a file with all these command lines for quick reference.)
Warning: Using GNU "tar
" will not copy POSIX ACLs; you'll need to use either the above "cp --archive
" method or "bsdtar":
mkdir /target
cd /origin
find . -xdev -depth -not -path ./lost+found -print0 \
| bsdtar -c -n --null -T - --format pax \
| { cd /target; bsdtar -x -pS -f -; }
Teddy
2009-01-13 21:09:04