Re: Disk images. Was [Solved] Re: Difficulty with a shell function.
Hi,
peter@easthope.ca wrote:
> > Thomas, I cited https://en.wikipedia.org/wiki/Optical_disk_image .
> > ou read https://en.wikipedia.org/wiki/Disk_image .
debian-user@howorth.org.uk wrote:
> When I go to that URL (as shown in my browser's URL bar) I am shown the
> page accessed from the URL below, prefaced by the text "(Redirected
> from Optical disk image)"
Indeed i see the same (and did not notice when i wrote my previous
reply).
It's astounding that wikipedia shows different behavior with the same
URL. If i click on the redirection note i get to
https://en.wikipedia.org/w/index.php?title=Optical_disk_image&redirect=no
which says not much more than
"Disk Image
This page was last edited on 25 July 2008, at 18:54 (UTC)."
peter@easthope.ca quoted previously:
> "... disk image ... written to an optical disk, disk sector by disc sector
> ...".
> Not directly comparable to ext4.
ISO 9660 and UDF usually work with block size 2048. So they are the
natural candidates for being put on optical media which show this
size with their data blocks.
It seems that Linux cannot handle directly ext4 after an image with
default block size has been copied to an optical medium. A workaround
is the use of a loop device on top of the optical drive device.
I tested:
dd if=/dev/zero bs=1M count=10 of=ext4_dummy.img
/usr/sbin/mkfs.ext4 -t ext4 ext4_dummy.img
sudo mkdir /mnt/ext
sudo mount ext4_dummy.img /mnt/ext
sudo chmod a+rw /mnt/ext
echo hello >/mnt/ext/hello
dd if=/dev/urandom bs=1M count=1 of=/mnt/ext/random_bytes
ls -l /mnt/ext
This shows
-rw-r--r-- 1 thomas thomas 6 Jan 30 18:43 hello
drwx------ 2 root root 12288 Jan 30 18:39 lost+found
-rw-r--r-- 1 thomas thomas 1048576 Jan 30 18:48 random_bytes
Now i put it on a DVD+RW:
sudo umount /mnt/ext
xorriso -as cdrecord -v dev=/dev/sr0 ext4_dummy.img
After ejecting and loading the medium to kick Linux into examining its
new content, i do:
sudo mount /dev/sr0 /mnt/ext
which fails with
mount: /mnt/ext: wrong fs type, bad option, bad superblock on
/dev/sr0, missing codepage or helper program, or other error.
dmesg reports:
EXT4-fs (sr0): bad block size 1024
But
sudo losetup loop0 /dev/sr0
sudo mount /dev/loop0 /mnt/ext
ls -l /mnt/ext
yields
-rw-r--r-- 1 thomas thomas 6 Jan 30 18:43 hello
drwx------ 2 root root 12288 Jan 30 18:39 lost+found
-rw-r--r-- 1 thomas thomas 1048576 Jan 30 18:48 random_bytes
and in dmesg
EXT4-fs (loop0): mounted filesystem c0ab3f6b-a441-452c-b97f-707842654ed4
ro with ordered data mode. Quota mode: none.
Cleanup of all created file objects and DVD content:
sudo umount /mnt/ext
sudo losetup -d /dev/loop0
sudo rmdir /mnt/ext
rm ext4_dummy.img
xorriso -outdev /dev/sr0 -blank as_needed -eject all
The ISO 9660 filesystem driver of Linux can deal with device block
sizes different from 2048. So no loop device is necessary to mount an
ISO 9660 on a storage device with block size 512 or 4192.
Have a nice day :)
Thomas
Reply to: