Skip to content

Instantly share code, notes, and snippets.

@brandonros
Last active April 16, 2025 01:51
Show Gist options
  • Save brandonros/2cbe4a159f8e471d91d4e5b82868cd2c to your computer and use it in GitHub Desktop.
Save brandonros/2cbe4a159f8e471d91d4e5b82868cd2c to your computer and use it in GitHub Desktop.

USB Preparation

SOURCE_IMAGE="debian-12-nocloud-amd64.qcow2"
TARGET_SIZE_GB=120
OUTPUT_RAW="${SOURCE_IMAGE%.qcow2}.raw"

# install dependencies
sudo apt-get update
sudo apt-get install -y parted

# download
curl -L -O https://cloud.debian.org/images/cloud/bookworm/latest/debian-12-nocloud-amd64.qcow2

# resize
qemu-img resize "$SOURCE_IMAGE" ${TARGET_SIZE_GB}G

# convert
qemu-img convert -f qcow2 -O raw "$SOURCE_IMAGE" "$OUTPUT_RAW"

# resize partition
LOOP_DEV=$(sudo losetup --find --show "$OUTPUT_RAW")
sudo parted --fix --script $LOOP_DEV resizepart 1 100%
sudo partprobe $LOOP_DEV
sudo e2fsck -f ${LOOP_DEV}p1
sudo resize2fs ${LOOP_DEV}p1

# unmount
sudo losetup -d $LOOP_DEV

# write to disk
sudo diskutil unmountDisk /dev/disk4
sudo dd if=debian-12-nocloud-amd64.raw of=/dev/rdisk4 bs=8M
sudo sync
sudo diskutil eject /dev/disk4

Sid

curl -L -O https://cloud.debian.org/images/cloud/sid/daily/latest/debian-sid-nocloud-amd64-daily.tar.xz
tar -xf debian-sid-nocloud-amd64-daily.tar.xz
sudo diskutil unmountDisk /dev/disk4
sudo dd if=disk.raw of=/dev/rdisk4 bs=8M
sudo sync
sudo diskutil eject /dev/disk4
@brandonros
Copy link
Author

# mount
mount /dev/sdb1 /mnt
# install
dpkg -i /mnt/firmware-iwlwifi_20250311-1_all.deb 
dpkg -i /mnt/libnl-3-200_3.7.0-2_amd64.deb 
dpkg -i /mnt/libnl-genl-3-200_3.7.0-2_amd64.deb 
dpkg -i /mnt/libnl-route-3-200_3.7.0-2_amd64.deb 
dpkg -i /mnt/libpcsclite1_2.3.3-1_amd64.deb 
dpkg -i /mnt/wpasupplicant_2.10-24_amd64.deb 
# reload
modprobe -r iwlwifi
modprobe iwlwifi
# configure
cat << EOF > /etc/wpa_supplicant/wpa_supplicant-wlo1.conf 
ctrl_interface=/run/wpa_supplicant
ctrl_interface_group=0
update_config=1
network={
  ssid="redacted"
  psk="redacted"
  key_mgmt=WPA-PSK
}
EOF
cat << EOF > /etc/systemd/network/25-wlo1.network
[Match]
Name=wlo1
[Network]
DHCP=yes
EOF
cat << EOF > /etc/hostname
beelink-linux
EOF
# start
systemctl enable [email protected]
systemctl start [email protected]
systemctl enable systemd-networkd.service
systemctl start systemd-networkd.service
# update
apt-get update
apt-get dist-upgrade
apt-get upgrade
apt-get autoremove
# install dependencies
apt-get install openssh-server e2fsprogs
# enable
systemctl start sshd
# create user
useradd -m -s /bin/bash user
passwd user
usermod -aG sudo user

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment