Linux dd - 디스크 복제
# 우선 디스크 정보부터 확인
원본 : /dev/sda 대상 : /dev/sdb
[root@Eloquence ~]# fdisk -l
WARNING: fdisk GPT support is currently new, and therefore in an experimental phase. Use at your own discretion.
Disk /dev/sda: 300.0 GB, 300000000000 bytes,
585937500 sectors // 원본 데이터가 저장된 디스크
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: gpt
Disk identifier: F6CA3DE6-556D-492F-AB86-03036A530C7F
# Start End Size Type Name
1 2048 411647 200M EFI System EFI System Partition
2 411648 2508799 1G Microsoft basic
3 2508800 585936895 278.2G Linux LVM
WARNING: fdisk GPT support is currently new, and therefore in an experimental phase. Use at your own discretion.
Disk /dev/sdb: 300.0 GB, 300000000000 bytes, 585937500 sectors // 원본 데이터를 고스란히 물려받을(?) 디스크
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: gpt
Disk identifier: F6CA3DE6-556D-492F-AB86-03036A530C7F
# Start End Size Type Name
# 복제 진행 및 진행상황 모니터링
command :
# dd if=복제 작업의 원본이 되는 디스크 디바이스 이름 of=원본의 내용을 저장할 디스크 디바이스 이름
bs=복제속도
# iostat -m or -d // dd가 진행되는 중간에 세션을 하나 더 띄워서 속도 측정하시면 됩니다.
[root@Eloquence ~]# dd if=/dev/sda of=/dev/sdb bs=512
279+1 records in
279+1 records out
300000000000 bytes (300 GB) copied, 2058.63 s, 146 MB/s // dd 완료되었네요!
[root@Eloquence ~]#iostat -m 2 // MB단위로 2초마다 iostat 값 출력 - 상황에 맞게 옵션값 변경해주세요.
# 결과 확인
[root@localhost ~]# fdisk -l
WARNING: fdisk GPT support is currently new, and therefore in an experimental phase. Use at your own discretion.
Disk /dev/sda: 300.0 GB, 300000000000 bytes, 585937500 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: gpt
Disk identifier: F6CA3DE6-556D-492F-AB86-03036A530C7F
# Start End Size Type Name
1 2048 411647 200M EFI System EFI System Partition
2 411648 2508799 1G Microsoft basic
3 2508800 585936895 278.2G Linux LVM
WARNING: fdisk GPT support is currently new, and therefore in an experimental phase. Use at your own discretion.
Disk /dev/sdb: 300.0 GB, 300000000000 bytes, 585937500 sectors // sda 내용이 sdb에 똑같이 복제된 걸 확인.
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: gpt
Disk identifier: F6CA3DE6-556D-492F-AB86-03036A530C7F
# Start End Size Type Name
1 2048 411647 200M EFI System EFI System Partition
2 411648 2508799 1G Microsoft basic
3 2508800 585936895 278.2G Linux LVM
Linux dd - 디스크 초기화(삭제)
# 두 가지 방법이 있습니다.
① 디스크 데이터 완전 삭제 // 파티션 삭제방법보다 소요시간이 조금 더 깁니다.
② 디스크 파티션 삭제 // 상대적으로 소요 시간이 짧을 수 있습니다.
# ① 디스크 데이터 완전 삭제
command :
# dd if=/dev/zero of=데이터 삭제될 대상 디스크 장치 이름
# dd if=/dev/random of=데이터 삭제될 대상 디스크 장치 이름
[root@Eloquence ~]# dd if=/dev/zero
of=/dev/sdb
279+1 records in
279+1 records out
300000000000 bytes (300 GB) copied, 2058.63 s, 146 MB/s // 데이터 삭제 완료
# ② 디스크 파티션 삭제
command :
# dd if=/dev/zero of=파티션 삭제될 대상 디스크 장치 이름 count=1 bs=속도
or
# dd if=/dev/random
of=파티션 삭제될 대상 디스크 장치 이름 count=1 bs=속도
[root@Eloquence ~]# dd if=/dev/zero of=/dev/sdb count=1 bs=512
279+1 records in
279+1 records out
300000000000 bytes (300 GB) copied, 2058.63 s, 146 MB/s // 파티션 삭제 완료
[root@localhost ~]# fdisk -l
. . . 전략
WARNING: fdisk GPT support is currently new, and therefore in an experimental phase. Use at your own discretion.
Disk /dev/sdb: 300.0 GB, 300000000000 bytes, 585937500 sectors // sdb 데이터 및 파티션이 비었는 걸 확인
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: gpt
Disk identifier: F6CA3DE6-556D-492F-AB86-03036A530C7F
제 주관적인 지식을 통해 작성된 글이며, 틀린 부분이 있다면 의견을 달아주세요.