Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- set -e
- NAME=foo
- FILE=/.$NAME.fs
- FSIZE=1
- DIR=/mnt/$NAME
- KEYDIR=/root
- ###
- cryptmount=$(which cryptmount)
- if [ -z "$cryptmount" ]; then echo "sorry, no cryptmount installed"; exit; fi
- btrfs=$(which btrfs)
- if [ -z "$btrfs" ]; then echo "sorry, no btrfs-tools installed"; exit; fi
- echo "generating $FILE (takes while) ..."
- dd if=/dev/zero of=$FILE bs=1G count=$FSIZE
- cp -f /etc/cryptmount/cmtab /etc/cryptmount/cmtab.$(date -I).bak
- cat >> /etc/cryptmount/cmtab <<EOF
- # created by $(basename $0)
- $NAME {
- dev=$FILE
- dir=$DIR
- fstype=btrfs
- mountoptions=noatime
- cipher=aes
- keyformat=builtin
- keyfile=$KEYDIR/$NAME.key
- flags=user,nofsck
- }
- EOF
- echo "generating key: $NAME .."
- $cryptmount --generate-key 32 $NAME
- $cryptmount --prepare $NAME
- echo "making btrfs on: $NAME ..."
- mkfs.btrfs /dev/mapper/$NAME
- mkdir -p $DIR
- mount -t btrfs -o noatime /dev/mapper/$NAME $DIR
- echo "creating btrfs subvolumes on: $DIR: "
- $btrfs subvolume create $DIR/rsnapshot
- $btrfs subvolume create $DIR/rsnapshot/hourly.0
- $btrfs subvolume create $DIR/rsnapshot/hourly.1
- $btrfs subvolume create $DIR/rsnapshot/hourly.2
- $btrfs subvolume create $DIR/rsnapshot/hourly.3
- $btrfs subvolume create $DIR/rsnapshot/hourly.4
- $btrfs subvolume create $DIR/rsnapshot/weekly.0
- $btrfs subvolume create $DIR/rsnapshot/weekly.1
- $btrfs fi df $DIR
- $btrfs subvolume list $DIR
- exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement