This section shows various methods of backing up and restoring the user partition.
This is probably the simplest way to back up your user partition on the Eeepc. First you need to open a terminal window, use <Alt><Ctrl><T> then type “sudo -i” to become the “super user” *Note: When running from a live cd/usb/sd you may need to use another method to become root.
dd if=/dev/sda2 of=/PATH/TO/BACKUP
This will create a “bit to bit” backup of your user partition. Although this backup is large it is easy to make, and easy to restore. Now to restore this backup you would do something like this.
dd if=/PATH/TO/BACKUP of=/dev/sda2
Now if you want to make the backup up smaller its also fairly easy to create a compressed backup using gzip as below.
dd if=/dev/sda2 | gzip -c9 > /PATH/TO/BACKUP.gz
And to even reduce the backup image size, you can write zeros into the empty space in the hard disk as described in this page. Furthermore, you can checksum to verify if the image is good following these instructions.
To restore it.
gunzip -c /PATH/TO/BACKUP.gz | dd of=/dev/sda2
It has been reported in the forum that setting dd's buffer size to 1 GB speeds up a restore tremendously. (I have not tested it myself):
gunzip -c /PATH/TO/BACKUP.gz | dd bs=1048576 of=/dev/sda
This method is more complex, but produces considerably smaller and more flexible backups. Other advantages include the ability to swap filesystems. First things first open a terminal window with <Alt><Ctrl><T> and the use “sudo -i” for “super user” mode. *Note: When running from a live cd/usb/sd you may need to use another method to become root.
First thing we need to do is mount the user partition outside of the union. Lucky for us this is easily done. Create the directory you'll be mounting it on.
Now mount it.
mount /dev/sda2 /mnt/sda2
Now we want all paths relative to our mount point for flexibility so lets cd to our new mount.
Next is to actually create our backup, for this we are going to be using the “tar” and use gzip compression. So it should look like this.
tar -cpszf /PATH/TO/BACKUP.tar.gz .
Now when you want to restore this backup you would simply mount your user partition again(Freshly formated) cd to it as above and type this.
tar -xf /PATH/TO/BACKUP.tar.gz
This method creates the smallest partition backups, as only used data blocks are copied, instead of copying everything as “dd” does.
At first you need a bootable USB stick or CD containing “partimage”, I prefer System Rescue CD. The next steps assume you are using System Rescue CD from a USB stick:
If you also want to backup your partition table, use those guidelines.
To restore from this image, repeat steps 1-3, and instead of backing up the partition restore it using partimage.
This is the simplest way to backup your whole system in one go. This will include the System, User, Bios, and EFI partitions “aka all of them”. You will need to consider what you're backing it up onto before hand if you have an 8G. This is because fat32 which is used for many external devices has file size limit of roughly 4 gigs. So its fine for the 2G and the 4G models, but if you have an 8G you may need to backup onto a drive formatted to linux filesystem or choosing another method of backup.
First open a terminal window and type “sudo -i” to become the “super user” then type.
dd if=/dev/sda of=/PATH/TO/BACKUP
When it finishes you have backed up your entire system. When you want to restore it use.
dd if=/PATH/TO/BACKUP of=/dev/sda
This method is very similar to the large dump method, however we compress the image to make it smaller. This may even enable an 8G to store its image on a fat32 filesystem. First open a terminal window and become a “super user” with “sudo -i”.
dd if=/dev/sda | gzip -c9 > /PATH/TO/BACKUP.gz
Now when you want to restore it use.
gunzip -c /PATH/TO/BACKUP.gz | dd of=/dev/sda
This is the most complex method, but its also the most flexible. It should also produce backups that are substantially smaller then the previous methods, which is beneficial to 8G+ owners. First open a terminal window and become a “super user” with “sudo -i”. Next we're going to create compressed tar archives of system, and user partitions.
Create the directories for the partitions to be mounted on.
Now mount the partitions.
mount /dev/sda1 /mnt/sda1
mount /dev/sda2 /mnt/sda2
Now CD to the first directory.
And create the archive file.
tar -cpszf /PATH/TO/BACKUP-sda1.tar.gz .
When finished CD to the next directory.
Now archive here as well.
tar -cpszf /PATH/TO/BACKUP-sda2.tar.gz .
Ok now the majority of the files are backed up. But there's still a bit that needs to be done. Next lets backup sda3 and sda4, now I personally don't see a current use for sda3 but we are trying to create a way to make a “perfect restore” First sda3.
dd if=/dev/sda3 | gzip -c9 > /PATH/TO/BACKUP-sda3.img.gz
dd if=/dev/sda4 | gzip -c9 > /PATH/TO/BACKUP-sda4.img.gz
Ok now we have all the partitions backed up. However we now need to backup the boot blocks and partition tables. First the mbr”Master Boot Record” combined with the partition table and the “protected storage” section that grub uses for its stage 1.5
dd if=/dev/sda bs=8192 count=1 | gzip -c9 > /PATH/TO/BACKUP-boot.img.gz
Now there shouldn't be anything on the boot blocks for sda1 and sda2 but lets back them up for good measure too.
dd if=/dev/sda1 bs=512 count=1 | gzip -c9 > /PATH/TO/BACKUP-boot-sda1.img.gz
dd if=/dev/sda2 bs=512 count=1 | gzip -c9 > /PATH/TO/BACKUP-boot-sda2.img.gz
Congratulations you've now backed up your system, now onto the restoration!
First thing we need a partition table.
gunzip -c /PATH/TO/BACKUP-boot.img.gz | dd of=/dev/sda
With this we should have our partition table, and boot block plus the reserved section for grub restored. Now we need to put some filesystems on those partitions.
mkfs.ext2 -L SYSTEM /dev/sda1
mkfs.ext3 -L USER /dev/sda2
If it asks you if your sure just tell it yes. Now we should restore the rest of our boot blocks just in case we had something on them.
gunzip -c /PATH/TO/BACKUP-boot-sda1.img.gz | dd of=/dev/sda1
gunzip -c /PATH/TO/BACKUP-boot-sda2.img.gz | dd of=/dev/sda2
Ok now on to the files, to restore those we need to mount the newly formated partitions so first lets create the mount points.
Mount the partitions:
mount /dev/sda1 /mnt/sda1
mount /dev/sda2 /mnt/sda2
Ok now on to the first directory.
And restore its files.
tar -xf /PATH/TO/BACKUP-sda1.tar.gz
And to the next.
tar -xf /PATH/TO/BACKUP-sda2.tar.gz
Ok the only pieces left are sda3 and sda4, and they are restored pretty simply.
gunzip -c /PATH/TO/BACKUP-sda3.img.gz | dd of=/dev/sda3
gunzip -c /PATH/TO/BACKUP-sda4.img.gz | dd of=/dev/sda4
Now your system should be restored. If you at anytime you want to backup you user changes after this just use the “tar” method described above for user partitions.
This version will work natively on the eee's Xandros. It relies on **rsync**, which you have to install first.
See this page about using
synaptic to install new packages. Find rsync, mark it for installation, and click
Note. There is a bug in synaptic: if you use search to search for a package, and then mark it and click apply, it will report an error. So don't use search. Just scroll down to the entry to mark it.
Once you have installed rsync, use the following command from a terminal (or create a file containing it, and run it as a command):
rsync -a --exclude "Trash" --exclude "My Music" --exclude ".*" /home/user /PATH/TO/BACKUP
The first time you run this it will create a backup of the directories and files you specify (you can include more files and directories after
/home/user above) to the destination you specify, excluding all files that match the - -exclude entries (you can have as many as you want). ”.*” matches files and directories beginning with a dot: these are hidden files used by programs for storing preferences; you can choose to back them up or not as you prefer.
Subsequent times you run it, it will only copy files that are new or have changed since last time.
The -a puts it in archive mode, which means it preserves the directory and file permissions as closely as possible.
To put the command above into a file, open a new file in a text editor, enter the line above and save it, say as the file “backup”. Then open a terminal with ctrl-alt-T, and in the directory where you saved the file say “chmod +x backup”. This makes the file executable. Then double clicking on the file from the file manager will run it and do the backup.
Rsync has a *vast* number of parameters to make it perform in different ways. It is especially good at backup up over the network to a server, but that is expert mode, which takes more work to describe than for this simple entry. rio sosh code rio