It’s time for some experimentation.
So I was looking for a way to make a live-usb, with persistence — preferably with encryption. And I found the following Kali Linux live-usb-persistence. very intriguing !
## For example : What does the underscore do ? read bytes _ < <(du -bcm kali-linux-1.0.8-amd64.iso |tail -1); echo $bytes
Here are the commands, in full, they use to make a persistent live-usb :
## This is intriguing. size=5gb read bytes _ < <(du -bcm kali-linux-1.0.8-amd64.iso |tail -1); echo $bytes parted /dev/sdb mkpart primary $bytes $size mkfs.ext3 -L persistence /dev/sdb3 e2label /dev/sdb3 persistence mkdir -p /mnt/my_usb mount /dev/sdb3 /mnt/my_usb echo "/ union" > /mnt/my_usb/persistence.conf umount /dev/sdb3
The same, but now for an encrypted install :
## This intrigues me even more. size=5gb read bytes _ < <(du -bcm kali-linux-1.0.8-amd64.iso |tail -1); echo $bytes parted /dev/sdb mkpart primary $bytes $size cryptsetup --verbose --verify-passphrase luksFormat /dev/sdb3 cryptsetup luksOpen /dev/sdb3 my_usb mkfs.ext3 -L persistence /dev/mapper/my_usb e2label /dev/mapper/my_usb persistence mkdir -p /mnt/my_usb mount /dev/mapper/my_usb /mnt/my_usb echo "/ union" > /mnt/my_usb/persistence.conf umount /dev/mapper/my_usb cryptsetup luksClose /dev/mapper/my_usb
## How to write an iso to an usb-stick. ## In this case : the kali distribution. dd if=kali-linux-1.0.8-amd64.iso of=/dev/sdb bs=1M
Since I’m not a too big of a fan, of running “ foreign (to me) ” commands, I decided to look for my own way. ;-) There’s only one problem though, I don’t need the answer in bytes. However, I do agree that using wc -c <"$arg" is a very elegant solution ! :-) Yet when I try to use basic calculations — either using bash’s builtins, such as ((expr/expr)) — the answer is always truncated down, in this case — I’m using a debian live iso as example — therefore I get 1230 (MB) as answer, whereas it should be 1231 (MB).
Thus here is the answer I seek :
## How to round numbers properly. arg="debian-live-7.6.0-amd64-kde-desktop.iso" bytes="$(wc -c < "$arg")" printf '%b\n' "$bytes" ## Answer : 1290584064 mbytes="$(printf '%.0f\n' "$(bc -q <<< "scale=2;"$bytes"/1048576")")" printf '%b\n' "$mbytes" ## Answer : 1231
Since I‘ve a computer with two hard-drives, the idea is to experiment with a live-environment, with persistence. Either on a separate usb thumbstick (I already have one with the linuxmint — debian edition on it.), or my “ spare ” hard-drive. :-D If the latter is the case, then I might opt for 3 partitions : One which will hold the iso, one which will hold the persistence part — referenced as the 5GB sized /dev/sdb3, as per their tutorial. And last, but not the least, yet another (encrypted, or not), container/partition, for the remainder of free space.
So much to do (read : experiment), and so little time. :-D
## This is a comment. # arg="your.iso" arg="debian-live-7.6.0-amd64-kde-desktop.iso" ## This one-liner does the trick as well, ## but seems rather foreign to me. # read mbytes _ < <(\du -m "$arg" |tail -1); echo $mbytes bytes="$(wc -c < "$arg")" mbytes="$(printf '%.0f\n' "$(bc -q <<< "scale=2;"$bytes"/1048576")")" size=5gb parted /dev/sdb mkpart primary $mbytes $size ## I need to check if the cryptsetup package ## is available in live ? cryptsetup --verbose --verify-passphrase luksFormat /dev/sdb3 cryptsetup luksOpen /dev/sdb3 my_usb mkfs.ext3 -L persistence /dev/mapper/my_usb e2label /dev/mapper/my_usb persistence mkdir -p /mnt/my_usb mount /dev/mapper/my_usb /mnt/my_usb echo "/ union" > /mnt/my_usb/persistence.conf umount /dev/mapper/my_usb cryptsetup luksClose /dev/mapper/my_usb
PS : In the meantime I’ll have a closer look at how to use dd.