Auto mount

Created רביעי 11 פברואר 2015

https://help.ubuntu.com/community/AutomaticallyMountPartitions

Discover UUIDs of all disks

ls -al /dev/disk/by-uuid/

Mount

udisksctl mount --block-device /dev/disk/by-uuid/f8391b1c-f251-4ef9-989d-b65de79067f4

Bash

#!/bin/bash
uuid1="7434f21f-009d-4de9-ba58-1cb3a37e48bc"
uuid2="f8391b1c-f251-4ef9-989d-b65de79067f4"
mount1=$(udisksctl mount --block-device /dev/disk/by-uuid/$uuid1 2>&1)
if [ $? -eq 0 ]; then
    dir_name1=$(echo $(echo $mount1 | awk 'BEGIN {FS="/"}{print $(NF)}') | sed "s/\.$//")
else
    dir_name1=$(echo $(echo $mount1 | awk 'BEGIN {FS="/"}{print $(NF)}') | sed "s/'\.$//")
fi
echo "MOUNT1 $mount1"
echo "DIR1 $dir_name1"
mount2=$(udisksctl mount --block-device /dev/disk/by-uuid/$uuid2 2>&1)

if [ $? -eq 0 ]; then
    dir_name2=$(echo $(echo $mount2 | awk 'BEGIN {FS="/"}{print $(NF)}') | sed "s/\.$//")
else
    dir_name2=$(echo $(echo $mount2 | awk 'BEGIN {FS="/"}{print $(NF)}') | sed "s/'\.$//")
fi
echo "MOUNT2 $mount2"
echo "DIR2 $dir_name2"



Backlinks: