5 added 8 characters in body
source | link

The answer by asciiphil seems to me to be correct, and should be marked as such.

It starts, "I don't know of a single-command way to do this." I don't, either, except to writeand have opened a corresponding feature request. As a workaround, one can create a wrapper script to provide onea single-command way to unlock and mount a partition. 

Assuming you use Bash, save the script below as, e.g. unlock-and-mount, make it executable, and put it in a directory in your PATH. You will then be able to unlock and mount a device in one step with unlock-and-mount /dev/disk/by-id/my-device-part-X.

Warning: this relies on parsing the messages udisksctl sends to stdout. Such parsing could break in the future, according to the udisksctl man page, which says:Warning: this relies on parsing the messages udisksctl sends to stdout, and upon the stability of the udisksctl command-line interface. This is fragile, according to the udisksctl man page, which says:

[This] program is not intended to be used by scripts or other programs - options/commands may change in incompatible ways in the future even in maintenance releases.[This] program is not intended to be used by scripts or other programs - options/commands may change in incompatible ways in the future even in maintenance releases.

In the meantime, here is the script, which works for now:

#!/usr/bin/env bash
# A convenience wrapper around `udisksctl`.

# Trace execution 
set -x

# Abort on errors. (I find this helpful, despite the cautions given in
# http://mywiki.wooledge.org/BashFAQ/105 and
# http://mywiki.wooledge.org/BashFAQ/112 .)
set -e
set -u

# Define functions
die () {
    echo >&2 "$@"
    exit 1
}

# Validate input argument(s) 
[[ "$#" -eq 1 ]] || die "Exactly 1 argument required: path to partition ID. $# given"
[[ -b "$1" ]]    || die "$1 is not a block device"
[[ "$1" == /dev/disk/by-id/* ]] || die "$1 does not begin '/dev/disk/by-id/'"

# Unlock partition
unlockedpart="$(udisksctl unlock -b "$1" |\
 tail -n1 |\
 sed -e 's/^Unlocked \/dev\/[[:print:]]\+ as \([[:print:]]\+\).$/\1/' \
)"

# Mount unlocked partition
udisksctl mount -b "$unlockedpart"

The answer by asciiphil seems to me to be correct, and should be marked as such.

It starts, "I don't know of a single-command way to do this." I don't, either, except to write a wrapper script to provide one. Assuming you use Bash, save the script below as, e.g. unlock-and-mount, make it executable, and put it in a directory in your PATH. You will then be able to unlock and mount a device in one step with unlock-and-mount /dev/disk/by-id/my-device-part-X.

Warning: this relies on parsing the messages udisksctl sends to stdout. Such parsing could break in the future, according to the udisksctl man page, which says:

[This] program is not intended to be used by scripts or other programs - options/commands may change in incompatible ways in the future even in maintenance releases.

In the meantime, here is the script, which works for now:

#!/usr/bin/env bash
# A convenience wrapper around `udisksctl`.

# Trace execution 
set -x

# Abort on errors. (I find this helpful, despite the cautions given in
# http://mywiki.wooledge.org/BashFAQ/105 and
# http://mywiki.wooledge.org/BashFAQ/112 .)
set -e
set -u

# Define functions
die () {
    echo >&2 "$@"
    exit 1
}

# Validate input argument(s) 
[[ "$#" -eq 1 ]] || die "Exactly 1 argument required: path to partition ID. $# given"
[[ -b "$1" ]]    || die "$1 is not a block device"
[[ "$1" == /dev/disk/by-id/* ]] || die "$1 does not begin '/dev/disk/by-id/'"

# Unlock partition
unlockedpart="$(udisksctl unlock -b "$1" |\
 tail -n1 |\
 sed -e 's/^Unlocked \/dev\/[[:print:]]\+ as \([[:print:]]\+\).$/\1/' \
)"

# Mount unlocked partition
udisksctl mount -b "$unlockedpart"

The answer by asciiphil seems to me to be correct, and should be marked as such.

It starts, "I don't know of a single-command way to do this." I don't, either, and have opened a corresponding feature request. As a workaround, one can create a wrapper script to provide a single-command way to unlock and mount a partition. 

Assuming you use Bash, save the script below as, e.g. unlock-and-mount, make it executable, and put it in a directory in your PATH. You will then be able to unlock and mount a device in one step with unlock-and-mount /dev/disk/by-id/my-device-part-X.

Warning: this relies on parsing the messages udisksctl sends to stdout, and upon the stability of the udisksctl command-line interface. This is fragile, according to the udisksctl man page, which says:

[This] program is not intended to be used by scripts or other programs - options/commands may change in incompatible ways in the future even in maintenance releases.

In the meantime, here is the script, which works for now:

#!/usr/bin/env bash
# A convenience wrapper around `udisksctl`.

# Trace execution 
set -x

# Abort on errors. (I find this helpful, despite the cautions given in
# http://mywiki.wooledge.org/BashFAQ/105 and
# http://mywiki.wooledge.org/BashFAQ/112 .)
set -e
set -u

# Define functions
die () {
    echo >&2 "$@"
    exit 1
}

# Validate input argument(s) 
[[ "$#" -eq 1 ]] || die "Exactly 1 argument required: path to partition ID. $# given"
[[ -b "$1" ]]    || die "$1 is not a block device"
[[ "$1" == /dev/disk/by-id/* ]] || die "$1 does not begin '/dev/disk/by-id/'"

# Unlock partition
unlockedpart="$(udisksctl unlock -b "$1" |\
 tail -n1 |\
 sed -e 's/^Unlocked \/dev\/[[:print:]]\+ as \([[:print:]]\+\).$/\1/' \
)"

# Mount unlocked partition
udisksctl mount -b "$unlockedpart"
4 added 8 characters in body
source | link

The answer by asciiphil seems to me to be correct, and should be marked as such.

It starts, "I don't know of a single-command way to do this." I don't, either, except to write a wrapper script to provide one. Assuming you use Bash, save the script below as, e.g. unlock-and-mount, make it executable, and put it in a directory in your PATH. You will then be able to unlock and mount a device in one step with unlock-and-mount /dev/disk/by-id/my-device-part-X.

Warning: this relies on parsing the messages udisksctl sends to stdout. Such parsing could break in the future, according to the udisksctl man page, which says:

[This] program is not intended to be used by scripts or other programs - options/commands may change in incompatible ways in the future even in maintenance releases.

In the meantime, here is the script, which works for now:

#!/usr/bin/env bash
# A convenience wrapper around `udisksctl`.

# Trace execution 
set -x

# Abort on errors. (I find this helpful, despite the cautions given in
# http://mywiki.wooledge.org/BashFAQ/105 and
# http://mywiki.wooledge.org/BashFAQ/112 .)
set -e
set -u

# Define functions
die () {
    echo >&2 "$@"
    exit 1
}

# Validate input argument(s) 
[[ "$#" -eq 1 ]] || die "Exactly 1 argument required: path to partition ID. $# given"
[[ -b "$1" ]]    || die "$1 is not a block device"
[[ "$1" == /dev/disk/by-id/* ]] || die "$1 does not begin '/dev/disk/by-id/'"

# Unlock partition
unlockedpart="$(udisksctl unlock -b "$1" |\
 tail -n1 |\
 sed -e 's/^Unlocked \/dev\/[[:print:]]\+ as \([[:print:]]\+\).$/\1/' \
)"

# Mount unlocked partition
udisksctl mount -b "$unlockedpart"

The answer by asciiphil seems to me to be correct, and should be marked as such.

It starts, "I don't know of a single-command way to do this." I don't, either, except to write a script to provide one. Assuming you use Bash, save the script below as, e.g. unlock-and-mount, make it executable, and put it in a directory in your PATH. You will then be able to unlock and mount a device in one step with unlock-and-mount /dev/disk/by-id/my-device.

Warning: this relies on parsing the messages udisksctl sends to stdout. Such parsing could break in the future, according to the udisksctl man page, which says:

[This] program is not intended to be used by scripts or other programs - options/commands may change in incompatible ways in the future even in maintenance releases.

In the meantime, here is the script, which works for now:

#!/usr/bin/env bash
# A convenience wrapper around `udisksctl`.

# Trace execution 
set -x

# Abort on errors. (I find this helpful, despite the cautions given in
# http://mywiki.wooledge.org/BashFAQ/105 and
# http://mywiki.wooledge.org/BashFAQ/112 .)
set -e
set -u

# Define functions
die () {
    echo >&2 "$@"
    exit 1
}

# Validate input argument(s) 
[[ "$#" -eq 1 ]] || die "Exactly 1 argument required: path to partition ID. $# given"
[[ -b "$1" ]]    || die "$1 is not a block device"
[[ "$1" == /dev/disk/by-id/* ]] || die "$1 does not begin '/dev/disk/by-id/'"

# Unlock partition
unlockedpart="$(udisksctl unlock -b "$1" |\
 tail -n1 |\
 sed -e 's/^Unlocked \/dev\/[[:print:]]\+ as \([[:print:]]\+\).$/\1/' \
)"

# Mount unlocked partition
udisksctl mount -b "$unlockedpart"

The answer by asciiphil seems to me to be correct, and should be marked as such.

It starts, "I don't know of a single-command way to do this." I don't, either, except to write a wrapper script to provide one. Assuming you use Bash, save the script below as, e.g. unlock-and-mount, make it executable, and put it in a directory in your PATH. You will then be able to unlock and mount a device in one step with unlock-and-mount /dev/disk/by-id/my-device-part-X.

Warning: this relies on parsing the messages udisksctl sends to stdout. Such parsing could break in the future, according to the udisksctl man page, which says:

[This] program is not intended to be used by scripts or other programs - options/commands may change in incompatible ways in the future even in maintenance releases.

In the meantime, here is the script, which works for now:

#!/usr/bin/env bash
# A convenience wrapper around `udisksctl`.

# Trace execution 
set -x

# Abort on errors. (I find this helpful, despite the cautions given in
# http://mywiki.wooledge.org/BashFAQ/105 and
# http://mywiki.wooledge.org/BashFAQ/112 .)
set -e
set -u

# Define functions
die () {
    echo >&2 "$@"
    exit 1
}

# Validate input argument(s) 
[[ "$#" -eq 1 ]] || die "Exactly 1 argument required: path to partition ID. $# given"
[[ -b "$1" ]]    || die "$1 is not a block device"
[[ "$1" == /dev/disk/by-id/* ]] || die "$1 does not begin '/dev/disk/by-id/'"

# Unlock partition
unlockedpart="$(udisksctl unlock -b "$1" |\
 tail -n1 |\
 sed -e 's/^Unlocked \/dev\/[[:print:]]\+ as \([[:print:]]\+\).$/\1/' \
)"

# Mount unlocked partition
udisksctl mount -b "$unlockedpart"
3 added 620 characters in body
source | link

The answer by asciiphil seems to me to be correct, and should be marked as such.

It starts, "I don't know of a single-command way to do this." I don't, either, except to write a script to provide one. Assuming you use Bash, save the script below as, e.g. unlock-and-mount, make it executable, and put it in a directory in your PATH. You will then be able to unlock and mount a device in one step with unlock-and-mount /dev/disk/by-id/my-device.

Warning: this relies on parsing the messages udisksctl sends to stdout. Such parsing could break in the future, according to the udisksctl man page, which says:

[This] program is not intended to be used by scripts or other programs - options/commands may change in incompatible ways in the future even in maintenance releases.

In the meantime, here is the script, which works for now:

#!/usr/bin/env bash
# A convenience wrapper around `udisksctl`.

# Trace execution 
set -x

# Abort on errors. (I find this helpful, despite the cautions given in
# http://mywiki.wooledge.org/BashFAQ/105 and
# http://mywiki.wooledge.org/BashFAQ/112 .)
set -e
set -u

# Define functions
die () {
    echo >&2 "$@"
    exit 1
}

# Validate input argument(s) 
[[ "$#" -eq 1 ]] || die "Exactly 1 argument required: path to diskpartition ID. $# given"
[[ -b "$1" ]]    || die "$1 is not a block device"
[[ "$1" == /dev/disk/by-id/* ]] || die "$1 does not begin '/dev/disk/by-id/'"

# Unlock devicepartition
unlockedpart="$(udisksctl unlock -b "$1" |\
 tail -n1 |\
 sed -e 's/^Unlocked \/dev\/sdd1[[:print:]]\+ as \([[:print:]]\+\).$/\1/' \
)"

# Mount unlocked partition
udisksctl mount -b "$unlockedpart"

The answer by asciiphil seems to me to be correct, and should be marked as such.

It starts, "I don't know of a single-command way to do this." I don't, either, except to write a script to provide one. Assuming you use Bash, save the script below as, e.g. unlock-and-mount, make it executable, and put it in a directory in your PATH. You will then be able to unlock and mount a device in one step with unlock-and-mount /dev/disk/by-id/my-device.

Warning: this relies on parsing the messages udisksctl sends to stdout. Such parsing could break in the future, according to the udisksctl man page, which says:

[This] program is not intended to be used by scripts or other programs - options/commands may change in incompatible ways in the future even in maintenance releases.

In the meantime, here is the script, which works for now:

#!/usr/bin/env bash
# A convenience wrapper around `udisksctl`.

# Trace execution 
set -x

# Abort on errors. (I find this helpful, despite the cautions given in
# http://mywiki.wooledge.org/BashFAQ/105 and
# http://mywiki.wooledge.org/BashFAQ/112 .)
set -e
set -u

# Define functions
die () {
    echo >&2 "$@"
    exit 1
}

# Validate input argument(s) 
[[ "$#" -eq 1 ]] || die "Exactly 1 argument required: path to disk ID. $# given"
[[ -b "$1" ]]    || die "$1 is not a block device"
[[ "$1" == /dev/disk/by-id/* ]] || die "$1 does not begin '/dev/disk/by-id/'"

# Unlock device
unlockedpart="$(udisksctl unlock -b "$1" |\
 tail -n1 |\
 sed -e 's/^Unlocked \/dev\/sdd1 as \([[:print:]]\+\).$/\1/' \
)"

# Mount unlocked partition
udisksctl mount -b "$unlockedpart"

The answer by asciiphil seems to me to be correct, and should be marked as such.

It starts, "I don't know of a single-command way to do this." I don't, either, except to write a script to provide one. Assuming you use Bash, save the script below as, e.g. unlock-and-mount, make it executable, and put it in a directory in your PATH. You will then be able to unlock and mount a device in one step with unlock-and-mount /dev/disk/by-id/my-device.

Warning: this relies on parsing the messages udisksctl sends to stdout. Such parsing could break in the future, according to the udisksctl man page, which says:

[This] program is not intended to be used by scripts or other programs - options/commands may change in incompatible ways in the future even in maintenance releases.

In the meantime, here is the script, which works for now:

#!/usr/bin/env bash
# A convenience wrapper around `udisksctl`.

# Trace execution 
set -x

# Abort on errors. (I find this helpful, despite the cautions given in
# http://mywiki.wooledge.org/BashFAQ/105 and
# http://mywiki.wooledge.org/BashFAQ/112 .)
set -e
set -u

# Define functions
die () {
    echo >&2 "$@"
    exit 1
}

# Validate input argument(s) 
[[ "$#" -eq 1 ]] || die "Exactly 1 argument required: path to partition ID. $# given"
[[ -b "$1" ]]    || die "$1 is not a block device"
[[ "$1" == /dev/disk/by-id/* ]] || die "$1 does not begin '/dev/disk/by-id/'"

# Unlock partition
unlockedpart="$(udisksctl unlock -b "$1" |\
 tail -n1 |\
 sed -e 's/^Unlocked \/dev\/[[:print:]]\+ as \([[:print:]]\+\).$/\1/' \
)"

# Mount unlocked partition
udisksctl mount -b "$unlockedpart"
2 added 620 characters in body
source | link
1
source | link