Easiest way to merge partitions under debian (unix)?

I have two unix partitions under debian that I would like to merge (disk space problems: /). What's the easiest way to do this? I think it would be better to tar or copy files from one partition to another, delete one and resize the other. I'll use split files to resize, but how do I copy the files? There are links, permissions, and devices that need to be moved unchanged.

+1


source to share


3 answers


To copy the files, you can run the following (as root). It works for symbolic links, devices, and regular files.

cd /partition2
tar cf - . | ( cd /partition1 && tar xf - )

      



Another way is to use cpio, but I never remember the correct syntax.

+2


source


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 want to go through GNU tar

, you 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 gotten a file with all of these commands for quick reference.)

Warning: Using GNU tar

will not " " copy the POSIX ACL; you will need to use either the " cp --archive

" or " bsdtar " method :

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 -; }

      

+2


source


You can also use SquashFS to mirror the partition and copy it. After resizing your second partition, mount the SquashFS image and copy the required files. Be aware that your kernel will need SquashFS support to mount the image.

0


source







All Articles