# Load the driver,See note 1
Modprobe DM-mirror
# Creating a device,See Note 2
Mknod/dev/Zero C 1 5
Mknod/dev/loop0 B 7 0
Mknod/dev/loop1 B 7 1
Mknod/dev/loop2 B 7 2
Mkdir/dev/cow
Mknode/dev/cow/ctl B 241 255
Mknode/dev/cow/0 B 241 0
# Mount the squash root file system. After mounting, you can find the rootfs file under/realroot/mnt,See note 3
Mount/realroot/mnt/squashrootfs/realroot/mnt/-o loop
# Set rootfs as a loop device,See note 4
Losetup/dev/loop1/realroot/mnt/rootfs
# Create cowfile. Out and mount it as a loop device. All future write operations will be written to cowfile. Out.
Dd If =/dev/Zero of =/realroot/mnt/cowfile. out BS = 2 k COUNT = 137500
Losetup/dev/loop2/realroot/mnt/cowfile. Out
# Combine/realroot/mnt/rootfs and/realroot/mnt/cowfile. Out to create a logical root file device,
# The device file is/dev/mapper/root_fs ,,See note 5
Echo "0 $ (blockdev -- getsize/dev/loop1) Snapshot/dev/loop1/dev/loop2 P 64" |
DMSetup create root_fs
# Mount the logical root file device/dev/mapper/root_fs created above to view a readable and writable root file system.
Mount/dev/mapper/root_fs/realroot/mnt/Image
# Switch to the final root file system that can be read and written
CD/realroot/mnt/Image
Chroot./sbin/init-I
The main command used by squash to compress the file system structure:
Mknod:Create squash compressed file system
Losetup:Set and control the loop device
Chroot:Change root directory
DMSetup:Low-level logical volume Management