XMPP wago@ee.smq.io irc://irc.y0m4m4.com/waitman,isnick
Notes about Blu-ray discs on Linux and beyond. TIP: turn off powersaving functions on computer before writing a Blu-Ray Disc. If your computer goes into powersave mode while writing it can greatly slow down the writing, taking 10 or more hours to finish writing the disc (even if the computer is restored from sleep mode).
A Blu-Ray disc uses the UDF filesystem. IF you're going to make a Blu Ray disc "movie" that plays in a blu-ray player you are going to need to use UDF v 2.5 or 2.6. However Linux does not support writing UDF version greater than 2.01. (Which is used on DVD discs). If you want to write a Blu-Ray using UDF v2.5 or 2.6 you have three choices: MS Windows, Mac OS X (10.5 or greater) or NetBSD. (maybe you can port their UDF code to another BSD system if you don't want to install NetBSD.?)
But for storing data on BD-R it's not a show-stopper. We can use UDF 2.01 and make a 25 GB + (depending on disc size) Blu-Ray data disc that we can read on most computers as long as they support reading UDF filesystems v 2.01 or greater. It's basically a "big DVD"
Note: There is also UDFClient.
http://www.13thmonkey.org/udfclient/
UDFClient used to create/test the NetBSD kernel implementation of UDF filesytem. It features read and write support up to UDF 2.5
It should work on Linux, if you need UDF 2.5 support.
Creating a Blu-Ray archive
The process is to create a "virtual" UDF drive that is the size of the disc, and burn that image file to the disc.
CAVEATS: UDF filesystem is in GB not GiB. So 1MB = 1000 Bytes, (Not 1024 bytes). Also the "blocksize" is 2k, 2048 bytes. One way to create a 'coaster' out of an expensive disc is to use a 512b blocksize.
First we need some software packages: (Alpine Linux)
apk add udftoolsapk
add dvd+rw-tools
(or apt on Debian, etc, the package names are probably the same or similar)
After we put a blu-ray disc into our drive, Linux should create a /dev/sr0 and maybe even mount it. We don't want to mount it here.
Let's get size avail:
# dvd+rw-mediainfo /dev/sr0
INQUIRY: [HL-DT-ST][BD-RE WH16NS40 ][1.04]
GET [CURRENT] CONFIGURATION:
Mounted Media: 41h, BD-R SRM
Media ID: MILLEN/MR1
Current Write Speed: 4.0x4495=17984KB/s
Write Speed #0: 4.0x4495=17984KB/s
Speed Descriptor#0: 00/12219391 R@12.0x4495=53952KB/s W@4.0x4495=17984KB/s
:-[ READ BD SPARE INFORMATION failed with SK=5h/INVALID FIELD IN CDB]: I/O error
READ DISC INFORMATION:
Disc status: blank
Number of Sessions: 1
State of Last Session: empty
"Next" Track: 1
Number of Tracks: 1
READ FORMAT CAPACITIES:
unformatted: 12219392*2048=25025314816
00h(3000): 11826176*2048=24220008448
32h(0): 11826176*2048=24220008448
32h(0): 5796864*2048=11871977472
32h(0): 12088320*2048=24756879360
READ TRACK INFORMATION[#1]:
Track State: invisible incremental
Track Start Address: 0*2KB
Next Writable Address: 0*2KB
Free Blocks: 12219392*2KB
Track Size: 12219392*2KB
READ CAPACITY: 0*2048=0
Don't worry about error on blank disc.
We're going to use the 24220008448 value to avoid overrunning storage space.
So we create a temporary UDF file system to stage our disc:
create tmp file:
# truncate -s 24220008448 ./file.udf
# mkudffs --utf8 -b 2048 -l 20200801_BC1 ./file.udf
Note: the "-l" switch sets the label, which appears on the computer when you insert/mount the disc. There's a limit (16 chars?) and no spaces I believe. So don't get fancy.
Mount filesystem (make sure to mount it UDF!)
If /mnt/tmp doesn't exist you need to first create it!
# mount -t udf -oloop,rw ./file.udf /mnt/tmp/
Populate the filesystem (copy)
cp * /mnt/tmp etc
or rsync (files from src to dest)
Permissions: (we don't want everything owned by root, probably. it might be weird)
# chown -R waitman:waitman /mnt/tmp/
# chmod -R a+r /mnt/tmp
# chmod -R go-w /mnt/tmp
After you are finished building your stage drive, unmount it
# umount /mnt/tmp
Now we copy "burn" the image file to the disc
# growisofs -speed=4 -Z /dev/sr0=file.udf
Adjust "speed" to match your drive / disc spec
Here's a php script (CLI) that can be used to split up your files into "discs". (it copies to destination you specify, does not alter original files)
It "remembers" the files you already copied, so when you run it again it will skip those files.
Example use:
php -q bdrbackup.php /home/waitman/drive/Bandcamp/ Rside/d1 24220008448
php -q bdrbackup.php /home/waitman/drive/Bandcamp/ Rside/d2 24220008448
When we run it the first time it stops after it hits the limit, running it the second time (we specify disc 2 destination) it will skip the files already copied and put the remainders in d2
<?php
error_reporting(E_ERROR | E_PARSE);
$dir = $argv[1];
$dest = $argv[2];
$max = $argv[3];
if (substr($dest,strlen($dest)-1,1)=='/') $dest = substr($dest,0,strlen($dest)-1);
if (substr($dir,strlen($dir)-1,1)!='/') $dir .= '/';
$lstfile = sha1($dir);
if (file_exists($lstfile.'.json'))
{
$lst = json_decode(file_get_contents($lstfile.'.json'),true);
} else {
$lst = array();
}
$f=`find "$dir"`;
$r=explode("\n",$f);
foreach ($r as $v)
{
$chk = sha1($v);
if (!$lst[$chk])
{
$sz = filesize($v);
if ($max>$sz)
{
echo $sz."\t".$v."\n";
if (is_dir($v))
{
$x=str_replace($dir,'',$v);
if ($x!='')
system ('mkdir -p "'.$dest.'/'.$x.'"');
} else {
$x=str_replace($dir,'',$v);
$n = explode('/',$x);
array_pop($n);
$j = join('/',$n);
if (!is_dir($dest.'/'.$j))
{
system ('mkdir -p "'.$dest.'/'.$j.'"');
}
system ('cp "'.$v.'" "'.$dest.'/'.$x.'"');
}
$lst[$chk]=true;
$max -= $sz;
} else {
goto finis;
}
}
}
finis:
$fp = fopen($lstfile.'.json','w');
fwrite($fp,json_encode($lst));
fclose($fp);
echo 'finished';
Supposedly M-Disc are rated for 1,000 years life, but the technology has only been around a few years. Blu-Ray discs have only been available since about 2006. I have a few dozen Blu-Ray M-Discs in my archive, if someone can read them in the year 3000 then I guess it's solid tech. But it's hard to know where my family chain was 1,000 years ago, and where it will be 1,000 years from now.
But hey, there's a new technology which might replace Blu-Ray, it's HVD (Holographic Versatile Disc) which will store 6TB on a disc.
https://en.wikipedia.org/wiki/Holographic_Versatile_Disc
So, what does 1,000 years look like?