Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

and:

 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
add comment

2 Answers 2

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
add comment

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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.