zeldor.biz

Linux, programming and more

Copyright © 2023
Log in

Remote Mirroring with nc and dd

November 13, 2013 by Igor Drobot Leave a Comment

Copy

Migration from Freenas all ZFS volumes to another machines lvm is pretty simple.

create on you new machine logical volume and start netcat which will write everything it receives to the new LVM of your choice:

# Source box

1
dd bs=16M if=/dev/disk/by-path/iscsi-mysql-lun-0 | nc 192.168.1.254 19000

dd bs=16M if=/dev/disk/by-path/iscsi-mysql-lun-0 | nc 192.168.1.254 19000

# Destination box (192.168.1.254)

1
nc -l -p 19000|dd bs=16M of=/dev/vg0/mysql-data

nc -l -p 19000|dd bs=16M of=/dev/vg0/mysql-data

Filed Under: Linux Tagged With: dd, FreeNAS, LVM, nc, netcat, ZFS

Progress bar for DD

January 21, 2011 by Igor Drobot Leave a Comment


I am still searching for a perfect progress bar for DD, I know a dirty trick[*1] – put DD to background an sending “USR1” signal to bring it to show a progress – I hate this solution!

This one is not so dirty, but you have only the done progress and transfer speed.

1
2
dd if=/opt/wap/Backup.tib | pv | ssh -c arcfour id@tower "dd of=/home/id/Backup.tib"
1.94GB 0:01:15 [30.1MB/s] [<=>

dd if=/opt/wap/Backup.tib | pv | ssh -c arcfour id@tower "dd of=/home/id/Backup.tib" 1.94GB 0:01:15 [30.1MB/s] [<=>

Dirty trick:
Only local way!

1
2
dd if=/opt/wap/Backup.tib of=file.img bs=4KB& pid=$!
while true; do kill -USR1 $pid && sleep 1 && clear; done

dd if=/opt/wap/Backup.tib of=file.img bs=4KB& pid=$! while true; do kill -USR1 $pid && sleep 1 && clear; done

Filed Under: Bash, Debian, Linux Tagged With: dd, progress bar, transfer

Data Recovery

October 5, 2010 by Igor Drobot Leave a Comment

Each of you looses already some important files like photos or important documents.
After a normal Windows crash it’ s not a problem to get all your data back.
I show you some methods to get your data back.

These two examples are taken directly from the ddrescue info pages.

Example 1: Rescue an ext3 partition in /dev/hda2 to /dev/hdb2

1
2
3
dd_rescue /dev/hda2 /dev/hdb2 -l logfile.txt
e2fsck -v -f /dev/hdb2
mount -t ext3 -o ro /dev/hdb2 /mnt

dd_rescue /dev/hda2 /dev/hdb2 -l logfile.txt e2fsck -v -f /dev/hdb2 mount -t ext3 -o ro /dev/hdb2 /mnt

If you have a damaged hard disk /dev/sda1 and you have an empty space hard disk /dev/sdb1 You can copy data from /dev/sda1 to /dev/sdb1 use the following commnd

1
2
3
dd_rescue /dev/sda1 /dev/sda2/backup.img
# To mount use:
mount -t ext3 /dev/sda2/backup.img mnt/ -o loop

dd_rescue /dev/sda1 /dev/sda2/backup.img # To mount use: mount -t ext3 /dev/sda2/backup.img mnt/ -o loop

Example 2: Rescue a CD-ROM in /dev/cdrom

1
ddrescue -b 2048 /dev/cdrom cdimage logfile

ddrescue -b 2048 /dev/cdrom cdimage logfile

Filed Under: Bash, Debian, Linux, Ubuntu Tagged With: dd, dd_rescue. restore data, HDD recovery