Friday, February 6, 2015

use dd command to clone hard drive

Leave a Comment
For examples, use dd command to clone hard drive on linux system

How to determine find out file system type

# df -T
Output
huupv@mailserver:~$ df -T
Filesystem     Type     1K-blocks    Used Available Use% Mounted on
/dev/sdb2      ext4      19548440 1659364  16873012   9% /
udev           devtmpfs    236536       4    236532   1% /dev
tmpfs          tmpfs        49408     300     49108   1% /run
none           tmpfs         5120       0      5120   0% /run/lock
none           tmpfs       247032       0    247032   0% /run/shm

Check block size device 

# blockdev --getbsz /dev/sdb2
Output
4096

Create filesytem format

# mkfs.ext4 /dev/sdb2

Create swap partition

# mkswap /dev/sdb3

Enable swap partition

# swapon /dev/sdb3

List disk partition 

# lsblk 
Output
huupv@mailserver:~$ sudo lsblk
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda      8:0    0    20G  0 disk
├─sda1   8:1    0   953M  0 part
└─sda2   8:2    0  19.1G  0 part /
sdb      8:16   0    22G  0 disk
├─sdb1   8:17   0   953M  0 part [SWAP]
└─sdb2   8:18   0  19.1G  0 part
sr0     11:0    1   689M  0 rom

How to find uuids of disk

# blkid 
Output
huupv@mailserver:~$ sudo blkid
/dev/sr0: LABEL="Ubuntu-Server 12.04.5 LTS amd64" TYPE="iso9660"
/dev/sda1: UUID="1db9efd1-b0b3-4d89-a4d6-7848caddaa77" TYPE="swap"
/dev/sda2: UUID="e2e91a32-92ee-464d-ae57-1f02a76adde3" TYPE="ext4"
/dev/sdb1: UUID="1db9efd1-b0b3-4d89-a4d6-7848caddaa77" TYPE="swap"
/dev/sdb2: UUID="e2e91a32-92ee-464d-ae57-1f02a76adde3" TYPE="ext4"
or
# ls -l /dev/disk/by-uuid/

Cloning a partition use dd command

# dd if=/dev/sda1 of=/dev/sdb1 bs=512 conv=noerror,sync
Note: of=/dev/sdb1 >= if=/dev/sda1

Cloning an entire partition use dd command

dd if=/dev/sda of=/dev/sdb bs=512 conv=noerror,sync
MBR Total Size

446 + 64 + 2 = 512

Where,
446 bytes - Bootstrap.
64 bytes - Partition table.
2 bytes - Signature.

Link youtube use dd command to clone hard drive bellow :

https://youtu.be/G7VNWFzWgjI

Copyright by: www.linuxoperatingsystem.info http://goo.gl/kMscJ4

0 comments:

Post a Comment