Creating an usb-stick of the current system

Discussion in 'Linux' started by Monkey, Jul 23, 2008.

  1. Monkey

    Monkey

    Joined:
    Jul 14, 2008
    Messages:
    8
    Likes Received:
    0
    Location:
    Germany
    Hi again,

    i have an 4GB USB-stick on which I want to create a backup of my (highly customized) system. I wan't to be able to boot from the usb-stick, and copy everything back on the ssd for the case, that I misconfigured everything... So I copied (cp -a) everything to the usb-stick and installed grub onto it... But the system is always booting from the internal ssd...

    Has anyone already created an usb-stick from the system and can give me a howto (especially from the grub-part)?

    thanks,
    Monkey
     
    Monkey, Jul 23, 2008
    #1
  2. Monkey

    Guest Guest

    Im also interested in this backup. Thanks
     
    Guest, Jul 23, 2008
    #2
  3. Monkey

    carterleonard

    Joined:
    Jul 10, 2008
    Messages:
    25
    Likes Received:
    0
    Me too me too!!!! This is very important to us! Anyone?....
     
    carterleonard, Jul 23, 2008
    #3
  4. Monkey

    adipradana

    Joined:
    Jul 28, 2008
    Messages:
    26
    Likes Received:
    0
    adipradana, Aug 13, 2008
    #4
  5. Monkey

    edgecrush3r

    Joined:
    Aug 12, 2008
    Messages:
    53
    Likes Received:
    0
    Assuming you did make the USB stick bootable.
    Did you added the boot entry in the /boot/grub/menu.lst ?
    Dont forget to select the USB from the bios boot menu (F12)

    Cheers,
    Tony
     
    edgecrush3r, Aug 18, 2008
    #5
  6. Monkey

    rbil

    Joined:
    Aug 14, 2008
    Messages:
    730
    Likes Received:
    0
    Location:
    The Wet Coast, Canada
    That's a good start, but Partimage only does one hd partition at a time and doesn't deal with the MBR. A better choice, imho is to use the linux command: dd and make a backup of the whole Acer SSD drive to an image file.

    Here's a general synopsis of the system I use to do this.

    I have an external 2.5" USB drive and I've partitioned it into 2 partitions. A small one that holds the sysresccd.org stuff mentioned above, making /dev/sdb1 the bootable drive when F12 is pressed and USB is selected. The remaining part of this HD is where I can keep backups along with anything else that I want.

    So I attached the external hd to the Acer, start the Acer, hit F12 and select to boot from the external USB drive. This starts to bootup and a MR: prompt is presented. Hit "A" key. Then hit "1" and the system boots the systemrescue system. Just hit enter when questioned to go with the bootup prompts unless you need to setup the keyboard for something other than US English. Eventually you're at a root prompt. Once, there, here are the steps to backup the WHOLE SSD drive:

    1) You'll need to mount the 2nd partition of the ext hd so that you can write the image file to it...

    mount -t auto /dev/sdb2 /mnt/windows

    I'm using /mnt/windows as the mount point, just because that directory already exists when the system is booted up.

    2) If you like you can navigate now to /mnt/windows and create a directory there if one doesn't already exist where you want the image file saved into.

    cd /mnt/windows
    mkdir Backup
    ls -l to check the successful creation of ths directory.

    3) Now we're going to backup all of the 8GB SSD (which includes the MBR, 1st partition and swap partition) to an image file within /mnt/windows/Backup ...

    And we're going to compress the image file as it's being created (by piping the dd through the gzip command) to keep it smaller than the 8GB it would be if dd alone was used ...

    dd if=/dev/sda | gzip > /mnt/windows/Backup/hdimage.gz

    After entering the above command and hitting Enter, the cursor will move down and NOTHING will show you any progress. Just be patient, can take 10 or so minutes to write the image file and you'll be notified when it completes.

    4) That's it, you have the SSD drive backed up.

    Now you want to shutdown your systemrescue session:

    shutdown -h now

    Unplug your ext drive when the computer has shutdown. End of what you need to do, for a FULL backup.

    Now, in the event you want to RESTORE this image back to the SSD drive, overwriting everything on the drive, you'll do this:

    1) Connect your ext hd to the Acer and start it up, hitting F12 to boot from it.
    At the MR: prompt, type A, then type 1 to indicate bootup from the first partition on that drive

    2) As above Enter your way through the bootup prompts, again only needing to change what keyboard you're using if not US English.

    3) When you reach the Linux root prompt, mount the 2nd partition where the image file is:

    mount -t auto /dev/sdb2 /mnt/windows

    Navigate to the directory where you saved your image file, in my example above, you'd do:

    cd /mnt/windows/Backup

    Now let's start the restore which will overwrite your SSD with the contents of your backup image file:

    gzip -dc /mnt/windows/Backup/hdimage.gz | dd of=/dev/sda

    in the above line gzip is unzipping the gz file and piping it to the dd command which is writing it to your SSD drive.

    When it finishes, and this can take a number of minutes, you'll be back at the prompt and your SSD drive will be restored.

    4) shutdown the system:

    shutdown -h now

    OK, here's some tips on this whole thing. Once you've created this setup on an external USB hard drive, when you plug it into a running Acer, you can access these partitions. You can use your regular Acer system to add directories to that second storage partition, so you could for example add: Backup2 which you could use to deposit another image file in a later backup session following the instructions above. Just replace /mnt/windows/Backup with /mnt/windows/Backup2 and have the second later image stored there.

    NOTE: this whole procedure is assuming that you have just the one external USB hard drive plugged in. If you have some other cards/USB drives plugged in, then the storage partition may not be assigned /dev/sdb2. Make SURE that you know how that partition has been assigned. The command: fdisk -l (that's a lower case L) will tell you what disk devices are recognized and how they're assigned.

    Hope this helps someone.

    Cheers.
     
    rbil, Aug 19, 2008
    #6
  7. Monkey

    Sid

    Joined:
    Jul 22, 2008
    Messages:
    632
    Likes Received:
    0
    Location:
    UK - (most locations)
    Assuming you had an 8gb SSD.
    Wouldn't it be possible for you to specify the whole SSD drive to be copied to an 8gb usb stick, using dd to copy the whole thing, All partitions would be copied in one go, I assume the result would be bootable?
     
    Sid, Aug 19, 2008
    #7
  8. Monkey

    rbil

    Joined:
    Aug 14, 2008
    Messages:
    730
    Likes Received:
    0
    Location:
    The Wet Coast, Canada
    It sounds like you're talking about cloning the SSD drive to a USB key. Yes, that could be easily done using dd, however I wouldn't count on the key being bootable because the key would have the SSD's drive assignment in its Grub. (wrong /dev) The SSD is recognized as /dev/sda and the key would be /dev/sdb.

    Cheers.
     
    rbil, Aug 19, 2008
    #8
  9. Monkey

    Sid

    Joined:
    Jul 22, 2008
    Messages:
    632
    Likes Received:
    0
    Location:
    UK - (most locations)
    Very true about booting from the cloned USB.

    The concept was to clone (snapshot) the SSD, if the SSD fails, then I boot with a known bootable Linux USB, then dd the cloned USB back onto the SSD.

    I use this as a snapshot before loading new apps or messing with the system, it gives me a known base to return to.
    Of course I could dd to a compressed ISO image, but then I have to think harder :)
     
    Sid, Aug 20, 2008
    #9
  10. Monkey

    zaphod

    Joined:
    Jul 10, 2008
    Messages:
    156
    Likes Received:
    0
    Location:
    France
    Thanks for the tips on backing up with dd. Having read your post I booted my A1 off an Xubuntu LiveUSB that I already had and used dd without gzip to backup /dev/sda to a folder on an external HDD. You were right about being patient; it took me a lot longer than 10 minutes, more like 1 hour :!:
     
    zaphod, Aug 23, 2008
    #10
  11. Monkey

    rbil

    Joined:
    Aug 14, 2008
    Messages:
    730
    Likes Received:
    0
    Location:
    The Wet Coast, Canada
    That seems like a very long time to backup the SSD. Maybe that livecd is a bit of a resource hog? Running top should give you some idea about what's going on. You might consider either just booting to a command prompt without loading the GUI desktop, or killing the gui before running the dd command? I'm not sure this is possible with the livecd? Maybe sudo /etc/init.d/gdm stop will do it?

    Cheers.
     
    rbil, Aug 25, 2008
    #11
  12. Monkey

    z0s0

    Joined:
    Aug 19, 2008
    Messages:
    11
    Likes Received:
    0
    If the external drive you are backing up to is NTFS, then the write speed is very slow.

    I'm doing a backup now to an ext3 drive, gzipping on the fly, and it's running at 10MB/s.

    I'm also testing another backup/restore approach, which simply tar's everything from the root partition onto a bootable USB drive, which you then should be able to untar later to restore system state.

    We'll see ;-)
     
    z0s0, Aug 28, 2008
    #12
  13. Monkey

    zaphod

    Joined:
    Jul 10, 2008
    Messages:
    156
    Likes Received:
    0
    Location:
    France
    @rbil
    I think you are right. Booting a full Xubuntu system is probably a bit excessive for executing a single terminal command :oops:
    I have subsequently created a SystemRescueCD LiveUSB which I will use next time.

    @z0s0
    My external hard disk is indeed ntfs formatted. Is that alone enough to reduce the transfer rate down to 2.2MB/s ?
     
    zaphod, Aug 29, 2008
    #13
  14. Monkey

    hiker_jon

    Joined:
    Aug 24, 2008
    Messages:
    28
    Likes Received:
    0
    Hi,

    I need a little Linux help. I have a USB disk drive (not pen drive) that I would like to use for backups using dd. I also have the system recovery iso (not the Linpus one, that failed to work when I put it onto a pen drive) and I have two partitions on the USB disk. The first partition is bootable (has an * in fdisk -l) so I just tried copying using dd the iso to /sdb1. Didn't work. I tried the same sort of thing with an iso for pendrivelinux. It also didn't work. What do I do to get some sort of bootable linux system on the first partition?
     
    hiker_jon, Aug 30, 2008
    #14
  15. Monkey

    rbil

    Joined:
    Aug 14, 2008
    Messages:
    730
    Likes Received:
    0
    Location:
    The Wet Coast, Canada
    rbil, Aug 30, 2008
    #15
  16. Monkey

    hiker_jon

    Joined:
    Aug 24, 2008
    Messages:
    28
    Likes Received:
    0
    Hi,

    I followed the instructions there (the from windows version), but when I tried to boot, the disk did not appear. After doing the instruction the partition was no longer bootable.
     
    hiker_jon, Aug 31, 2008
    #16
  17. Monkey

    caos30

    Joined:
    Aug 29, 2008
    Messages:
    1
    Likes Received:
    0
    @hiker_jon: i tried too for recovering the original system configuration using the recovery disk, and it faulted until 5 tryings!!! I used the DVD recovery disk that was included with the A1, putting it in an other PC with dvd lector. In that PC i booted from dvd and choosed the second option: make a USB recovery stick (or something like this). Well, previously i had put a 2 Gb SD card within a mini-lector-card USB inserted in the PC. The process of USB recovery creation toke no more than 15 minuts. Once created it, i inserted this "USB memory card bootable" in the A1 and booted (changing with F12 the boot devices order). Then appeared a simple wizzard to recover the A1.The recovery process was interrupted with a "miesterious error" some times (4-5). I tried to repeat the reboot and re-recovery with the same USB memory, but it not functioned. Also i repeat the making again of the recovery USB, some times. Finally (i don't rememeber how many tries i did) the process was completely succesful! uffff.... :shock:

    I would want to share my experience with all you, hoping to help someone... TRY IT AGAIN!!! ;)

    SERGI
     
    caos30, Aug 31, 2008
    #17
  18. Monkey

    crispian

    Joined:
    Aug 30, 2008
    Messages:
    12
    Likes Received:
    0
    Thanks for this thread- I was looking for a way to save a complete image of my system now that I have it tweaked "just so". Now I can run live update without worrying that something will screw up making me have to install from scratch and have to tweak it all again.

    I couldn't get sysresccd to boot from a usb stick, so I used Damn Small Linux (dsl) on a 512MB partition (fat32) of my 8GB stick and formatted the rest as an ext3 partition.

    I then booted from it fine, and ran
    Code:
    dd if=/dev/hdc | gzip > /Backup/9-9-08/hdimage.gz
    (dsl sees the SSD as hdc, and I created a /Backup mount point for the 2nd partion of the USB stick).

    It worked fine, but it took it's time- over an hour- I'm not sure how you got it to run in 10 minutes. The cpu usage didn't seem maxed out and the memory usage stayed low (I have added the extra 1GB for a total of 1.5). And dsl uses FluxBox so I don't think that running it from a desktop should make all that much difference.

    Anyhow, it worked, that's what's important!
     
    crispian, Sep 11, 2008
    #18
  19. Monkey

    rbil

    Joined:
    Aug 14, 2008
    Messages:
    730
    Likes Received:
    0
    Location:
    The Wet Coast, Canada
    Maybe the long time you're experiencing has something to do with writing to a flash key as opposed to an ext. 2.5" hdd, that I'm using? My backups probably take twice as long as I originally stated, but certainly nowhere near an hour. When I first posted these instructions, I started the backup and walked away. Maybe I was gone longer than 10 minutes? :) Didn't seem like it took all that much time. Maybe 20 minutes when I did another backup.

    Cheers.
     
    rbil, Sep 11, 2008
    #19
  20. Monkey

    rbil

    Joined:
    Aug 14, 2008
    Messages:
    730
    Likes Received:
    0
    Location:
    The Wet Coast, Canada
    Wouldn't you know it, but last night I had to resort to a complete restore from my backup. :) Well at least I got real world experience in terms of how long a restore takes with my method. It took around 40 minutes to dd from the ext hdd to the ssd. I guess this is expected as writes are slower on the ssd then are reads. The restore went perfectly, btw.

    Cheers.
     
    rbil, Sep 12, 2008
    #20
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.