1.Incremental copy
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.
2. Format the new partition’s filesystem as type ext4
mkfs -t ext4 /dev/sdx1
3. Partition a disk
sudo fdisk /dev/sda
4. Get Directory Size
du -hs
5. Free reserved disk space
sudo tune2fs -m 0 /dev/sdb1
6. Recursively counting number of files
find DIR_NAME -type f | wc -l
7. Recursive search for text
grep -rnw '/path/to/somewhere/' -e "pattern"
-r
or-R
is recursive,-n
is line number, and-w
stands match the whole word.-l
(lower-case L) can be added to just give the file name of matching files.- Along with these,
--exclude
or--include
parameter could be used for efficient searching. Something like below:
8. sync + SSH
rsync -as -e “ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null” –info=progress2 –delete-after ./work/ teng@192.168.1.224:/home/teng/work/