Squashfs mounting trouble / streaming to squashfs

This is a two headed problem.

For the last decade+ I streamed dd of a partition to gzip to create compressed images in my automated backup scripts for servers.
e.g. dd if=/dev/sdX1 | gzip -c sdX1.img.gz etc.

That obviously works stellar, but I rather want to move to squashfs in order that I can read contents of the backup faster.

First Problem:

The squashfs status is as follows:

  • Currently you cannot do just
    dd if=/dev/sdX1 | squashfs -c etc.

  • In order to stream dd to a squashfs is a convoluted non sensical non-pipe command as follows
    mksquashfs squash.img -p ‘sde5_backup.img f 444 root root dd if=/dev/sdX1 bs=4M’

Anyone know of a way to PIPE dd to squasfs without the nonsensical example above (which does work) ?

Second problem.
Once I created a squashfs there is seemingly no way to mount the image inside the squash filesystem

Here is what I did (assume my partition to be backed up is /dev/sde5)

$] mksquashfs  squash.img -p 'sde5_backup.img f 444 root root dd if=/dev/sde5 bs=4M'
$] ls -l  
-rw-r--r-- 1 root root 2039283712 Mar  4 01:54 squash.img
drwxr-xr-x 2 root root         38 Mar  4 01:46 TEMP
drwxr-xr-x 2 root root       4096 Mar  4 02:04 TEMP1

So the squashed image was created.
Now to mount this squashed image I do

 mount  squash.img  TEMP

I then check to see what is in TEMP and find

$] ls -l    TEMP
total 2960966
-r--r--r-- 1 root root 4819981824 Mar  4 01:47 sde5_backup.img

So clearly the squashed file system is mounted and I can see the image of the disk.
Now to mount this diskimage fails.
e.g.

$] mount TEMP/sde5_backup.img TEMP1
mount: /archive/TEMPDIR/TEMP1: cannot mount /dev/loop1 read-only.

while

$] mount -o loop TEMP/sde5_backup.img TEMP1
mount: /archive/TEMPDIR/TEMP1: cannot mount /dev/loop1 read-only

Why am I unable to mount the image inside the squashfs.?

Looking around the web, everyone seems to be able to just mount it but not on my servers.

What am I missing ?


Linux sysadmin blog - Linux/Unix Howtos and Tutorials - Linux bash shell scripting wiki