How to easily clone a (encrypted hard) disk over network (with dd and netcat)

The task was simple: two computers (notebooks). One – we call it A – with a working operating system (Xubuntu) and a new one – we call it B – without operating system. This is how I proceeded:

  1. Create bootable flash drive with in my case Arch-Linux
  2. In the Arch-Linux boot loader, press [TAB] and add “copytoram” to the boot command to load the squashfs image into ram. I needed this because in this case I only had a flash drive at hand. If you have two, you don’t need this.
  3. List network devices:
  4. Assign a IP adress to computer A with:

  5. To identify source disk, list all block devices with:

  6. Prepare the copy operation (do not execute yet!) with

  7. Boot machine B from the same or different flash drive
  8. Assign different IP adress
  9. Identify target device
  10. Prepare the receiving copy operation with

  11. Execute the command on Machine B
  12. Then execute the command on Machine A
  13. Wait until the copying process is completed.
  14. Use at least the Sync command to synchronize corresponding file data in volatile storage and permanent storage
  15. Restart the machine, you are done

How it works/remarks
dd reads the source drive bit by bit into the normal output stream. The output stream is piped to netcat, which sends it over the network to a receiving netcat process (server with -l). Therefore the server must be started first. The server receives the bits and piped them back to dd, which writes them to the target on machine B.

Maybe this is not the best and/or most efficient way, but transfer speed in my case of 75MB/s (poor performance on screenshots is from a setup with two vm’s) is in IHMO very good for this simple setup.

Thanks to pmenke for his support.

Useful Linux/Unix commands

  • How do I find all files containing specific text?
  • How i change the default file permissions (mask that controls file permissions)
  • Untar (unzip) file
  • Copy files via rsync from one host to another

     

Write zeros to a hard drive – Wipe/Erase unused or free space

Windows: Format and write zeros to every sector of the drive.

Windows: Format and write zeros to every sector of the drive. After the first pass write randome numbers.

Windows: Fill free space.

Unix: Fill free space.

Unix: Fill free space on FAT32 drive (4GB limit per file).

To run the process in background see Run command in background on a Synology NAS with nohup

Bugzilla checksetup.pl stops with segmentation fault

After upgrading an openSUSE machine, the Bugzilla installation no longer works. Each run of the checksetup.pl crashes with “segmentation fault”. After updating perl with cpan and some research the solution for the problem was very simple:

  1. Rename the lib folder in the Bugzilla directory
  2. Run ./install-modules –all
  3. Run ./checksetup.pl again

pfSense ipfw rules

Lists zones:

Show rules (Zone ID 2 for example):

Show all tables

Show authenticated/allowed clients (in)

Show authenticated/allowed clients (out)

pfSense 2.2.5 CaptivePortal Patch

Patch for pfSense 2.2.5 to redirect proxy users to the authentification portal.

Diff created with WinMerge.

Install IPKG on a Synology DS415play

I search for a easy guid to install ipkg on my Synology DS415play with Intel Atom CPU. I found a guid by Edward P:

Connect to your NAS as root through SSH
Go to a temporary folder, for example:

Download the bootstrap script:

Make the downloaded script file executable:

Execute the bootstrap script:

Installation should now be completed. To test it, run:

Enjoy.

Erase and overwrite Disk on Synology DiskStation

I wanted to erase and overwrite the data on some hard disks that I need to downgrade my RAID 5 from three 4TB WD Red to only two. The erase function on the webgui doesn’t work – something message like “don’t possible with your drive”. I search and found an alternative:

To identify the disk use fdisk and/or hdparm:

To run the dd command furthermore after disconnection from the SSH connection, use nohup: