fredx181 wrote: ↑Thu Jul 18, 2024 2:20 pm
Instead of the script from first post, here's a script that will just add the bootfrom partition in Thunar Devices list (the rest of the partitions showing will stay according to the standard gvfs-mount configuration):
Depends on existing symlink /mnt/home (which is by default created from the initrd, if all is well).
This is almost irrelevant to your posts, but I thought you being good scripters might find my little interactive mount scripts amusing. I find them very effective for my uses.
They grep devices and filter colorized output in the terminal and prompt for what drive to mount or unmount. There are four scripts to mount either to /mnt or /run/media/root, or unmount from /mnt or /run/media/root.
I use them in KL's and puppies and they seem to work just fine. They only probe for certain devices, and not every possible device. The drives mounted to /mnt won't show up in devices in Thunar however.
In a KLV airedale I might plug in a USB drive which will show up on the Xfce desktop unmounted. If I run the following cmntdev
script, I can see a colorized list of the devices and labels, also mountpoints in /mnt, and then be prompted to mount one, which when mounted will then make the drive icon disappear from the desktop. As soon as I run the cmntudev and unmount it, it pops up on the desktop again.
So the bottom line is I can easily see what drives are attached and what drive letter they are and their label and then choose where to mount it from the terminal.
cmntdev
Code: Select all
#!/bin/bash
## Lists contents of /mnt
## Lists devices sd, mm, and sr devices found in /dev
## Prompts for [device name] to mount
## Creates /mnt/[device name] if it doesn't exist in /mnt
## Mounts to /mnt/[device name]
## Lists files in /mnt/[device name] top level and exits
## Exits if user input [device name] is not found in /dev
## Exits if [device name] already exists in /mnt and is not empty
echo ""
if [ -z "$(ls -A /mnt)" ]
then
echo -e "\e[93m/mnt:\e[0m"
echo -e " *\e[37mempty\e[0m*"
ls -CF --color=auto /mnt
elif ! [ -z "$(ls -A /mnt)" ]
then
echo -e "\e[93m/mnt:\e[0m"
ls -CF --color=auto /mnt
fi
echo ""
echo -e "\e[93m/dev:\e[0m"
echo -e " \e[35mpartition label mountpoint\e[0m"
echo -e " \e[32m========= ===== ==========\e[0m"
lsblk -o NAME,FSTYPE,LABEL,MOUNTPOINT | grep --color=auto -e mnt'/'sd'[a-z]''[0-9]' -e mnt'/'sd'[a-z]''[0-9]' -e mnt'/'mmcblk'[0-9]''[a-z]''[0-9]' -e mnt'/'sr'[0-9]' -e sd'[a-z]''[0-9]' -e mmcblk'[0-9]''[a-z]''[0-9]' -e sr'[0-9]' -e 'root/''[a-z, A-Z, 0-9]'*
echo ""
read -p "enter partition to mount: " drv2mnt
if ! [[ -e /dev/$drv2mnt ]]
then
echo ""
echo " '"${drv2mnt}"' not found as partition name"
echo "" ; exit
elif [[ -e /mnt/$drv2mnt ]] && ! [ -z "$(ls -A /mnt/$drv2mnt)" ]
then
echo ""
echo " '/mnt/"${drv2mnt}"' already exists --not empty."
echo ""
echo -e "\e[93m/mnt/"${drv2mnt}":\e[0m"
ls -CF --color=auto /mnt/$drv2mnt
echo "" ; exit
fi
if ! [[ -e /mnt/$drv2mnt ]]
then
echo ""
echo "creating directory '/mnt/"${drv2mnt}"'"
mkdir /mnt/$drv2mnt
echo "mounting '"${drv2mnt}"'"
mount /dev/$drv2mnt /mnt/$drv2mnt
if ! [ $? -eq 0 ] && [ -z "$(ls -A /mnt/$drv2mnt)" ]
then
echo "'/mnt/"$drv2mnt"' is currently empty."
rm -dv /mnt/$drv2mnt
echo ""
echo -e "\e[93m/mnt:\e[0m"
ls -CF --color=auto /mnt
echo "" ; exit
else
pid=$!
wait $pid
sleep 2
fi
elif [[ -e /mnt/$drv2mnt ]] && [ -z "$(ls -A /mnt/$drv2mnt)" ]
then
echo ""
echo "found empty directory '/mnt/"${drv2mnt}"'"
echo "mounting '"${drv2mnt}"'"
mount /dev/$drv2mnt /mnt/$drv2mnt
if ! [ $? -eq 0 ] && [ -z "$(ls -A /mnt/$drv2mnt)" ]
then
echo ""
echo " '/mnt/"$drv2mnt"' is currently empty"
echo ""
echo -e "\e[93m/mnt/"${drv2mnt}":\e[0m"
echo -e " *\e[37mempty\e[0m*"
ls -CF --color=auto /mnt/$drv2mnt
echo "" ; exit
else
pid=$!
wait $pid
sleep 2
fi
fi
if [ -z "$(ls -A /mnt/$drv2mnt)" ]
then
echo ""
echo -e "\e[93m/mnt/${drv2mnt}:\e[0m"
echo -e " *\e[37mempty\e[0m*"" \e[92m--mounted\e[0m"
ls -CF --color=auto /mnt/$drv2mnt
echo ""
elif ! [ -z "$(ls -A /mnt)" ]
then
echo ""
echo -e "\e[93m/mnt/${drv2mnt}:\e[0m"
ls -CF --color=auto /mnt/$drv2mnt
echo ""
fi
cmntudev
Code: Select all
#!/bin/bash
## Lists contents of /mnt
## Lists devices sd, mm, sr found in /dev
## Prompts for [device] to unmount
## Exits if user input [device] is not found in /mnt
## Unmounts /mnt/[device]
## Removes /mnt/[device] if empty after unmount
## List contents of /mnt/[device] if not empty after unmount
echo ""
if [ -z "$(ls -A /mnt)" ]
then
echo -e "\e[93m/mnt:\e[0m"
echo -e " *\e[37mempty\e[0m*"
ls -CF --color=auto /mnt
elif ! [ -z "$(ls -A /mnt)" ]
then
echo -e "\e[93m/mnt:\e[0m"
ls -CF --color=auto /mnt
fi
echo ""
echo -e "\e[93m/dev:\e[0m"
echo -e " \e[35mpartition label mountpoint\e[0m"
echo -e " \e[32m========= ===== ==========\e[0m"
lsblk -o NAME,FSTYPE,LABEL,MOUNTPOINT | grep --color=auto -e mnt'/'sd'[a-z]''[0-9]' -e mnt'/'sd'[a-z]''[0-9]' -e mnt'/'mmcblk'[0-9]''[a-z]''[0-9]' -e mnt'/'sr'[0-9]' -e sd'[a-z]''[0-9]' -e mmcblk'[0-9]''[a-z]''[0-9]' -e sr'[0-9]' -e 'root/''[a-z, A-Z, 0-9]'*
echo ""
read -p "enter partition to unmount: " drv2unmnt
if ! [ -e /mnt/$drv2unmnt ]
then
echo ""
echo " '"${drv2unmnt}"'"" not found in /mnt"
echo ""
echo -e "\e[93m/mnt:\e[0m"
ls -CF --color=auto /mnt
echo "" ; exit
fi
if [ -e /mnt/$drv2unmnt ]
then
echo ""
echo "unmounting '/mnt/"${drv2unmnt}"'"
umount /mnt/$drv2unmnt
pid1=$!
if ! [ $? -eq 0 ]
then
wait $pid1
echo -e "\e[93m/mnt:\e[0m"
ls -CF --color=auto /mnt
echo "" ; exit
fi
fi
if [ -e /mnt/$drv2unmnt ] && ! [ -z "$(ls -A /mnt/$drv2unmnt)" ]
then
sleep 1
echo " '"${drv2unmnt}"'"" is not empty."
sleep 1
echo ""
echo -e "\e[93m/mnt/""${drv2unmnt}"":\e[0m"
ls -CF --color=auto /mnt/$drv2unmnt
echo "" ; exit
fi
if [ -e /mnt/$drv2unmnt ] && [ -z "$(ls -A /mnt/$drv2unmnt)" ]
then
echo "removing empty directory '/mnt/"${drv2unmnt}"'"
sleep 1
rm -dv /mnt/$drv2unmnt
pid2=$!
wait $pid2
fi
if [ -z "$(ls -A /mnt)" ]
then
echo ""
echo -e "\e[93m/mnt:\e[0m"
echo -e " *\e[37mempty\e[0m*"
ls -CF --color=auto /mnt
echo ""
elif ! [ -z "$(ls -A /mnt)" ]
then
echo ""
echo -e "\e[93m/mnt:\e[0m"
ls -CF --color=auto /mnt
echo ""
fi
I zipped up the five scripts, there's one that just lists devices:
cmntls -- lists the devices in /dev
cmntdev -- mounts devices by drive letter to /mnt
cmntudev -- unmounts devices from /mnt
cmntlab -- mounts devices by label to /run/media/root
cmntulab -- unmounts devices from /run/media/root
you can see in the screenshot that I have a couple links in /mnt for convenience, the /vmnt link points to where I keep my mount scripts.