0

I am trying to make /dev/sda a /dev/mmcblk device and the only way, I have found, is to make a /media/ mounted USB dongle installed indefinitely by making it mounted at /mnt/ instead.

But...how should I go about about using a mount point at /mnt/ for a USB Dongle that is not installed indefinitely so I can update /dev/ to handle /dev/mmcblk?

3
  • I am using debian bullseye and trying udev rules right now w/ /dev/disk/by-id/ files.
    – Mala Dies
    Oct 19, 2022 at 7:04
  • Could you add more context, for instance why the need to fake a USB disk as multimedia card? Is this a Raspberry Pi or similar SoC? What is the end goal?
    – cbugk
    Oct 19, 2022 at 9:10
  • Sure...I am trying to use a Linux Distro to handle making a SBC image. Cross-Compiling and such. My host needs to be able to handle the /dev/mmcblk file while Cross-Compiling the image.
    – Mala Dies
    Oct 20, 2022 at 22:19

1 Answer 1

0

Alright here goes nothing, let me know if this does not work.

Run with privilege script.sh:

#!/bin/bash

## Test in a directory first
#export BASE_PATH='.'
export BASE_PATH='/dev'

## Device names
export KNAME_DRIVE='sda'
export KNAME_MMC='mmcblk0'

## Character between disk kname and partition number
export PREFIX_DRIVE_PART=''
export PREFIX_MMC_PART='p'

## Symlink for device
ln -s "${BASE_PATH}/${KNAME_DRIVE}" "${BASE_PATH}/${KNAME_MMC}"

## Symlinks for partitions
# Get only two specified columns.
# Filter for desired drive.
# Prints the partition kname.
# xargs -i iterating over lines, {} being the iterator's value
# $'' increasing readability.
# ${VAR1##${VAR2}} being value of first instance of string VAR2 being substracted from string VAR1
lsblk --raw --noheadings -o NAME,KNAME \
| grep "${KNAME_DRIVE}" \
| awk -v kname_drive="${KNAME_DRIVE}" '{
    if ($1 != kname_drive) {
        print $2
    }
}' \
| xargs -i bash -c $'KNAME_DRIVE_PART="{}";
PATH_DESTINATION="${BASE_PATH}/${KNAME_DRIVE_PART}";
PATH_SYMLINK_FILE="${BASE_PATH}/${KNAME_MMC}${PREFIX_MMC_PART}${KNAME_DRIVE_PART##${KNAME_DRIVE}${PREFIX_DRIVE_PART}}";
ln -s ${PATH_DESTINATION} ${PATH_SYMLINK_FILE};
'
1
  • Hello...thank you for the script. I found out my issue. I needed hardware versus source for my particular application.
    – Mala Dies
    Nov 14, 2022 at 2:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .