Capturing disk images within Kubernetes
• Mark Eschbach
Long story short we got a lot of DVDs sitting around. DVDs are inconvient to play and the player we have is loud. So digitizing is the next steps. I have a k8s service which listens to DBus events but now is the hard part: actually copying the disks.
On the host the most simple case is using something like
dd if=/dev/dvd0 of=/some/storage/path bs=2048 to actually
produce the image. Beyond that there are the following problems:
- Playback - We’ll use our Synology device + Chromecast. We know this works with actual movies we have shot however I will have to verify this works with image captures!
- Metadata - Knowing what to name the image is important. Probably have separate locations for DVDs versus game disks in the future.
However those are future Mark problems. First up is actually building a container capable of capturing a disk. Does
dd even exist in a Ubuntu container?
metal$ docker run -it --rm ubuntu:21.04 container$ dd stdin< <control-c> stdout> 0+0 records in stdout> 0+0 records out stdout> 0 bytes copied, 1.35843 s, 0.0 kB/s
Well that confirms it does. Under the host operating system, Ubuntu 20.10 the particular drive appears at
as stated by
lsblk. Oddly enough this works in both the container and host. To gain access to the device I attached
-v /dev/sr0:/host/dev/r0 to the container.
dd if=/host/dev/sr0 of=test.img bs=2048 work? Looks like no:
dd: failed to open '/host/dev/sr0': Operation not permitted.
--privileged flag did allow
dd to perform the copy at 8.9 MB/s which is woefully slow. Well…after
experimenting the best I could get consistently is 5.2 MB/s using ` dd if=/host/dev/sr0 of=test.img ibs=2048 obs=4096 iflag=direct oflag=direct count=1238672 status=progress`
. Which feels super slow but I guess considering 1x DVD reading is at 1.3 MB/s
I suppose read speeds could be worse as it appears like the disk is being read at 4x.
I tried a few different commands, including
eject -X 125 /dev/sr0 on both the host and in the container without luck.
hdparm -I /dev/sr0 gives errors and unknown info warnings so I am not likely to attempt that. Overall I’ll start with
dd command variation and possibly expriment in the future. The problem may actually be the disk itself.