Ho kopitsa li-volumes ho litsamaiso tsa polokelo ka seva sa Linux ho sebelisa XCOPY

Hoa etsahala hore o hloka ho fumana kopi e feletseng ea molumo ka har'a mokhoa o le mong oa polokelo ea data (DSS), eseng setšoantšo, clone, empa molumo o feletseng. Empa tsamaiso ea polokelo ha e lumelle kamehla hore sena se etsoe ka hare ho sebelisa mekhoa ea eona. Ho bonahala eka khetho e le 'ngoe feela ke ho kopitsa ka seva, empa tabeng ena palo eohle ea data e tla khannoa ka seva ka boeona, marang-rang ho ea tsamaisong ea polokelo le likoung tsa polokelo, ho kenya likarolo tsena kaofela. Empa ho na le litaelo tsa SCSI tse ka u lumellang ho etsa ntho e 'ngoe le e' ngoe ka har'a tsamaiso ea polokelo ka boeona, 'me haeba tsamaiso ea hau e tšehetsa VAAI ho tloha VMware, joale e batla e le 100% hore taelo ea XCOPY (EXTENDED COPY) e tšehetsoe, e bolellang sehlopha seo le ho se etsa. moo o ka kopitsang teng, ntle le ho kenya tšebetsong seva le marang-rang.

Ho bonahala eka ntho e 'ngoe le e' ngoe e lokela ho ba bonolo, empa ha kea ka ka fumana mangolo a seng a lokiselitsoe hang-hang, kahoo ke ile ka tlameha ho tsosolosa lebili. Linux e khethiloe bakeng sa seva ea OS, 'me taelo ea ddpt (http://sg.danny.cz/sg/ddpt.html) e khethiloe e le sesebelisoa sa ho kopitsa. U sebelisa motsoako ona, u ka kopitsa mefuta efe kapa efe ho tsoa ho OS leha e le efe, kaha ho kopitsa ho etsahala thibela-ka-block ka lehlakoreng la tsamaiso ea polokelo. Kaha hoa hlokahala ho kopitsa li-block ka li-block, 'me palo ea li-blocks e tlameha ho baloa, taelo ea blockdev e ne e sebelisetsoa ho bala palo ea liphetolelo tse joalo. Boholo ba boholo ba block bo fumanoe ka liteko; ddpt ha e hlile ha e sebetse ka block e kholo. Sephetho e bile sengoloa se latelang se bonolo:

#!/bin/bash
# first parameter = input device
# second parameter = output device
# device size must be the same
# changing bs variable can reduce speed, max speed should be at bs=32768. 32768 is max setting, lower settings should be calculated dividing by 2

set -o nounset
bs=32768
s=`blockdev --getsz $1`
i=0
while [ $i -le $s ]
do
ddpt of=$2 bs=512 oflag=xcopy,direct if=$1 iflag=xcopy,direct count=$bs verbose=-1 skip=$i seek=$i
i=$(( $i+$bs ))
done

Ha re hlahlobeng hanyane! Ha e le e nyane, faele ea 1TB ha ea ka ea etsoa kapele mme ea hlahlojoa ke md5sum :)

root@sales-demo-05:/home/vasilyk# blockdev --getsz /dev/mapper/mpathfs
2516582400
root@sales-demo-05:/home/vasilyk# blockdev --getsz /dev/mapper/mpathfr
2516582400
root@sales-demo-05:/home/vasilyk# mount /dev/mapper/mpathfs /xcopy_source/
mount: /xcopy_source: wrong fs type, bad option, bad superblock on /dev/mapper/mpathfs, missing codepage or helper program, or other error.
root@sales-demo-05:/home/vasilyk# mkfs /dev/mapper/mpathfs
mke2fs 1.44.1 (24-Mar-2018)
Discarding device blocks: done
Creating filesystem with 314572800 4k blocks and 78643200 inodes
Filesystem UUID: bed3ea00-c181-4b4e-b52e-d9bb498be756
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
        4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968,
        102400000, 214990848

Allocating group tables: done
Writing inode tables: done
Writing superblocks and filesystem accounting information: done

root@sales-demo-05:/home/vasilyk# mount /dev/mapper/mpathfs /xcopy_source/
root@sales-demo-05:/home/vasilyk# ls -l /xcopy_source/
total 16
drwx------ 2 root root 16384 Aug 19 15:35 lost+found
root@sales-demo-05:/home/vasilyk# head -c 1T </dev/urandom > /xcopy_source/1TB_file
root@sales-demo-05:/home/vasilyk# ls -l /xcopy_source/
total 1074791444
-rw-r--r-- 1 root root 1099511627776 Aug 19 17:25 1TB_file
drwx------ 2 root root         16384 Aug 19 15:35 lost+found
root@sales-demo-05:/home/vasilyk# umount /xcopy_source
root@sales-demo-05:/home/vasilyk# mount /dev/mapper/mpathfr /xcopy_dest/
mount: /xcopy_dest: wrong fs type, bad option, bad superblock on /dev/mapper/mpathfr, missing codepage or helper program, or other error.
root@sales-demo-05:/home/vasilyk# cat xcopy.sh
#!/bin/bash
# first parameter = input device
# second parameter = output device
# device size must be the same
# changing bs variable can reduce speed, max speed should be at bs=32768. 32768 is max setting, lower settings should be calculated dividing by 2

bs=32768
s=`blockdev --getsz $1`
i=0
while [ $i -le $s ]
do
ddpt of=$2 bs=512 oflag=xcopy,direct if=$1 iflag=xcopy,direct count=$bs verbose=-1 skip=$i seek=$i
i=$(( $i+$bs ))
done
root@sales-demo-05:/home/vasilyk# time ./xcopy.sh /dev/mapper/mpathfs /dev/mapper/mpathfr
real    11m30.878s
user    2m3.000s
sys     1m11.657s

Ho ne ho etsahala eng tsamaisong ea polokelo ka nako eo:

Ho kopitsa li-volumes ho litsamaiso tsa polokelo ka seva sa Linux ho sebelisa XCOPY
Ha re tsoeleng pele ka Linux.

root@sales-demo-05:/home/vasilyk# mount /dev/mapper/mpathfr /xcopy_dest/
root@sales-demo-05:/home/vasilyk# ls -l /xcopy_dest/
total 1074791444
-rw-r--r-- 1 root root 1099511627776 Aug 19 17:25 1TB_file
drwx------ 2 root root         16384 Aug 19 15:35 lost+found
root@sales-demo-05:/home/vasilyk# mount /dev/mapper/mpathfs /xcopy_source/
root@sales-demo-05:/home/vasilyk# md5sum /xcopy_source/1TB_file
53dc6dfdfc89f099c0d5177c652b5764  /xcopy_source/1TB_file
root@sales-demo-05:/home/vasilyk# md5sum /xcopy_dest/1TB_file
53dc6dfdfc89f099c0d5177c652b5764  /xcopy_dest/1TB_file
root@sales-demo-05:/home/vasilyk#

Tsohle li tsamaile, empa leka 'me u sebelise ka kotsi ea hau! Joalo ka molumo oa mohloli, ho molemo ho nka linepe, bakeng sa ho qala.

Source: www.habr.com

Eketsa ka tlhaloso