btrfs-snap icon indicating copy to clipboard operation
btrfs-snap copied to clipboard

ERROR: .... is not a btrfs mountpoint (or old version of btrfs-tools, try > 0.19) Ubuntu 20.04

Open axeljacobs opened this issue 3 years ago • 0 comments

btrfs-snap version: 1.7.3 btrfs-progs version : 5.4.1 root btrfs volume : /var/fileserver btrfs subvolume : /var/fileserver/data/active

When Verifying that the path is either a valid btrfs mountpoint or a subvolume

# Verify that the path is either a valid btrfs mountpoint
mount -t btrfs | cut -d " " -f 3 | grep "^${mp}$" > /dev/null
if [ $? -ne 0 ] ; then
    # or a valid snapshot matching mp
    btrfs subvolume show $mp | grep "${mp}$" > /dev/null
    if [ $? -ne 0 ] ; then
        log.error "${mp} is not a btrfs mountpoint (or old version of btrfs-tools, try > 0.19)"
        exit 1;
    fi
fi

with btrfs-progs version 4.4: btrfs subvolume show /var/fileserver/data/active the output would look like this:

/var/fileserver/data/active
        Name:                   active
        UUID:                   84638c7b-742f-3c4a-a6ba-6d64b82cba71
        Parent UUID:            -
        Received UUID:          -
        Creation time:          2018-02-10 15:02:47 +0100
        Subvolume ID:           260
        Generation:             233633
        Gen at creation:        25
        Parent ID:              5
        Top level ID:           5
        Flags:                  -
        Snapshot(s):

with btrfs-progs version 5.4.1: the same command btrfs subvolume show /var/fileserver/data/active output:

data/active
        Name:                   active
        UUID:                   57e8d80f-99b6-394d-9b12-bc766e0a249a
        Parent UUID:            -
        Received UUID:          -
        Creation time:          2022-02-17 13:54:53 +0000
        Subvolume ID:           258
        Generation:             308
        Gen at creation:        8
        Parent ID:              5
        Top level ID:           5
        Flags:                  -
        Snapshot(s):

the "full" path is not present anymore /var/fileserver/data/active != data/active

the command btrfs subvolume show $mp | grep "${mp}$" will always retrun exit code 1 leading the script to stop.

A solution is to adapt the script like this, in order to grep the correct subvolume name :

# Verify that the path is either a valid btrfs mountpoint
mount -t btrfs | cut -d " " -f 3 | grep "^${mp}$" > /dev/null
if [ $? -ne 0 ] ; then
    # or a valid snapshot matching mp
    # Get the path of the root volume as a prefix
    rv=$(mount -t btrfs | cut -d " " -f 3)
    # Remove the prefix with the / from the full path
    vn=${mp#"$rv/"}
    btrfs subvolume show $mp | grep "$vn" > /dev/null
    if [ $? -ne 0 ] ; then
        log.error "${mp} is not a btrfs mountpoint (or old version of btrfs-tools, try > 0.19)"
        exit 1;
    fi
fi

Hope it helps someone....

axeljacobs avatar Feb 18 '22 12:02 axeljacobs