Changes

18 bytes added ,  23:56, 16 August 2012
m
Updated mksquashfs line
Line 6: Line 6:  
Step 1: Get access to read-write base image, note that I got loop2 and loop3 here, YMMV.  
 
Step 1: Get access to read-write base image, note that I got loop2 and loop3 here, YMMV.  
 
  <nowiki>mkdir squashfs
 
  <nowiki>mkdir squashfs
mount -o loop /run/media/*/LIVE/LiveOS/squashfs.img squashfs/
+
mount -o loop /run/media/*/LIVE/LiveOS/squashfs.img squashfs/
cp squashfs/LiveOS/ext3fs.img .</nowiki>
+
cp squashfs/LiveOS/ext3fs.img .</nowiki>
    
Step 2: Set up loopback and device mapper devices for persistent overlay, base device mapper and snapshot.
 
Step 2: Set up loopback and device mapper devices for persistent overlay, base device mapper and snapshot.
 
  <nowiki>losetup -f ext3fs.img  
 
  <nowiki>losetup -f ext3fs.img  
losetup -f /run/media/*/LIVE/LiveOS/overlay-*  
+
losetup -f /run/media/*/LIVE/LiveOS/overlay-*  
echo 0 $(blockdev --getsize /dev/loop2) linear /dev/loop2 0 |dmsetup create orig
+
echo 0 $(blockdev --getsize /dev/loop2) linear /dev/loop2 0 |dmsetup create orig
echo 0 $(blockdev --getsize /dev/mapper/orig) snapshot /dev/mapper/orig /dev/loop3 p 8 | dmsetup create top</nowiki>
+
echo 0 $(blockdev --getsize /dev/mapper/orig) snapshot /dev/mapper/orig /dev/loop3 p 8 | dmsetup create top</nowiki>
    
Step 3: Stop the snapshot device and merge the snapshot with the base
 
Step 3: Stop the snapshot device and merge the snapshot with the base
 
  <nowiki>dmsetup suspend top
 
  <nowiki>dmsetup suspend top
echo 0 $(blockdev --getsize /dev/loop2) snapshot-merge /dev/loop2 /dev/loop3 p 8 | dmsetup create mergeomatic && dmsetup status mergeomatic
+
echo 0 $(blockdev --getsize /dev/loop2) snapshot-merge /dev/loop2 /dev/loop3 p 8 | dmsetup create mergeomatic && dmsetup status mergeomatic
dmsetup status
+
dmsetup status
dmsetup remove mergeomatic</nowiki>
+
dmsetup remove mergeomatic</nowiki>
    
Step 4: Set the top device to no snapshot, and inspect the filesystem for results, if desired.
 
Step 4: Set the top device to no snapshot, and inspect the filesystem for results, if desired.
 
  <nowiki>echo 0 $(blockdev --getsize /dev/loop2) linear /dev/loop2 0 | dmsetup load top
 
  <nowiki>echo 0 $(blockdev --getsize /dev/loop2) linear /dev/loop2 0 | dmsetup load top
dmsetup resume top
+
dmsetup resume top
mkdir root
+
mkdir root
mount /dev/mapper/top root
+
mount /dev/mapper/top root
cd root
+
cd root
chroot .</nowiki>
+
chroot .</nowiki>
    
Step 5: Clean up.
 
Step 5: Clean up.
 
  <nowiki>cd ..
 
  <nowiki>cd ..
umount root
+
umount root
dmsetup remove top
+
dmsetup remove top
dmsetup remove orig
+
dmsetup remove orig
losetup -d /dev/loop2
+
losetup -d /dev/loop2
losetup -d /dev/loop3
+
losetup -d /dev/loop3
umount squashfs/</nowiki>  
+
umount squashfs/</nowiki>  
    
Step 6: Copy the root filesystem image back into the squashfs image, you may need -noappend  
 
Step 6: Copy the root filesystem image back into the squashfs image, you may need -noappend  
 
  <nowiki>mkdir LiveOS
 
  <nowiki>mkdir LiveOS
mv ext3fs.img LiveOS
+
mv ext3fs.img LiveOS
mksquashfs LiveOS/ext3fs.img /run/media/*/LIVE/LiveOS/squashfs.img -noappend</nowiki>
+
rm /run/media/*/LIVE/LiveOS/squashfs.img
 +
mksquashfs LiveOS /run/media/*/LIVE/LiveOS/squashfs.img -keep-as-directory</nowiki>