Creating an usb-stick of the current system

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

  1. Monkey

    zaphod

    Joined:
    Jul 10, 2008
    Messages:
    156
    Likes Received:
    0
    Location:
    France
    When I did my back-up with dd I didn't pipe through gzip. Can anyone give me an idea of how much smaller than 8GB the backup is with gzip ?
     
    zaphod, Sep 13, 2008
    #21
  2. Monkey

    crispian

    Joined:
    Aug 30, 2008
    Messages:
    12
    Likes Received:
    0
    Mine is 1.9GB.
     
    crispian, Sep 13, 2008
    #22
  3. Monkey

    zaphod

    Joined:
    Jul 10, 2008
    Messages:
    156
    Likes Received:
    0
    Location:
    France
    Thanks. I think I'll have a go at your approach on a 4GB USB key. I'll put SystemRescueCd on one partition and write the backup to a second one. Any particular reason to use ext3 rather than fat32 for the backup partition ?
     
    zaphod, Sep 13, 2008
    #23
  4. Monkey

    crispian

    Joined:
    Aug 30, 2008
    Messages:
    12
    Likes Received:
    0
    For whatever reason I couldn't get get SystemRescueCD to boot (I'm sure I was just doing something stupid), so in the end I put dsl (Damn Small Linux) on a 512MB fat32 partition of my 8GB stick and booted from that. The rest of the stick I formatted as ext3 for the backup for no other reason than habit- that is what I'm used to using when I format partitions for my linux boxes. I don't think it matters what you use as long as you can mount it and write to it when you've booted from the first partition.
     
    crispian, Sep 13, 2008
    #24
  5. Monkey

    zaphod

    Joined:
    Jul 10, 2008
    Messages:
    156
    Likes Received:
    0
    Location:
    France
    I successfully did my backup with a 4GB USB stick. I installed SystemRescueCD in a ~300MB FAT32 partition and formatted the rest of the stick as ext2. Using dd piped to gzip it took ~25 mins and the backup file size was ~2.7GB.
     
    zaphod, Sep 13, 2008
    #25
  6. Monkey

    rbil

    Joined:
    Aug 14, 2008
    Messages:
    730
    Likes Received:
    0
    Location:
    The Wet Coast, Canada
    Congratulations.

    Cheers.
     
    rbil, Sep 14, 2008
    #26
  7. Monkey

    Guest Guest

    No you are not alone. I could not get SystemRescueCD working either. In the end I have got Parted magic working and do everything with that.
     
    Guest, Sep 28, 2008
    #27
  8. Monkey

    rbil

    Joined:
    Aug 14, 2008
    Messages:
    730
    Likes Received:
    0
    Location:
    The Wet Coast, Canada
    I've just created a 4GB flash key that has everything required to backup your current system, as I've outlined earlier in this thread. If someone has a web host I can upload it to, then it can be made available for whoever wants it. The file size is approximately 206.7 MB. Let me know. If I can find a download site for it, I'll post instructions on how to create the 4GB flash key on your system.

    Cheers.
     
    rbil, Sep 29, 2008
    #28
  9. Monkey

    rbil

    Joined:
    Aug 14, 2008
    Messages:
    730
    Likes Received:
    0
    Location:
    The Wet Coast, Canada
    Download 4GB Flash Key Image File - With Instructions

    Instructions for Creating 4GB Flash Key for Backup/Recovery of SSD drive on AAO


    1) Download file 4gbrestoreimage.gz to your home folder (approx. 206MB)

    File Host.Just Free Space.Com Download Link

    After you've downloaded the file to your home directory, open a terminal and do:

    Code:
    cd /mnt/home
    md5sum 4gbrestoreimage.gz 
    The checksum should match: a04644a6f99f33512d051d8c2fc82087 4gbrestoreimage.gz
    If it does, the download was good.

    2) Stick a 4GB flash memory key in a USB port on your Acer

    3) Go into Thunar and unmount the drive

    4) Go back into the terminal and do the following commnand to really confirm the /dev name:

    Code:
    sudo fdisk -l
    If there's no other drive hooked up to USB, it SHOULD be /dev/sdb, BUT make darn sure! (you've been warned)

    5) run the following command to elevate yourself to root:

    Code:
    sudo su -
    (you should now see the prompt: "root@localhost")

    6) Type in the following command and hit ENTER:

    NOTE: This will wipe anything you presently have off your key and replace it with a 300MB FAT32 partition containing the SystemRescueCD and a 3.5GB FAT32 partition that you'll store your backup image on.

    Code:
    gzip -dc /mnt/home/4gbrestoreimage.gz | dd of=/dev/sdb
    (again, MAKE SURE that your flash key is indeed /dev/sdb - see the fdisk command above in step 4)

    After entering the above command, you'll see nothing happening in the terminal, but you'll see the led on the key blinking. It's "burning the image to the key". You'll just need to wait until it completes. When it does, you'll be back at the command prompt. It will have stated:

    Code:
    7827457+0 records in
    7827456+0 records out
    4007857472 bytes (4.0 GB) copied ...
    Takes somewhere around 12 minutes. That's it, your key is prepared.

    7) Shutdown your computer and reboot, hitting F12 and selecting your USB key to boot from.

    8) Follow instructions I've posted on page one of this thread in terms of backing up your SSD drive to /mnt/windows/Backup/hdimage.gz.

    9) I suggest you copy and print the total post I made so that you have it for future reference. Both how to backup and how to restore, should you need to.

    NOTE: my instructions referred to backing up to a USB hard drive which obviously can have much more storage than a 4GB key. You'll really only be able to make one complete SSD backup to one image file on the key. The "Backup" directory on /dev/sdb2 has already been created.

    NOTE: Backing up the SSD will take about 20 minutes. It'll gzip 8.1GB (your SSD drive) to a file that is approx. 2.2GB in size.
    You can always stick the key in another computer and copy that file (hdimage.gz) to a hdd or burn it to a DVD so you have a backup.

    HTH, those having problems setting up a flash key.

    Cheers.

    ADDED: October 2 ... See page 4 of this thread for how to add a script to make backups/restores easier with the 4GB Flash Key. You first have to have the flash key created before you can add this script.

    viewtopic.php?f=29&t=317&start=30

    Cheers.
     
    rbil, Sep 29, 2008
    #29
  10. Monkey

    jccguays

    Joined:
    Jul 28, 2008
    Messages:
    36
    Likes Received:
    0
    Location:
    Spain
    Hi, rbil!

    Firstly, thank you very much for the process I was looking for. Now, for a newbie like me, can try to play and learn something about linux.

    Well, I have done a backup of my system. I have used a 4 GB flash key and I think it's correct. Anyway I have some questions :mrgreen:

    1. When finished it reported that the size was about 1.97 GB, but when I put the flash key inside my AA1, the size of the file is 3.4 GB. ¿Is it normal?

    2. The process take about one hour, could be the flash key (it reported about 4.2 M/s) or the file partition in the usb?

    Best regards
     
    jccguays, Sep 30, 2008
    #30
  11. Monkey

    gadgetmind

    Joined:
    Aug 1, 2008
    Messages:
    84
    Likes Received:
    0
    Note that if people use gzip to compress the data, this will compress less and less as time goes by. This is because dd reads every sector of the disk, including unused bits, but as the machine gets used more there will be more unused disk sectors that are non-zero as they were used previously.

    The fix for this is to zero unused space prior to doing the backup. I have never found an elegant way to do this, but here is a bodgy way. Note that this needs the filing system to be mounted, so it's best done when booted into Linpus just before shutting down to do the backup.

    dd if=/dev/zero of=zero.bin
    rm zero.bin

    The first command fills a file with zeros, will take a long time to run, and will finally exit due to the disk filing completely. You then delete the file. You can put both commands on one line if you like with a semi-colon between them.

    Ian
     
    gadgetmind, Sep 30, 2008
    #31
  12. Monkey

    rbil

    Joined:
    Aug 14, 2008
    Messages:
    730
    Likes Received:
    0
    Location:
    The Wet Coast, Canada
    1. do you mean the gz file was reported at 1.97 GB after backup, but when you look at it in the Acer it's 3.4GB? You sure you're not looking at the size of the partition and not the gz file in the Acer? What does df -h tell you?

    2. That seems like a long backup time! Maybe your flash key is much slower than the ones I use? I'm using Kingston DataTraveler 4GB flash keys that I got for $9.99 each. You can try using a larger block size and see whether that speeds things up:

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

    This will increase the block size from the default of 512 bytes to 4k bytes.

    BTW, did you make the flash key from the image I've provided for download or did you prepare the flash key yourself? If the latter, what filesystem are you using on the backup partition?

    Cheers.
     
    rbil, Sep 30, 2008
    #32
  13. Monkey

    rbil

    Joined:
    Aug 14, 2008
    Messages:
    730
    Likes Received:
    0
    Location:
    The Wet Coast, Canada
    Good point Ian, and it leads me to wonder just how much can be stored on a 4GB flash key when zipped? Would it ever exceed the FAT32 partition size of 3.5 GB I've left for backup space if the SSD was totally filled up? I guess an 8 GB flash key would be the ultimate answer, but then the backup partition would need to be ext2 rather than FAT32 if the SSD image won't zip down to under 4GB in size.

    What are your thoughts on this?

    Cheers.
     
    rbil, Sep 30, 2008
    #33
  14. Monkey

    gadgetmind

    Joined:
    Aug 1, 2008
    Messages:
    84
    Likes Received:
    0
    I think it's very optimistic to expect a full 8GB partition to ZIP down to 3.5GB but you might get lucky. It depends on what you go filling it with. Personally, I'd consider using an old HD in a USB caddy, but I am lucky in that I have multiple such littering the place.

    Regards file size, you can just run your dd/gzip multiple times and tell dd the size and skip (different options depending on whether backing up or restoring - take care)

    Or you can do this to backup
    dd if=/dev/sda1 conv=noerror,sync bs=4k | gzip -c | split -b 2000m - /mnt/whatever/backup.img.gz.
    the extra options to dd tell it what to do if a sector can't be read. Probably overkill for an SSD but I regularly use this when cloning HDs as the sods can tend to have the odd unreadable sector.

    Do this to restore
    cat /mnt/whatever/backup.img.gz.* | gzip -dc | dd of=/dev/sda1

    (Disclaimer, I haven't actually tried running either of these, but they look about right!)

    Ian
     
    gadgetmind, Sep 30, 2008
    #34
  15. Monkey

    rbil

    Joined:
    Aug 14, 2008
    Messages:
    730
    Likes Received:
    0
    Location:
    The Wet Coast, Canada
    I do my backups using a 2.5" external hdd. So this isn't really an issue for me. For those trying to do so with a 4GB flash key, it may never be an issue depending on how much stuff they decide to load on the SSD. Anyway, it's all food for thought.

    Cheers.
     
    rbil, Sep 30, 2008
    #35
  16. Monkey

    jccguays

    Joined:
    Jul 28, 2008
    Messages:
    36
    Likes Received:
    0
    Location:
    Spain
    1. Yes, it's correct. If a see under Thunar, the file has the same space that under "df -h" command: 3.4 GB. It's not a problem of space, I can use another USB of 8 or 16 GB.
    2. The USB is a Dane-elec, and yes, I think it takes too long.
    3. I use the file you uploaded becasue I couldn't create a partition inside the USB and I tried with Partition Magic, Gtparted, and qtparted: impossible. I'll try to use a new USB I have of 16 GB.

    Best regards and thanks.
     
    jccguays, Sep 30, 2008
    #36
  17. Monkey

    rbil

    Joined:
    Aug 14, 2008
    Messages:
    730
    Likes Received:
    0
    Location:
    The Wet Coast, Canada
    In reply to jccquays ...

    1. The df -h command tells you what the size of the drives are, how much is used and available, etc.
    Did you actually navigate to the Backup directory on that drive and look at the file size of the file named: hdimage.gz ? That's the actual backup you would have made if you followed my instructions.

    2. Try using the bs=4k parameter as I suggested. That might speed things up for you.

    3. If you use any drive larger than 4GB and try to image it using the file I've uploaded, you'll end up with a drive that is still only 4GB in size. The second partition on that drive will need to be expanded to make use of the raw space left after the second partition is created. qtparted would be able to do this.

    I don't want to over-complicate things, but if you're going to use that file to image a 16GB flash key, this is how I'd do it.

    1. follow the instructions as you did when you created the 4GB flash key, then
    2. run qtparted and resize the second partition to take up the full remaining space on the key, then
    3. you may as well reformat that partition as ext2, rather than leaving it FAT32, and finally
    4. create a directory on that new partition named "Backup", so that when you actually follow my instructions on backing up using dd, that the file is there. It will be lost if you reformat the partition as suggested in step3.

    steps 3 and 4 are up to you. You can leave it FAT32 if you find that more useful and then the Backup directory will remain as it was on your 4GB key.

    Cheers.
     
    rbil, Sep 30, 2008
    #37
  18. Monkey

    jccguays

    Joined:
    Jul 28, 2008
    Messages:
    36
    Likes Received:
    0
    Location:
    Spain
    Hi, thanks for the help. I did as you said and by now it's working. I used qtparted, because, at least for me, using Gparted is useless.


    I prefer use FAT32, because I can use with windows too.

    I'm editing to say that I have made a new backup inside a new pendrive of 16 gb (z serie of Dane-Elec). It lasted about 30 minutes, and the space of the file it's the same than before: 3.4GB. I think that with ext2 or ext3 file could be faster, but I don't mind a little slow but useful for anothers SO.

    Regards and thanks again
     
    jccguays, Oct 1, 2008
    #38
  19. Monkey

    rbil

    Joined:
    Aug 14, 2008
    Messages:
    730
    Likes Received:
    0
    Location:
    The Wet Coast, Canada
    A Script To Make Backup/Restores Easier on the 4GB Flash Key

    I threw this script together to save users having to remember a bunch of Linux commands to backup and restore SSD images to the 4GB flash key that I've provided in this thread (see page 3). If you've downloaded that image file and created a 4GB flash key, you can add this script to it and make life easier. :)

    INSTRUCTIONS
    -------------------------------------------------

    1) Place the flash key into your AA0 and it'll automount

    2) Open mousepad and copy and paste the following code into it:

    Code:
    #!/bin/bash  
    # Written by rbil
    # Designed for a 4GB flash key and used to backup or restore
    # the SSD drive on the Aspire One
    # Make SURE that this is the ONLY USB drive in your computer!!!!
    # Released under the GPL
    # Use AT YOUR OWN RISK.         
    
    function pause(){
        read -p "$*"
    }
    
    echo Backup and Restore Script for Aspire One using 4GB Flash Key
    echo Make SURE this is the ONLY USB drive now attached to your Aspire One!
    echo =============================================
    echo .
    echo Type in the number of your choice:
    select CHOICE in Backup Restore Quit
    do
    
    case "$CHOICE" in
    "Backup")
    echo BACKUP SCRIPT by rbil
    echo ==========================================================
    echo It is run by doing: cd /mnt/cdrom
    echo then: ./backup
    echo ==========================================================
    echo .          
    echo This script will backup your SSD drive to the second partition in a 
    echo directory called Backup
    echo The filename will be: hdimage.gz
    echo After it has completed the backup it will display a directory listing
    echo showing you the file and its size.
    echo The system will then shutdown and you\'re ready to use this flash key
    echo either to restore your system or do a new backup.
    echo ------------------------------------------------------------
    echo To do a restore later, you\'ll:
    echo cd /mnt/cdrom
    echo ./backup
    echo And select restore as the option.
    echo ------------------------------------------------------------
    
    mount -t auto /dev/sdb2 /mnt/windows
    echo This will take some time. Just be patient!
    echo System will shutdown after completion ...
    
    dd if=/dev/sda bs=4k | gzip > /mnt/windows/Backup/hdimage.gz
    echo Backup has completed and here is your backup file:
    ls -l /mnt/windows/Backup
    
    pause 'Press any key to shutdown ...'
    echo Now shutting down ...
    shutdown -h now
    ;;
    
    "Restore")
    echo Restoring your system!
    echo This can take some time, so please be patient ...
    echo System will shutdown after restore is completed.
    echo ------------------------------------------------------------
    mount -t auto /dev/sdb2 /mnt/windows
    
    
    gzip -dc /mnt/windows/Backup/hdimage.gz | dd of=/dev/sda bs=4k
    echo Your system is now restored!
    
    pause 'Press any key to shutdown ...'
    echo Now shutting down ...
    shutdown -h now
    ;;
    "Quit")
    echo Now shutting down ...
    shutdown -h now
    exit
    ;;
    esac
    done
    
    3) Save the file as "backup" (without the quotes of course) to the FIRST partition on your flash key. That's the one that contains files such as: aida.img, altker32, etc.

    4) Using Thunar, navigate to that drive and right click on the file "backup" and click "Properties", then the "Permissions" tab and check "Allow this file to run as a program"

    That's it, you now have a script to automate backups and restores from your 4GB flash key.

    To use it:

    1) Boot your AAO with the flash key in a USB slot. Make sure it is the ONLY USB drive attached to your computer!

    2) Hit F12 to select the flash key as the boot device

    3) At the MBR prompt, type an "A", then type "1" and the system will bootup.

    4) You can just hit ENTER as things are displayed unless you wish to change the keyboard from the default English to some other language.

    5) When you have reached a command prompt do:

    Code:
    cd /mnt/cdrom
    ./backup
    
    You will then be able to select to do:

    1) Backup
    2) Restore
    3) Quit

    by entering the numbers 1, 2, or 3

    This should make things easier for people.

    Cheers.
     
    rbil, Oct 2, 2008
    #39
  20. Monkey

    zaphod

    Joined:
    Jul 10, 2008
    Messages:
    156
    Likes Received:
    0
    Location:
    France
    @rbil,
    The script is a great idea. It will save me having to remember the terminal commands. I have just copied it to my USB drive and will be using it for future backups. Thanks :D
     
    zaphod, Oct 5, 2008
    #40
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.