Thursday, August 6, 2015
better compressed dd images of blockdevices
When creating full images from one of my rootdisks …
dd if=/dev/sda | bzip2 >/opt/backup/sda.img.bzip2
… i noticed the backups were growing, but the amount of data on the device was not.
Since dd is a full blocklevel- and not a filebased backup, there must be some free space containing old bits and bytes.
The sfill utility can overwrite the freespace with zeroes, giving me better compressed images.
sfill -f -l -l -z /mnt/mountpoint
Clean ubuntu rootdisk
My script to clean up some stuff.
Seems that those kernel header packages are eating up all inodes on small ext volumes.
#!/bin/sh nr_of_removed_packages=`dpkg -l | egrep "^rc" | cut -d" " -f3 | wc -l` nr_of_active_kernels=`ls /boot/vmlinuz* | wc -l` active_kernels=`ls /boot/vmlinuz* | cut -d" " -f9 | sed -r 's/\/boot\/vmlinuz-//' | sed -r 's/-generic//'` nr_of_headers_to_be_cleaned=`dpkg -l | grep linux-headers | grep -v headers-generic | cut -d" " -f3 | grep -v "$active_kernels" | wc -l` if [ "$nr_of_removed_packages" -gt "0" ]; then echo "Purge configuration files for removed packages ($nr_of_removed_packages)" dpkg --purge `dpkg -l | egrep "^rc" | cut -d" " -f3` else echo "No removed packages" fi if [ "$nr_of_headers_to_be_cleaned" -gt "0" ]; then echo "Cleaning old kernel headers, but skipping active kernels:" echo "$active_kernels" echo "" echo "Going to clean:" dpkg -l | grep linux-headers | grep -v headers-generic | cut -d" " -f3 | grep -v "$active_kernels" echo "Wait 5 seconds or break now!!" sleep 5 dpkg --purge `dpkg -l | grep linux-headers | grep -v headers-generic | cut -d" " -f3 | grep -v "$active_kernels"` else echo "No kernel headers to be cleaned" fi echo "Done!"