Copy entire file system hierarchy from one drive to another
--
Music by Eric Matyas
https://www.soundimage.org
Track title: City Beneath the Waves Looping
--
Chapters
00:00 Question
00:34 Accepted answer (Score 43)
01:07 Answer 2 (Score 292)
02:08 Answer 3 (Score 139)
02:41 Answer 4 (Score 9)
03:34 Thank you
--
Full question
https://superuser.com/questions/307541/c...
Accepted answer links:
http://linuxdocs.org/HOWTOs/mini/Hard-Di...
Answer 2 links:
[rsync]: http://linux.die.net/man/1/rsync
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#linux #filesystems
#avk47
ANSWER 1
Score 309
What you want is rsync.
This command can be used to synchronize a folder, and also resume copying when it's aborted half way. The command to copy one disk is:
rsync -avxHAX --progress / /new-disk/
The options are:
-a : all files, with permissions, etc..
-v : verbose, mention files
-x : stay on one file system
-H : preserve hard links (not included with -a)
-A : preserve ACLs/permissions (not included with -a)
-X : preserve extended attributes (not included with -a)
To improve the copy speed, add -W
(--whole-file
), to avoid calculating deltas/diffs of the files. This is the default when both the source and destination are specified as local paths, since the real benefit of rsync's delta-transfer algorithm is reducing network usage.
Also consider adding --numeric-ids
to avoid mapping uid/gid values by user/group name.
ANSWER 2
Score 160
Michael Aaron Safyan's answer doesn't account for sparse files. -S
option fixes that.
Also this variant doesn't spam with the each file progressing and doesn't do delta syncing which kills performance in non-network cases.
Perfect for copying filesystem from one local drive to another local drive.
rsync -axHAWXS --numeric-ids --info=progress2
ACCEPTED ANSWER
Score 45
I often use
> cp -ax / /mnt
Presuming /mnt is the new disk mounted on /mnt and there are no other mounts on /.
the -x keeps it on the one filesystem.
This of course needs to be done as root or using sudo.
This link has some alternatives, including the one above
http://linuxdocs.org/HOWTOs/mini/Hard-Disk-Upgrade/copy.html
ANSWER 4
Score 10
Like Michael Safyan suggests above, I've used rsync
for this purpose. I suggest using some additional options to exclude directories that you probably don't want to copy.
This version is fairly specific to Gnome- and Debian/Ubuntu-based systems, since it includes subdirectories of users' home directories which are specific to Gnome, as well as the APT package cache.
The last line will exclude any directory named cache/Cache/.cache, which may be too aggressive for some uses:
rsync -WavxHAX --delete-excluded --progress \
/mnt/from/ /mnt/to/
--exclude='/home/*/.gvfs' \
--exclude='/home/*/.local/share/Trash' \
--exclude='/var/run/*' \
--exclude='/var/lock/*' \
--exclude='/lib/modules/*/volatile/.mounted' \
--exclude='/var/cache/apt/archives/*' \
--exclude='/home/*/.mozilla/firefox/*/Cache' \
--exclude='/home/*/.cache/chromium'
--exclude='home/*/.thumbnails' \
--exclude=.cache --exclude Cache --exclude cache