Squashfs Backup Demo

by Ramses Soto-Navarro ramses@sotosystems.com, 2/1/2022

Mount squashfs file
Interactive shell
Release session
Prepare Server for Backup
SSHFS remote mount
Squash Backup


What is squashfs:

  • Squashfs is an archiver like tar.
  • Archives data onto backup file.
  • Allows quick read access of file backups.
  • High compression.
  • Can be mounted.
  • Can be appended.
  • Random seek, rather than linear.
  • Very quick access.
  • Used in embedded systems, cellphones, routers, livecd.
  • 7-zip supports squashfs.

The squashfs mount enables us to:

  • Archive the entire old server in a compressed file.
  • Mount the squashfs file and easily review files and directories.
  • Copy files from the old servers.
  • Run an interactive shell session of the old server.
  • Append more files to the backup file as needed.

Audience is experienced Linux administrators.

Mount a squashfs file

Mount an old www server squashfs file.

ssh server1
sudo su -
mkdir -p /backup/www-old
mount /backup/backup-www-old.sqfs /backup/www-old/
umount /backup/www-old

Interactive shell

Chroot into an interfactive shell.

cd /backup/cid-old
mount -o bind /dev dev
mount -o bind /sys sys
mount -o bind /proc proc
chroot . /bin/bash

Release session

umount dev
umount sys
umount proc
cd /mnt
umount /mnt/root/boot
umount /mnt/root

Prepare Server for Backup

* Start the server in rescue mode using the installation media.
* Activate Linux LVM,

vgscan ; vgchange -ay

* Mount the root directory:

mkdir -p /mnt/root
mount /dev/vg1/lvroot /mnt/root

* Mount the boot directory:

mount /dev/sda1 /mnt/root/boot

* Mount the rest of the directories:

cat /mnt/root/etc/fstab

* Activate networking:

cat /mnt/root/etc/sysconfig/network/ifcfg-eth0
cat /mnt/root/etc/sysconfig/network/routes
ifconfig eth0 netmask
route add default gw

* Activate ssh:

service sshd start

SSHFS remote mount

mkdir /mnt/oldserver
sshfs -o ro /mnt/oldserver/

Squash Backup

* Squashfs old server in rescue mode:

cd /mnt/oldserver
mksquashfs . /backup/oldserver.sqfs

The End.