this post was submitted on 10 Mar 2025
1 points (100.0% liked)

It's A Digital Disease!

21 readers
1 users here now

This is a sub that aims at bringing data hoarders together to share their passion with like minded people.

founded 2 years ago
MODERATORS
 
The original post: /r/datahoarder by /u/mofosyne on 2025-03-10 13:07:50.

Aiming to create a script that would create a pure UDF iso (So can burn 4gb+ video etc...) to a bluray disc with extra protection via dvdisaster.

Just can't figure the issue out. Got 'wrong fs type, bad option, bad superblock on /dev/loop1, missing codepage or helper program, or other error.' mount error.

Is this due to some linux kernel restriction on UDF?

Have a look and see if it makes sense to you.


!/bin/bash
==========

Blu‑ray Archival Script
=======================

Warning: Not working... got 'wrong fs type, bad option, bad superblock on /dev/loop1, missing codepage or helper program, or other error.' mount error
======================================================================================================================================================

This script creates a blank UDF image sized for Blu‑ray media,
==============================================================

formats it using mkudffs, and optionally mounts it for copying files.
=====================================================================

It is intended for archival to Blu‑ray only.
============================================

Usage: ./create\_bluray\_udf.sh <source\_folder> [<image\_name>]
================================================================

Check for required dependencies
===============================

for cmd in mkudffs dvdisaster sudo dd truncate; do
 if ! command -v "$cmd" &> /dev/null; then
 echo "Error: $cmd is not installed. Please install it."
 exit 1
 fi
done

Check for correct number of arguments
=====================================

if [ "$#" -lt 1 ]; then
 echo "Got $# args"
 echo "Usage: $0 <source\_folder> [<image\_name>]"
 exit 1
fi

Get Source Folder
=================

SOURCE\_FOLDER="$1"

Derive default folder name from the source folder
=================================================

DEFAULT\_FOLDER\_NAME=${SOURCE\_FOLDER%/}
DEFAULT\_FOLDER\_NAME=${DEFAULT\_FOLDER\_NAME##\*/}

Generate a default disc title from the folder name
==================================================

DEST*TITLE=$(echo "$DEFAULT\_FOLDER\_NAME" | sed 's/[^*]+/\L\u&/g' | sed 's/\_/ /g')

Get destination image; if not specified, default to <foldername>.udf
====================================================================

DEST\_IMAGE=${2:-${DEFAULT\_FOLDER\_NAME}.udf}

echo "SOURCE\_FOLDER = $SOURCE\_FOLDER"
echo "DEFAULT\_FOLDER\_NAME = $DEFAULT\_FOLDER\_NAME"
echo "DEST\_TITLE = $DEST\_TITLE"
echo "DEST\_IMAGE = $DEST\_IMAGE"

mkudffs settings for Blu‑ray
============================

MEDIA\_TYPE=bdr # bdr – BD-R (Blu-ray Disc Recordable)
UDF\_REV=2.60 # Use highest supported UDF version (Blu-ray requires UDF 2.50+)
echo "MEDIA\_TYPE = $MEDIA\_TYPE"
echo "UDF\_REV = $UDF\_REV"

Calculate the size needed (in bytes) for the source folder and add 10% overhead
===============================================================================

RAW\_SIZE=$(du -sb "$SOURCE\_FOLDER" | cut -f1)
OVERHEAD=$(echo "$RAW\_SIZE \* 0.10" | bc -l | cut -d. -f1)
TOTAL\_SIZE=$(echo "$RAW\_SIZE + $OVERHEAD" | bc)

echo "Source folder size: $RAW\_SIZE bytes"
echo "Caculate 10% UDF metadata overhead: $OVERHEAD bytes"
echo "Allocating image size (with overhead): $TOTAL\_SIZE bytes"

Create a blank file of the calculated size
==========================================

echo "Creating blank image file..."
truncate -s "$TOTAL\_SIZE" "$DEST\_IMAGE"
if [ $? -ne 0 ]; then
 echo "Error: Failed to create blank image file."
 exit 1
fi

Format the blank image as a UDF filesystem using mkudffs
========================================================

echo "Formatting image as UDF..."
mkudffs --media-type=$MEDIA\_TYPE --udfrev=$UDF\_REV --label="$DEST\_TITLE" "$DEST\_IMAGE"
if [ $? -ne 0 ]; then
 echo "Error: Failed to format the image with mkudffs."
 exit 1
fi

Create a temporary mount point and mount the image
==================================================

MOUNT\_POINT=$(mktemp -d)
echo "Mounting image at $MOUNT\_POINT..."
sudo mount -o loop,rw -t udf "$DEST\_IMAGE" "$MOUNT\_POINT"
if [ $? -ne 0 ]; then
 echo "Error: Failed to mount the image."
 rmdir "$MOUNT\_POINT"
 rm "$DEST\_IMAGE"
 exit 1
fi

Copy the source files into the mounted image
============================================

echo "Copying files from $SOURCE\_FOLDER to the UDF image..."
sudo cp -a "$SOURCE\_FOLDER"/. "$MOUNT\_POINT"
if [ $? -ne 0 ]; then
 echo "Error: Failed to copy files."
 sudo umount "$MOUNT\_POINT"
 rmdir "$MOUNT\_POINT"
 exit 1
fi

sync || echo "Warning: sync command failed"

Unmount the image and clean up the temporary mount point
========================================================

echo "Unmounting image..."
sudo umount "$MOUNT\_POINT"
rmdir "$MOUNT\_POINT"
echo "UDF image created at $DEST\_IMAGE"

Optional: Enhance the image with error correction using dvdisaster
==================================================================

echo "Enhancing image with error correction using dvdisaster..."
dvdisaster -i "$DEST\_IMAGE" -mRS02 -n 15% -o image
if [ $? -ne 0 ]; then
 echo "Warning: Failed to add error correction."
else
 echo "Protected image created successfully."
fi

exit 0
no comments (yet)
sorted by: hot top controversial new old
there doesn't seem to be anything here