Listing posts

Displaying posts 36 - 40 of 328 in total
Backup & restore disk/partitions
mouse 3718 · person cloud · link
Last update
2023-11-17
2023
11-17
«squashfs»

1. Partition table

1
2
3
4
5
# dump raw ms-dos table/mbr
dd if=/dev/sdX of=mbr.bin     bs=512 count=1
dd if=/dev/sdX of=mbr_2mb.bin bs=2MB count=1 # paranoia
# restore
dd if=mbr.bin of=/dev/sdX
  • using sfdisk (version > 2.26 for GPT support):
1
2
3
4
5
6
7
8
9
# dump raw partition table
sfdisk -b -O disk /dev/sdX # disk-<device>-<offset>.bak
# restore
ls disk-*.bak | sed -r 's/(.+)-(0x.+).bak/dd if=\0 of=\/dev\/sdX seek=$((\2)) bs=1 conv=notrunc/' | bash

# dump partition table in text format
sfdisk -d /dev/sdX > sdcard.ptable
# restore
sfdisk    /dev/sdX < sdcard.ptable

2. Partition data

You can use FSarchiver or the old school way:

  • ext* efficient backup/restore:
1
2
e2image -ra /dev/sdXY - | pv | 7za a -mx=9 -si sdXY.e2i.7z
7za x -so sdXY.e2i.7z | pv | dd of=/dev/sdXY bs=4K

or create a squashfs mountable image1:

1
2
3
4
5
6
7
8
9
10
11
apt install squashfs-tools

# backup
mkdir tmpdir
mksquashfs tmpdir sdXY.squashfs -p "sdXY.img f 444 root root e2image -ra /dev/sdXY -" -comp xz

# mount and...
mkdir tmpdir mntdir
mount sdXY.squashfs tmpdir
pv tmpdir/sdXY.img | dd of=/dev/sdXY # ...restore or...
mount tmpdir/sdXY.img mntdir         # ...inspect
  • ntfs efficient backup/restore:
1
2
ntfsclone -s -o - /dev/sdXY | pv | 7za a -mx=9 -si sdXY.nc.7z
7za x -so sdXY.nc.7z | pv | ntfsclone -r -O /dev/sdXY -
  • raw full backup/restore:
1
2
dd if=/dev/sdXY | pv | 7za a -mx=9 -si sdXY.dd.7z
7za x -so sdXY.dd.7z | pv | dd of=/dev/sdXY bs=4K

Tips: dd seek/skip


~~~ * ~~~

Debian package templates
mouse 165 · person cloud · link
Last update
2023-11-17
2023
11-17
«package variables»

inspect package available templates items with descriptions

1
2
3
4
5
# use `mc` to explore .deb content and locate `templates` file
# or use apt-extracttemplates
# or do it manually:
ar x file.deb control.tar.xz
tar -xOf control.tar.xz ./templates | less -p Template

set items value (pre-seed)

1
2
3
4
5
6
7
8
# list items
debconf-get-selections | grep ttf-mscorefonts-installer

# set item
echo "ttf-mscorefonts-installer  msttcorefonts/dlurl  string  xyz" | debconf-set-selections

# install package
apt-get install ttf-mscorefonts-installer

Source: serverfault, stackoverflow


~~~ * ~~~

Debian install the same packages to another PC
mouse 179 · person cloud · link
Last update
2023-11-16
2023
11-16
«install manually installed packages»
1
2
3
4
5
6
# backup (list of manually installed packages)
apt-mark showmanual > packages.txt

# restore
apt-get -s install -- `cat packages.txt | grep -v "^#" | tr "\n" ' '` 2>&1
aptitude -s --visual-preview install -- `cat packages.txt | grep -v "^#" | tr "\n" ' '`

~~~ * ~~~

Securely backup files to an online drive with gocryptfs
mouse 3935 · person cloud · link
Last update
2023-11-13
2023
11-13
«encrypted online backup»

We can easily accomplish this by using rclone on top of gocryptfs (hp), just remember to:

  • do not lose the .gocryptfs.reverse.conf volume's settings file
  • disable online storage automatic file versioning to increase security

Note: in the future we could use rclone crypt but at the moment it is not the best option available.

Install

1
2
3
4
5
6
sudo bash
mkdir -p /opt/gocode/src
cd /opt/gocode/src
git clone https://github.com/rfjakob/gocryptfs.git
cd gocryptfs && ./build.bash # buildfor CPU w/o AES-NI
strip /opt/gocode/bin/gocryptfs

Backup

1
2
3
4
5
6
7
8
# 1. setup the encrypted virtual fs
gocryptfs -init -reverse plain enc
# 2. move away volume settings
fusermount -u enc
mv plain/.gocryptfs.reverse.conf plain-gcfs.conf
# 3. remount and start the backup
gocryptfs -reverse -conf plain-gcfs.conf plain enc
rclone sync enc remote:/path/to/dest

Restore

  • Direct mount via rclone mount:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    # 1. mount the online drive on a local folder
    rclone mount remote:/path/to/backup enc
    # 2. mount the unencrypted virtual fs
    gocryptfs -conf plain-gcfs.conf -serialize_reads enc plain
    # 3. restore the backup
    rsync -avi plain/ /path/to/restore/
    # 4. umount the virtual fs in backward order
    fusermount -u plain
    fusermount -u enc
    
  • Dump and decrypt (requires twice the space):

    1
    2
    3
    4
    5
    6
    7
    8
    # 1. temporary dump of the online drive
    rclone sync remote:/path/to/backup enc
    # 2. mount the unencrypted virtual fs
    gocryptfs -reverse -conf plain-gcfs.conf enc plain
    # 3. restore the backup
    rsync -avi plain/ /path/to/restore/
    # 4. umount the vfs
    fusermount -u plain
    

~~~ * ~~~

Mechanical Keyboard Switch Types
mouse 254 · person cloud · link
Last update
2023-11-06
2023
11-06
« — »

Gateron KS-9 (good&cheap; PRO=pre-lubed; amazon)

  • black 2.0mm/60g/linear
  • red 2.0mm/45g/linear
  • brown 2.0mm/55g/tactile
  • blue 2.3mm/60g/click
  • green 2.3mm/80g
  • yellow 2.0mm/50g/linear
  • white 2.0mm/35g

Cherry mx/Kailh/Logitech GX

  • red: 2.0mm/45g/linear
  • blue: 2.2mm/60g/click
  • brown: 2.0mm/55g/tactile

Razer/Kaihl

  • yellow: 1.2mm/45g/linear
  • orange: 1.9mm/45g/tactile
  • green: 1.9mm/50g/click

Logitech Romer-G

  • linear: 1.5mm/45g
  • tactile: 1.5mm/45g

Source: mechanical-keyboard.org, x-bows.com

See also: Ferris T34 open source keyboard, HandsDown layout