Skip to content

Instantly share code, notes, and snippets.

View msmafra's full-sized avatar

Marcelo dos Santos Mafra msmafra

  • Brazil
  • 14:41 (UTC -03:00)
View GitHub Profile
#!/bin/bash
[[ "$(id -u)" -eq 0 ]] || (echo "Got root?" ; exit 5)
command -v btrfs > /dev/null || (echo "Command not found: btrfs" ; exit 4)
for folder in $* ; do
mount | awk '{print $3}' | grep "$(pwd)/${folder}" && echo "${folder} has a submount?" && exit 1
btrfs sub list . | grep "${PWD##*/}/${folder}" && echo "${folder} has a subvolume?" && exit 2
[ -e ${folder}.temp ] && echo "${folder}.temp already exists?" && exit 3 || true
mv ${folder} ${folder}.temp
btrfs sub create ${folder}