TWL's Algorithms

Archive for May, 2015

Clone a hard disk to two or more hard disks simultaneously

Clone to two hard disks at once!

nohup dd bs=1M if=/dev/sdc | tee >(dd bs=1M of=/dev/sda) | dd bs=1M of=/dev/sdb &

To clone to more hard disks, pipe to more tee >(dd bs=1M of=/dev/sda) in between. Just make sure to end the command with dd, to prevent the output from being displayed in the terminal.

E.g. three targets:
nohup dd bs=1M if=/dev/sda | tee >(dd bs=1M of=/dev/sdb) | tee >(dd bs=1M of=/dev/sdc) | dd bs=1M of=/dev/sdd &

>() construct is a shell feature that allows an output command to be used instead of an output file. The shell creates a temporary file name and substitutes it in place of that expression. The command sending the output will write to the temporary file, and the output will be redirected to the standard input of whatever command is inside the parenthesis.

Linux tweaks

These are the modifications I made prior to using vim, especially over a SSH connection.

Show syntax in vim
Open the file ~/.vimrc and enter the line:
syntax on

Show colours over ssh connection
Append this line in ~/.bashrc:
export TERM=xterm

Burning windows 7 iso onto a bootable usb and install from it

The following steps work for installing Windows 8 from a usb drive too.

First, you must format the usb drive with NTFS format.

  1. Open Command Prompt.
  2. Type diskpart and press enter.
  3. Type list disk to see the disks that you have.
  4. Type select disk 0, replacing 0 with the disk number of your usb drive (look at the disk size as a hint).
  5. Type clean.
  6. Type create partition primary
  7. Type select partition 1
  8. Type active to mark it as the active partition.
  9. Type format fs=ntfs quick
  10. Type exit

After that, mount the Windows 7 installer iso file through Daemon Tools.

Then copy everything in the virtual drive of the iso file into your newly formatted usb drive.

Plug the usb drive into your target pc to install windows 7.

Make sure that the pc boots from the usb drive by setting the boot options or bios accordingly.