Created
July 24, 2025 19:19
-
-
Save michaelmrose/e4cc0c33a9f4e3a64903ae8ca7e8888a to your computer and use it in GitHub Desktop.
Revisions
-
michaelmrose created this gist
Jul 24, 2025 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,47 @@ #!/bin/bash set -e # Usage message if [ "$#" -ne 2 ]; then echo "Usage: $0 <device> <mount-point>" exit 1 fi DEVICE="$1" MOUNT_POINT="$2" # Validate device if [ ! -b "$DEVICE" ]; then echo "Error: $DEVICE is not a block device" exit 1 fi # Create mount point if it doesn't exist mkdir -p "$MOUNT_POINT" # Detect filesystem type # FSTYPE=$(blkid -o value -s TYPE "$DEVICE") FSTYPE=$(lsblk -no FSTYPE "$DEVICE") if [ -z "$FSTYPE" ]; then echo "Error: Could not detect filesystem type for $DEVICE" exit 1 fi # Get user and group info FSUID=$(id -u) FSGID=$(getent group users | cut -d: -f3) if [ -z "$FSGID" ]; then echo "Group 'users' not found, falling back to your primary group" GID=$(id -g) fi # Assemble mount options OPTS="uid=$FSUID,gid=$FSGID,umask=000" echo "Mounting $DEVICE as $FSTYPE to $MOUNT_POINT with options: $OPTS" # Perform the mount sudo mount -t "$FSTYPE" -o "$OPTS" "$DEVICE" "$MOUNT_POINT"