Score:2

How to mount or unmount all partitions of a device at once using udisksctl?

it flag

I need to use udisksctl.
I tried the classic method /dev/sda?* already seen on the internet:

udisksctl mount -b /dev/sda?*

or

udisksctl unmount -b /dev/sda?*

/dev/sda?* in my case is equivalent to /dev/sda1 /dev/sda2

but udisksctl only mounts or unmounts the first partition listed /dev/sda1.
How can I make it mount or unmount all partitions at once?

Score:4
id flag

One way you can do it is to loop though the /dev/sd device partitions

for i in /dev/sd??*; do udiskctl unmount -b $i; done

If you only wanted to do /dev/sda partitions then change the first ? to a

for i in /dev/sda?*; do udiskctl unmount -b $i; done
it flag
I am only interested in partitions on the `/dev/sda` disk and not partitions on all `/dev/sd?` disks.
Terrance avatar
id flag
@MarioPalumbo Updated for just drive `/dev/sda`
it flag
Does this also work for `/dev/sda10`, `/dev/sda11`, `/dev/sda12`, `/dev/sda147`, `/dev/sda385`, `/dev/sda2706`, etc.?
it flag
Is good `/dev/sda?*` as in the question?
Terrance avatar
id flag
@MarioPalumbo Yeah, that should work. :) Updated, and I tested as well. :)
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.