Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am getting a SSD and I'd like it to become my new Linux boot drive. However, it is smaller than my current hard drive's root Linux partition, so I'd like to copy over the filesystem and exclude some directories (which I'll leave on another hard drive). So I can't just clone the partition with parted or similar because it is too big.

I want to make sure all the data, metadata, links and such are preserved. That seems to exclude "cp" because it doesn't preserve all the metadata and link information.

The two basic techniques I've been able to identify seem to be something like:

 find / -xdev -print0 | cpio -pa0V /mnt/dst


 rsync -avP -H -S --numeric-ids / /mnt/dst

Can anyone chime in with what they've used in the past, whether one of these or a different method, or if they see any flaws in these approaches.

share|improve this question

Not sure what you mean by metadata. Inode numbers? A cp -a will copy all the permissions, links, etc. If you want to exclude things I would use rsync's --exclude option. If you have sparse files (probably you don't unless you are doing virtualization), then you should use the -S option if you are going to use rsync.

If its your boot drive then you'll also need to reinstall your bootloader, etc. and possibly configure your partitions.

share|improve this answer

Overall, the approach of using find and cpio should be fine (I tend to use find, xargs and tar, but that is more caused by existing knowledge of those tools). Generally, tar and cpio are made for backing up and as such they should store everything needed. However there might be some meta data they miss to include (ACL like SELinux labels), there is star that apparently have better support for this. I would expect rsync to be better than cp but worse than star in handling additional meta data.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .