diff -uNr os-prober-1.56-orig/linux-boot-prober os-prober-1.56/linux-boot-prober
--- os-prober-1.56-orig/linux-boot-prober	2012-03-27 10:39:42.000000000 -0400
+++ os-prober-1.56/linux-boot-prober	2012-12-30 11:39:29.076007840 -0500
@@ -5,16 +5,79 @@
 
 newns "$@"
 require_tmpdir
-
+ERR="n"
 grep "^/dev/" /proc/mounts | parse_proc_mounts >"$OS_PROBER_TMP/mounted-map" || true
 
-partition="$1"
+if [ -z "$1" ]; then
+	ERR=y
+elif [ "$1" = btrfs -a -z "$2" ]; then
+	ERR=y
+elif [ "$1" = btrfs -a -z "$3" ]; then
+	ERR=y
+elif [ "$1" = btrfs ]; then
+	type=btrfs
+#	echo "$2" | grep -q "^UUID=" || ERR=y
+#	echo "$3" | grep -q "^subvol=" || ERR=y	
+#	UUID="$(echo "$2" | sed "s/UUID=//")"
+#	subvol="$(echo "$3" | sed "s/subvol=//")"
+	export "$2"
+	export "$3"
+	partition=$(blkid | grep "$UUID" | cut -d ':' -f 1 | tr '\n' ' ' | cut -d ' ' -f 1)
+	debug "btrfs: partition=$partition, UUID=$UUID, subvol=$subvol"
+else
+	partition="$1"
+	type=other
+fi
 
-if [ -z "$partition" ]; then
+if [ "x$ERR" != xn ]; then
 	echo "usage: linux-boot-prober partition" >&2
+	echo "       linux-boot-prober btrfs UUID=<> subvol=<>" >&2
 	exit 1
 fi
 
+if [ "$type" = btrfs ]; then
+	# handle all of the btrfs stuff here
+	if [ ! -e "/proc/self/mountinfo" ]; then
+		warn "/proc/self/mountinfo does not exist, exiting"
+		exit 1
+	fi
+	mpoint=$(grep "btrfs" /proc/self/mountinfo | grep "/$subvol " | grep "$partition " | cut -d ' ' -f 5)
+	if [ "$mpoint" = "/" ]; then
+		warn "specifying active root not valid, exiting"
+		exit 1
+	fi
+	if [ "x$mpoint" = "x" ]; then
+		test="/usr/lib/linux-boot-probes/50mounted-tests"
+		if [ -x $test ] && [ -f $test ]; then
+			debug "running $test btrfs $UUID $subvol $partition"
+			if $test "btrfs" "$UUID" "$subvol" "$partition"; then
+				debug "linux detected by $test"
+			fi
+		fi
+		exit 0
+	fi
+	type=btrfs
+	bootfs=$(grep "/boot " /proc/self/mountinfo | cut -d ' ' -f 9)
+	if [ "$bootfs" = btrfs ]; then
+		warn "btrfs boot partition not supported"
+		exit 1
+	fi
+	linux_mount_boot "$partition" "$mpoint"
+	bootpart="${mountboot%% *}"
+	bootmounted="${mountboot#* }"
+	test="/usr/lib/linux-boot-probes/mounted/40grub2"
+	if [ -f $test ] && [ -x $test ]; then
+		debug "running $test on btrfs subvol=$subvol UUID=$UUID"
+		if $test "$partition" "$bootpart" "$mpoint" "$type"; then
+			debug "$test succeeded"
+		fi
+	fi
+	if ! umount "$mpoint/boot"; then
+		warn "failed to umount $mpoint/boot"
+	fi
+	exit 0
+fi
+
 if ! mapped="$(mapdevfs "$partition")"; then
 	log "Device '$partition' does not exist; skipping"
 	continue
@@ -22,8 +85,8 @@
 
 if ! grep -q "^$mapped " "$OS_PROBER_TMP/mounted-map"; then
 	for test in /usr/lib/linux-boot-probes/*; do
-		debug "running $test"
 		if [ -x $test ] && [ -f $test ]; then
+			debug "running $test"
 			if $test "$partition"; then
 				debug "linux detected by $test"
 				break
diff -uNr os-prober-1.56-orig/linux-boot-probes/common/50mounted-tests os-prober-1.56/linux-boot-probes/common/50mounted-tests
--- os-prober-1.56-orig/linux-boot-probes/common/50mounted-tests	2012-03-27 10:42:12.000000000 -0400
+++ os-prober-1.56/linux-boot-probes/common/50mounted-tests	2012-12-30 11:39:29.076007840 -0500
@@ -5,16 +5,28 @@
 
 partition="$1"
 
-types="$(fs_type "$partition")" || types=NOT-DETECTED
+if [ "x$partition" = xbtrfs ]; then
+	if [ -z "$2" -o -z "$3" -o -z "$4" ]; then
+		debug "btrfs parameters missing"
+		exit 1
+	fi
+	types=btrfs
+	UUID="$2"
+	subvol="$3"
+	partition="$4"
+else
+	types="$(fs_type "$partition")" || types=NOT-DETECTED
+fi
+
 if [ "$types" = NOT-DETECTED ]; then
 	debug "$1 type not recognised; skipping"
-	exit 0
+	exit 1
 elif [ "$types" = swap ]; then
 	debug "$1 is a swap partition; skipping"
-	exit 0
+	exit 1
 elif [ "$types" = crypto_LUKS ]; then
 	debug "$1 is a LUKS partition; skipping"
-	exit 0
+	exit 1
 elif [ "$types" = ntfs ]; then
 	if type ntfs-3g >/dev/null 2>&1; then
 		types='ntfs-3g ntfs'
@@ -23,7 +35,7 @@
 	if type cryptsetup >/dev/null 2>&1 && \
 	   cryptsetup luksDump "$partition" >/dev/null 2>&1; then
 		debug "$1 is a LUKS partition; skipping"
-		exit 0
+		exit 1
 	fi
 	types="$(grep -v nodev /proc/filesystems)"
 fi
@@ -34,7 +46,16 @@
 fi
 
 mounted=
-if type grub-mount >/dev/null 2>&1 && \
+
+if [ "$types" = btrfs ]; then
+	if mount -o subvol=$subvol -t btrfs -U $UUID "$tmpmnt" 2>/dev/null; then
+		mounted=1
+		partition=$(grep "btrfs" /proc/self/mountinfo | grep "/$subvol " | cut -d ' ' -f 10)
+		type=btrfs
+	else 
+		warn "error mounting btrfs subvol=$subvol UUID=$UUID"
+	fi
+elif type grub-mount >/dev/null 2>&1 && \
    type grub-probe >/dev/null 2>&1 && \
    grub-mount "$partition" "$tmpmnt" 2>/dev/null; then
 	mounted=1
diff -uNr os-prober-1.56-orig/os-prober os-prober-1.56/os-prober
--- os-prober-1.56-orig/os-prober	2012-12-26 13:53:55.965187122 -0500
+++ os-prober-1.56/os-prober	2012-12-30 11:39:29.077007847 -0500
@@ -64,9 +64,12 @@
 
 	# Also detect OSes on LVM volumes (assumes LVM is active)
 	if type lvs >/dev/null 2>&1; then
-		echo "$(LVM_SUPPRESS_FD_WARNINGS=1 log_output lvs --noheadings --separator : -o vg_name,lv_name |
+		echo "$(LVM_SUPPRESS_FD_WARNINGS=1 log_output lvs --noheadings --separator : -o vg_name,lv_name 2>/dev/null |
 			sed "s|-|--|g;s|^[[:space:]]*\(.*\):\(.*\)$|/dev/mapper/\1-\2|")"
 	fi
+
+	# now lets make sure we got all of the btrfs partitions and disks
+	blkid | grep btrfs | cut -d ':' -f 1
 }
 
 parse_proc_swaps () {
@@ -124,6 +127,8 @@
 	grep "^md" /proc/mdstat | cut -d: -f2- | parse_proc_mdstat >"$OS_PROBER_TMP/raided-map" || true
 fi
 
+: >"$OS_PROBER_TMP/btrfs-vols"
+
 for partition in $(partitions); do
 	if ! mapped="$(mapdevfs "$partition")"; then
 		log "Device '$partition' does not exist; skipping"
@@ -142,7 +147,26 @@
 		continue
 	fi
 
-	if ! grep -q "^$mapped " "$OS_PROBER_TMP/mounted-map" ; then
+	# do btrfs processing here; both mounted and unmounted will
+	# be handled by 50mounted-tests so we can do a subvol only once.
+	type=$(blkid -o value -s TYPE $mapped)
+	if [ "$type" = btrfs ]; then
+		uuid=$(blkid -o value -s UUID $mapped)
+		if grep -q "^$uuid" "$OS_PROBER_TMP/btrfs-vols" ; then
+			continue
+		fi
+		debug "btrfs volume uuid=$uuid partition=$partition"
+		echo "$uuid" >>"$OS_PROBER_TMP/btrfs-vols"
+		test="/usr/lib/os-probes/50mounted-tests"
+		if [ -f "$test" ] && [ -x "$test" ]; then
+			debug "running $test on btrfs $partition"
+			if "$test" btrfs "$uuid" "$partition"; then
+				debug "os detected by $test"
+		   		continue
+			fi
+		fi
+
+	elif ! grep -q "^$mapped " "$OS_PROBER_TMP/mounted-map" ; then
 		for test in /usr/lib/os-probes/*; do
 			if [ -f "$test" ] && [ -x "$test" ]; then
 				debug "running $test on $partition"
diff -uNr os-prober-1.56-orig/os-probes/common/50mounted-tests os-prober-1.56/os-probes/common/50mounted-tests
--- os-prober-1.56-orig/os-probes/common/50mounted-tests	2012-09-17 11:08:12.000000000 -0400
+++ os-prober-1.56/os-probes/common/50mounted-tests	2012-12-30 11:39:29.077007847 -0500
@@ -1,20 +1,36 @@
 #!/bin/sh
 # Sub-tests that require a mounted partition.
 set -e
-partition="$1"
 
 . /usr/share/os-prober/common.sh
 
-types="$(fs_type "$partition")" || types=NOT-DETECTED
+if [ "x$1" = xbtrfs ]; then
+	types=btrfs
+	if [ -z "$2" -o -z "$3" ]; then
+		debug "missing btrfs parameters, exiting"
+		exit 1
+	fi
+	UUID="$2"
+	BTRFSDEV="$3"
+else
+	partition="$1"
+	types="$(fs_type "$partition")" || types=NOT-DETECTED
+fi
+
 if [ "$types" = NOT-DETECTED ]; then
 	debug "$1 type not recognised; skipping"
-	exit 0
+	exit 1
+elif [ "x$types" = "x" ]; then
+	exit 1
+elif [ "$types" = LVM2_member ]; then
+	debug "skipping LVM2 Volume Group on $partition"
+	exit 1
 elif [ "$types" = swap ]; then
 	debug "$1 is a swap partition; skipping"
-	exit 0
+	exit 1
 elif [ "$types" = crypto_LUKS ]; then
 	debug "$1 is a LUKS partition; skipping"
-	exit 0
+	exit 1
 elif [ "$types" = ntfs ]; then
 	if type ntfs-3g >/dev/null 2>&1; then
 		types='ntfs-3g ntfs'
@@ -23,7 +39,7 @@
 	if type cryptsetup >/dev/null 2>&1 && \
 	   cryptsetup luksDump "$partition" >/dev/null 2>&1; then
 		debug "$1 is a LUKS partition; skipping"
-		exit 0
+		exit 1
 	fi
 	for type in $(grep -v nodev /proc/filesystems); do
 		# hfsplus filesystems are mountable as hfs. Try hfs last so
@@ -46,6 +62,76 @@
 fi
 
 mounted=
+
+# all btrfs processing here.  Handle both unmounted and
+# mounted subvolumes.
+if [ "$types" = btrfs ]; then
+	partition="$BTRFSDEV"
+	debug "begin btrfs processing for $UUID"
+	# note that the btrfs volume must not be mounted ro
+	if mount -t btrfs -U "$UUID" "$tmpmnt"  2>/dev/null; then
+		debug "btrfs volume $UUID mounted"
+	else
+		warn "cannot mount btrfs volume $UUID, exiting"
+		rmdir "$tmpmnt" || true
+		exit 1
+	fi
+	# besides regular subvols, get ro and snapshot so thet can be excluded
+        subvols=$(btrfs subvolume list "$tmpmnt" | cut -d ' ' -f 9)
+        rosubvols=$(btrfs subvolume list -r "$tmpmnt" | cut -d ' ' -f 9)
+        sssubvols=$(btrfs subvolume list -s "$tmpmnt" | cut -d ' ' -f 9)
+        if ! umount "$tmpmnt"; then
+            warn "failed to umount btrfs volume on $tmpmnt"
+            rmdir "$tmpmnt" || true
+            exit 1
+        fi
+	if [ -z "$subvols" ]; then
+		debug "no subvols found on btrfs volume $UUID"
+		exit 1
+	fi
+	found=
+        for subvol in $subvols; do
+		debug "begin btrfs processing for $UUID subvol=$subvol"
+		if echo "$rosubvols" | grep -q -x "$subvol"; then
+			continue
+		fi
+		if echo "$sssubvols" | grep -q -x "$subvol"; then
+			continue
+		fi
+		mounted=
+		mpoint="$(grep btrfs /proc/self/mountinfo | grep "$partition " | grep "/$subvol " | cut -d ' ' -f 5)"
+		if [ -n "$mpoint" ]; then
+			if [ "x$mpoint" = "x/" ]; then
+				continue # this is the root for the running system
+			fi
+			mounted=1
+		else
+			# again, do not mount btrfs ro
+			mount -t btrfs -o subvol="$subvol" -U "$UUID" "$tmpmnt"
+			mpoint="$tmpmnt"
+		fi
+		test="/usr/lib/os-probes/mounted/90linux-distro"
+		if [ -f "$test" ] && [ -x "$test" ]; then
+			debug "running subtest $test"
+			if "$test" "$partition" "$mpoint" btrfs "UUID=$UUID" "subvol=$subvol"; then
+				debug "os found by subtest $test on subvol $subvol"
+				found=1
+			fi
+		fi
+		if [ -z "$mounted" ]; then
+			if ! umount "$tmpmnt"; then
+			    warn "failed to umount $tmpmnt"
+			fi
+		fi
+	done
+	rmdir "$tmpmnt" || true
+	if [ "$found" ]; then
+		exit 0
+	else
+		exit 1
+	fi
+fi
+
 if type grub-mount >/dev/null 2>&1 && \
    type grub-probe >/dev/null 2>&1 && \
    grub-mount "$partition" "$tmpmnt" 2>/dev/null; then
diff -uNr os-prober-1.56-orig/os-probes/mounted/common/90linux-distro os-prober-1.56/os-probes/mounted/common/90linux-distro
--- os-prober-1.56-orig/os-probes/mounted/common/90linux-distro	2012-12-26 13:53:55.968187150 -0500
+++ os-prober-1.56/os-probes/mounted/common/90linux-distro	2012-12-30 11:39:29.077007847 -0500
@@ -7,6 +7,8 @@
 partition="$1"
 dir="$2"
 type="$3"
+uuid="$4"
+subvol="$5"
 
 # This test is inaccurate, but given separate / and /boot partitions and the
 # fact that only some architectures have ld-linux.so, I can't see anything
@@ -128,7 +130,11 @@
 	fi
 	
         label="$(count_next_label "$short")"
-	result "$partition:$long:$label:linux"
+	if [ "x$type" = "xbtrfs" -a "x$uuid" != "x" -a "x$subvol" != "x" ]; then
+		result "$partition:$long:$label:linux:$type:$uuid:$subvol"
+	else
+		result "$partition:$long:$label:linux"
+	fi
 	exit 0
 else
 	exit 1
diff -uNr os-prober-1.56-orig/README.btrfs os-prober-1.56/README.btrfs
--- os-prober-1.56-orig/README.btrfs	1969-12-31 19:00:00.000000000 -0500
+++ os-prober-1.56/README.btrfs	2012-12-30 11:50:23.719841072 -0500
@@ -0,0 +1,15 @@
+BTRFS is a new filesystem which combines the filesystem with logical volume
+management (subvolumes).  For further information, see:
+      https://btrfs.wiki.kernel.org/index.php/Main_Page
+      https://btrfs.wiki.kernel.org/index.php/FAQ
+
+In order to support BTRFS, a number of changes were necessary to os-prober,
+os-probes/common/50mounted-tests, os-probes/mounted/common/90linux-distro,
+linux-boot-prober, and linux-boot-probes/common/50mounted-tests.
+
+The biggest impact will be to grub2 where there is additional information
+output by os-prober and where, if a BTRFS subvolume is being used for root,
+the parameters for linux-boot-prober have changed.
+
+Sun 30 Dec 2012 11:49:52 AM EST Gene Czarcinski <gene@czarc.net>
+
