User Tools

Site Tools


indexes:backup_a_partition_with_dd_and_gzip

Table of Contents

Pre-Backup

If you want to increase the gzip capability you would like to fill the non-allocated space with zeros. This is done by putting zeros into a file until the file fills up all space on the drive. Then delete the file to free up space. Now you should have “stuffed” the free space with good compression zeros:

dd if=/dev/zero of=/media/mounted-partition-to-backup/delete.me bs=8M; rm delete.me

Backup

When I need to backup a parititon I use the dd command, so simple and so powerful. Usually a partition isn't filled out and have some free space. To avoid creating a unnecessary huge backup file I parse it through gzip:

root@tdd-HP-ProBook-5310m:/media/disk# dd if=/dev/sda4 bs=64K | gzip -c  > ./HP_TOOLS.img.gz
32688+0 records in
32688+0 records out
2142240768 bytes (2,1 GB) copied, 68,0337 s, 31,5 MB/s
root@tdd-HP-ProBook-5310m:/media/disk# ls -lh
total 268M
-rw-r--r-- 1 root root 268M 2011-04-03 15:56 HP_TOOLS.img.gz
root@tdd-HP-ProBook-5310m:/media/disk# 

As you can see 2GB becomes a 268MB backup file.

Restore

To restore the backup simply parse the backup file like this:

gunzip -c HP_TOOLS.img.gz | dd of=/dev/sda4 bs=64K 
indexes/backup_a_partition_with_dd_and_gzip.txt · Last modified: 02/12/2018 21:34 by 127.0.0.1