Linux Cloning a bootable USB stick

Discussion in 'Software' started by Cleggmeister, 20 Feb 2012.

  1. Cleggmeister

    Cleggmeister Of reasonable knowledge...

    Joined:
    12 Oct 2009
    Posts:
    1,140
    Likes Received:
    22
    Hi folks,

    I recently started running a N40L server with Openmediavault. All is groovy but I learned that I shouldn't be running a USB pen drive as the boot/OS disc since it'll eventually die due to the ongoing disc writes the OS requires.

    So, I'd like to make another replica USB drive to back mine up, for use until I source a cheap HDD for OS purposes.

    When I put the OS USB drive into my Win7 machine it's not recognised - I guess the filesystem is not compatible. So, since I'm also running a Linux distro on my server I guess there's a clever command I can run to create a clone???

    Any thoughts and advice welcome!

    Cleggy.
     
  2. RedFlames

    RedFlames ...is not a Belgian football team

    Joined:
    23 Apr 2009
    Posts:
    13,800
    Likes Received:
    2,177
    straight copy:

    Code:
    dd if=/dev/sda1 of=/dev/sda2
    substitute sda1 and sda2 for source and destination respectively

    save to file:

    Code:
    dd if=/dev/sda1 of=~/filename
    replace 'filename' with file name of choice

    restore from file:

    Code:
    dd if=~/filename of=~/dev/sda1
    replace 'filename' with file name of choice

    all of these have to be done as root.
     
    Cleggmeister likes this.
  3. Cleggmeister

    Cleggmeister Of reasonable knowledge...

    Joined:
    12 Oct 2009
    Posts:
    1,140
    Likes Received:
    22
    Rep is en route, many thanks!

     
  4. WTF_Shelley

    WTF_Shelley The picture is wheeljack

    Joined:
    6 Apr 2005
    Posts:
    185
    Likes Received:
    5
    Just remember to do this from an other machine so your not DDing a live mount system.

    Also if you want to copy all the info off the drive including MBR and other partitions use the drive letter not the number
    Code:
    dd if=/dev/sda of=/dev/sdb
    You can also directly compress is to a .tar.gz file with magic linux pipe goodnes ;)
    Code:
    dd if=/dev/sda | gzip > ~/sda1.dd.gz
     

Share This Page