I wrote this script to make my sd-card mount to my chosen mount point when mounting my device inside pcmanfm.
It applies equally to Thunar.
When you see
/run/media/$USER/3456-7890/
in pcmanfm (or thunar)
3456-7890 is the mount point pcmanfm is using.
This can be changed.
This "3456-7890" number is not randomly generated or invented somehow by pcmanfm.
It is a property of the device being mounted. In this case an sd-card.
If the sd-card disk is formatted as
- exfat, "3456-7890" is the disk label on the sd-card and this is where pcmanfm takes this number from
- ext3 or ext4, "3456-7890" is the disk UUID, on the sd-card and this is where pcmanfm takes this number from
If you use
sudo blkid
at the command line with your sd-card/ device mounted you will see this information for yourself.
The script I wrote below changes the default disk label, or UUID, of the sd-card/ your device to your chosen disk 'ID' and is fairly self explanatory.
Run it from the top, bit by bit, until you can see what it is doing.
#!/bin/bash
clear screen
clear
my existing disk label or UUID
Change this to your existing mount point
grab it from pcmanfm or from using blkid at the command line
current_UUID="3456-7890" # sd-card in T440s laptop
#current_UUID="3434-3533" # sd-card in T430 laptop
set the new desired disk ID here
this will be the new mount point after you run the script
new_UUID="SDC-256GB"
install e2fsprogs if not already installed
if ! pacman -Qq e2fsprogs >/dev/null 2>&1; then
sudo pacman -S e2fsprogs
else
echo; echo "e2fsprogs is already installed"; echo
fi
install util-linux-libs if not already installed
if ! pacman -Qq util-linux-libs >/dev/null 2>&1; then
sudo pacman -S util-linux-libs
else
echo; echo "util-linux-libs is already installed"; echo
fi
see the UUID and mount points of all devices
echo;echo;echo " ... all devices info shown below ..."
sudo blkid
echo; echo
show our sd card, all information
echo; echo " ... our device only ..."
sudo blkid | grep "$current_UUID"
echo; echo
get the mount point of the device
echo; echo " ... the actual mount point of our device ... "
sudo blkid | grep "$current_UUID" | grep -oE "^.:" | sed 's/://g'
mpd="$(sudo blkid | grep "$current_UUID" | grep -oE "^.:" | sed 's/://g')"
echo; echo "... the mount point we need to use to change the UUID..."
sudo blkid | grep "$current_UUID" | grep -oE "^.:" | sed 's/p1://g' | sed 's/p0://g'
mpdc="$(sudo blkid | grep "$current_UUID" | grep -oE "^.:" | sed 's/p1://g' | sed 's/p0://g' )"
echo
unmount or make sure our device is unmounted
sudo umount $mpd
echo; echo "... changing the UUID"
file_system_type="$(blkid | grep $current_UUID | grep -oE "TYPE="[a-zA-Z0-9]{1,20}"" | sed 's/TYPE="//g' | sed 's/"//g')"
if [[ "$file_system_type" = "ext4" ]] || [[ "$file_system_type" = "ext3" ]]; then
# for ext3 and ext4 file systems
# set the new UUID to be specific
sudo tune2fs "$mpd" -U "$new_UUID"
# set the new UUID to be random
#### sudo tune2fs "$mpd" -U random
fi
echo;
if [[ "$file_system_type" = "exfat" ]]; then
# for exfat file systems
sudo exfatlabel "$mpd" "$new_UUID"
fi
mount the disk
make dir "$new_UUID" if it did not already exist
sudo mkdir -p /run/media/$USER/"$new_UUID";
moiunt the disk
sudo mount /dev/"$mpd" /run/media/$USER/"$new_UUID"
test to check it worked
echo; echo " ... this should show new UUID ..."
blkid | grep "$new_UUID"
echo; echo
nobootwait
option, look at this answer http://askubuntu.com/questions/120/how-do-i-avoid-the-s-to-skip-message-on-boot – TuKsn May 06 '14 at 09:32