Old dogs can learn new tricks
» Tagged as: virtualization
Yep, you live and you learn. For years I thought you can invoke fdisk only on a physical hard drive. How wrong I was! You can invoke it even on a file (you will then have to manually set cylinders etc etc). This is very usefull when working with Qemu images.
I didn't know that dd had a 'sparse' option and have often had to wait until it created images for Qemu and encrypted file systems. All you need to do is to make use of the 'seek' option in dd.
Last but not least, I didn't know that losetup (and mount) had a skip option. That means you can mount virtual partitions inside Qemu images using losetup.
So I learnt three important things in a day and I thought I was an old dog. I am slightly embarrassed really. All these three things were on a post by Karsten M. Self. in a Xen Mailing list.
The last discovery (losetup offset option) is specially interesting. You can make encrypted file systems even more secure by adding a random number of junk bytes at the start of the image. That would mean the 'file' command cannot be used to find out what kind of a file you have and anyone trying to crack it will not only have to deal with the encryption algorithm but also try to guess that random number you have chosen for the padding.