$linuxcli.in _    [commands]    [tips & tricks]    [manpage]    [ESXi CLi]    [what is my ip?]    [pingme!]    [BIOS lock code]    [Code repo]


{

Clone hard drive in a file with high compression

}

 dd command is use to copy        xz has the capacity to compress
  | the source disk and its       the data into highest compression
  | path is mention under          ratio.
  | "if" switch.   /	            |
  |          _____/                 |
  |         /                       |      -9e is the highest compression level
  |        /                        |      which require more resource compare
  |       /\                        |      to other levels.
  |      /  \                       |     /
  |     /    \                      |    /
  |    /      \                     |   /
# dd if=/dev/sdX status=progress | xz -9e > sdX.img.xz
                 /                        | /
                /                         |/
               /                          |
  progress option in status         redirect output
  switch will show the current      into a file in
  progress status of data write     .xz extenstion
  on standard output.               that will help
                                    to identify
                                    when it is
                                    require to
				    decompress.

{ How to restore from same file. }

 xzcat decompress xz format          progress option in status
 file in standard output.            switch will show the current
   |                                 progress of data writing on
   |   Backup file, which is         target device along with the
   |   source file to restore.       data transfer speed.
   |          |                         /
   |          |                        /
   |          |                       /
# xzcat sdX.img.xz | dd of=/dev/sdX status=progress
                  /   \  |
                 /     \ |
 Pipe to forward the    \|
 standard output to      \
 next command i.e. dd    dd command will copy
                         data from standard input
                         and dump it into target
                         device which path is
                         mention in "of" switch.

Last updated on 18 February 2025 6:20 am IST