Skip to content

Instantly share code, notes, and snippets.

View rustybird's full-sized avatar

Rusty Bird rustybird

View GitHub Profile
#!/usr/bin/python3 -S
import fcntl
import os
import struct
import sys
LOOP_CONFIGURE = 0x4C0A
LO_FLAGS_READ_ONLY = 1
LO_FLAGS_DIRECT_IO = 16
--- /etc/xen/scripts/block.orig 2022-10-21 11:44:46.259102430 +0000
+++ /etc/xen/scripts/block 2022-10-21 11:44:46.259102430 +0000
@@ -341,7 +341,7 @@
else
roflag=''
fi
- do_or_die losetup $roflag "$loopdev" "$file"
+ do_or_die piccolosetup --sector-size=512 --direct-io=on $roflag "$loopdev" "$file"
xenstore_write "$XENBUS_PATH/node" "$loopdev"
echo $loopdev > "$HOTPLUG_STORE-node"
#!/bin/bash
#
# "Manage Bookmarks" (Ctrl-Shift-o) - "Import and Backup" - "Backup..."
# split-browser-bookmark-json2tsv <bookmarks-2022-03-04.json >>bookmarks.tsv
# (Conversion happens in a diposable qube, which must have jq installed.)
set -e -u -o pipefail
jq_filter='recurse(.children[]?) |
select(.typeCode==1) |

EXPERIMENTAL: Convert a Qubes R4.0 installation from file on ext4 to file-reflink on btrfs

  1. Ensure that you have a working backup of all VMs.

  2. Find the UUID of the LUKS device hosting the dom0 ext4 root filesystem:

    grep -Eo '^/dev/mapper/luks-[0-9a-f-]{36} / ext4 ' /proc/mounts | cut -b 18-54
    

    Write down the output on a piece of paper.

#!/usr/bin/sudo bash
set -e -o pipefail
shopt -s expand_aliases
usage() {
cat <<END
Usage: $0 -a # reset AEM ("reinstalled Qubes")
$0 -t # reset TPM ("new computer")
$0 -t -a # reset both ("new user")
@rustybird
rustybird / window.py
Created September 13, 2016 10:33
override_redirect focus test
#!/usr/bin/python2
# How to test:
#
# 1. Minimize all windows belonging to the VM, except for one terminal.
# 2. Run "sleep 10; ./window.py" in the terminal.
# 3. Focus a window from another VM before the popup appears.
# 4. Move the pointer to the popup without travelling through the terminal.
# 5. Click on the popup.
#
#!/bin/bash
while :; do
date >&2
curl --proxy socks5h://127.0.0.1:9150 \
--proxy-user some:thing \
https://check.torproject.org/api/ip
echo
@rustybird
rustybird / qvm-copy-from-vm
Last active February 23, 2017 12:28
qvm-copy-from-vm
# moved to https://github.com/rustybird/qubes-stuff/blob/master/dom0/bin/qvm-copy-from-vm
#!/usr/bin/sudo bash
set -xeuo pipefail
# Make a Btrfs layout Qubes R4.1 installation use ephemeral swap.
dev=/dev/sda2
grub_cfg=/boot/grub2/grub.cfg # BIOS boot
#grub_cfg=/boot/efi/EFI/qubes/grub.cfg # EFI boot
test -e "$grub_cfg" # sanity check 1