What''s a good way of determining the mount point for a BTRFS filesystem in a shell script? /home/user might be a filesystem, a directory under a filesystem /home, a directory under a subvol /home of /, a subvol of /, or a subvol of the /home filesystem. How do I determine which it is? -- My Main Blog http://etbe.coker.com.au/ My Documents Blog http://doc.coker.com.au/ -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Hi Russell, all of the information you need should be available from the ''mount'' and ''btrfs subvol list'' commands. Though I realise it can be awkward to parse it out of there, this will be the only way to get accurate information in the face of bind-mounts and other fancy tricks. One other datapoint that you might be able to use is that btrfs, I believe, always shows inode number 256 for subvolumes in ''stat''. Keep in mind there that the root subvolume is, as the name implies, also technically a subvolume. Regards, Bart On Sat, Dec 29, 2012 at 6:04 AM, Russell Coker <russell+btrfs@coker.com.au> wrote:> What''s a good way of determining the mount point for a BTRFS filesystem in a > shell script? > > /home/user might be a filesystem, a directory under a filesystem /home, a > directory under a subvol /home of /, a subvol of /, or a subvol of the /home > filesystem. How do I determine which it is? > > -- > My Main Blog http://etbe.coker.com.au/ > My Documents Blog http://doc.coker.com.au/ > -- > To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html-- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Sat, 29 Dec 2012, Bart Noordervliet <bart@noordervliet.net> wrote:> all of the information you need should be available from the ''mount'' > and ''btrfs subvol list'' commands. Though I realise it can be awkward > to parse it out of there, this will be the only way to get accurate > information in the face of bind-mounts and other fancy tricks. One > other datapoint that you might be able to use is that btrfs, I > believe, always shows inode number 256 for subvolumes in ''stat''. Keep > in mind there that the root subvolume is, as the name implies, also > technically a subvolume.What I want to do is to have shell scripts create snapshots and then automatically remove them. As the output of "btrfs subvol list" is relative to the root of the filesystem even if we don''t consider bind mounts and other complications it becomes difficult to generate a "btrfs subvol delete" command that is correct from a shell script. Perhaps the best solution would be to have an option to "btrfs subvol list" to give output with fully qualified paths. -- My Main Blog http://etbe.coker.com.au/ My Documents Blog http://doc.coker.com.au/ -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
> Perhaps the best solution would be to have an option to "btrfs subvol list" to > give output with fully qualified paths.This patch does that. http://comments.gmane.org/gmane.comp.file-systems.btrfs/20040 -Anand -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html