~ubuntu-core-dev/partman-btrfs/ubuntu

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/bin/sh

set -- $1

fs=$1
mp=$2
type=$3
options=$4
dump=$5
pass=$6

case $type in
    btrfs)
	options="${options%,subvol=*}"
	#for removing the option subvol,when thats the only option
	#eg: options=="subvol=@", no comma present
	options="${options%subvol=*}"
	mount -t btrfs ${options:+-o "$options"} $fs /target$mp || exit 1
	case $mp in
	    /)
		btrfs subvolume create /target$mp/@
		umount /target$mp
		options="${options:+$options,}subvol=@"
		mount -t btrfs -o $options $fs /target$mp
		;;
	    /home)
		btrfs subvolume create /target$mp/@home
		umount /target$mp
		options="${options:+$options,}subvol=@home"
		mount -t btrfs -o $options $fs /target$mp
		;;
	esac
	echo "umount /target$mp"
	exit 0
	;;
esac

exit 1