<div class="gmail_quote"><font face="arial, helvetica, sans-serif">On Fri, Dec 2, 2011 at 3:46 AM, Alasdair G Kergon <span dir="ltr"><<a href="mailto:agk@redhat.com">agk@redhat.com</a>></span> wrote:</font></div><div class="gmail_quote">

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div class="im">On Thu, Dec 01, 2011 at 09:44:53PM -0600, Douglas McClendon wrote:<br>
> The commandline to do the 'edit' was requested for users like Fred, and<br>
> because I guess one day I might find myself wanting to do the same.<br>
<br>
</div>This is unsupported, but if you want to try:<br>
You need to flip the 5th byte of the 'cow' device from 0 to 1 (when<br>
the snapshot is not active).  (But you might have lost the most recent<br>
changes if they weren't flushed out when it filled up.)<br>
<br>
Something like this:<br>
<br>
# lvs<br>
  LV    VG   Attr   LSize  Origin Snap%  Move Log Copy%  Convert<br>
  lvol0 vg2  owi-a- 10.00m<br>
  lvol1 vg2  Swi-I- 10.00m lvol0  100.00<br>
<br>
# dmsetup table vg2-lvol1-cow<br>
0 20480 linear 7:0 22528<br>
<br>
# lvchange -an vg2/lvol0<br>
<br>
# dmsetup create tmp-vg2-lvol1-cow --table "0 20480 linear 7:0 22528"<br>
<br>
# hexdump -C /dev/mapper/tmp-vg2-lvol1-cow | head -1<br>
00000000  53 6e 41 70 00 00 00 00  01 00 00 00 08 00 00 00  |SnAp............|<br>
<br>
Flip byte 5, e.g. copy to file, edit that bit, copy back.<br>
  # dd if=/dev/mapper/tmp-vg2-lvol1-cow of=/tmp/cow-start bs=512 count=1<br>
  # vim -b /tmp/cow-start   (and/or xxd)<br>
  # dd if=/tmp/cow-start of=/dev/mapper/tmp-vg2-lvol1-cow<br>
<br>
# dmsetup remove tmp-vg2-lvol1-cow<br>
<br>
# lvchange -ay vg2/lvol0<br>
<br>
# lvs<br>
  LV    VG   Attr   LSize  Origin Snap%  Move Log Copy%  Convert<br>
  lvol0 vg2  owi-a- 10.00m<br>
  lvol1 vg2  swi-a- 10.00m lvol0   10.08<br>
<br>
# hexdump -C /dev/mapper/vg2-lvol1-cow | head -1<br>
00000000  53 6e 41 70 01 00 00 00  01 00 00 00 08 00 00 00  |SnAp............|<br>
<span class="HOEnZb"><font color="#888888"><br>
Alasdair<br></font></span></blockquote><div><font face="'courier new', monospace"><br></font></div><div><font face="'courier new', monospace">Thank you Alasdair and Douglas for your attention to this matter,</font></div>

<div><font face="'courier new', monospace">the recovery succeeded on my simple test case.</font></div><div><font face="'courier new', monospace"><br></font></div><div><font face="'courier new', monospace">Some reports follow:</font></div>

<div><span style="font-family: 'courier new', monospace; "><br></span></div><div><span style="font-family: 'courier new', monospace; ">I edited the 'exhausted', 100 MiB overlay file from my F16-Live test</span></div>

<div><span style="font-family: 'courier new', monospace; ">case, which </span><span style="font-family: 'courier new', monospace; ">had been made Invalid by attempting to write beyond its</span></div><div>

<span style="font-family: 'courier new', monospace; ">capacity.</span></div><div><font face="'courier new', monospace"><br></font></div><div><font face="'courier new', monospace">After</font></div>

<div><span style="font-family: 'courier new', monospace; "># dmsetup create item --table "0 8388608 snapshot 7:1 7:2 P 8" --readonly</span></div><div><span style="font-family: 'courier new', monospace; "><br>

</span></div><div><div style="font-family: 'courier new', monospace; "># dmsetup status</div><div style="font-family: 'courier new', monospace; ">item: 0 8388608 snapshot 202336/204800 800</div><div style="font-family: 'courier new', monospace; ">

<br></div><div style="font-family: 'courier new', monospace; "># mount /dev/dm-0 /mnt/b/</div><div style="font-family: 'courier new', monospace; ">mount: block device /dev/mapper/item is write-protected, mounting read-only</div>

<div style="font-family: 'courier new', monospace; ">mount: wrong fs type, bad option, bad superblock on /dev/mapper/item,</div><div style="font-family: 'courier new', monospace; ">       missing codepage or helper program, or other error</div>

<div style="font-family: 'courier new', monospace; ">       In some cases useful info is found in syslog - try</div><div style="font-family: 'courier new', monospace; ">       dmesg | tail  or so</div><div style="font-family: 'courier new', monospace; ">

<div><br></div><div># dmesg |tail</div><div>[  772.461469] EXT4-fs (dm-0): INFO: recovery required on readonly filesystem</div><div>[  772.461476] EXT4-fs (dm-0): write access unavailable, cannot proceed</div></div><div style="font-family: 'courier new', monospace; ">

<br></div><div><div><font face="'courier new', monospace"># e2fsck -n /dev/dm-0 </font></div><div><font face="'courier new', monospace"><br></font></div><div><font face="'courier new', monospace">e2fsck 1.41.14 (22-Dec-2010)</font></div>

<div><font face="'courier new', monospace">Warning: skipping journal recovery because doing a read-only filesystem check.</font></div><div><font face="'courier new', monospace">_Fedora-16-x86_6 contains a file system with errors, check forced.</font></div>

<div><font face="'courier new', monospace">Pass 1: Checking inodes, blocks, and sizes</font></div><div><font face="'courier new', monospace">Inodes that were part of a corrupted orphan linked list found.  Fix? no</font></div>

<div><font face="'courier new', monospace"><br></font></div><div><font face="'courier new', monospace">Inode 17442 was part of the orphaned inode list.  IGNORED.</font></div><div><font face="'courier new', monospace">Deleted inode 156288 has zero dtime.  Fix? no</font></div>

<div><font face="'courier new', monospace"><br></font></div><div><font face="'courier new', monospace">Inode 162164 was part of the orphaned inode list.  IGNORED.</font></div><div><font face="'courier new', monospace">Pass 2: Checking directory structure</font></div>

<div><font face="'courier new', monospace">Pass 3: Checking directory connectivity</font></div><div><font face="'courier new', monospace">Pass 4: Checking reference counts</font></div><div><font face="'courier new', monospace">Pass 5: Checking group summary information</font></div>

<div><font face="'courier new', monospace">Block bitmap differences:  -(129696--129702) -(555921--557003) -(557006--557016) -(557020--557050) -557058 -(557632--557663) -559125 -560586 -(565664--565759) -(566784--566911) -(566973--566991) -(567016--567023) -(567032--567039) -(567044--567051) -(567068--567159) -567164 -(567168--567183) -(567188--567189) -(567200--567279) -(567284--567285) -(567288--567406) -(567408--567677) -(567680--567798) -(567800--567807) -567839 -(567856--567912) -(567916--567919) -567960 -567967 -580765 -(580909--580911) -580920 -(580990--580991) -(581024--581036) -(581040--581127) -592079 -606092 -(608256--608261) -608264 -608290 -(608313--608314) -608317 -(608320--608322) -608361 -608376 -608400 -608421 -608767 -(608770--608773) -608775 -608777 -608779 -(608783--608784) -(608797--608807) -608809 -608813 -608816 -(608825--608831) -608895 -608914 -(608932--608943) -609054 -609077 -609147 -609167 -609195 -609203 -609223 -(609322--609323) -(609542--609543) -(609558--609567) -(609584--609586) -(609666--609711) -609716 -(609718--609730) -(609736--609939) -609965 -(640485--640556)</font></div>

<div><font face="'courier new', monospace">Fix? no</font></div><div><font face="'courier new', monospace"><br></font></div><div><font face="'courier new', monospace">Free blocks count wrong (381446, counted=375520).</font></div>

<div><font face="'courier new', monospace">Fix? no</font></div><div><font face="'courier new', monospace"><br></font></div><div><font face="'courier new', monospace">Inode bitmap differences:  -17442 -156288 -162164</font></div>

<div><font face="'courier new', monospace">Fix? no</font></div><div><font face="'courier new', monospace"><br></font></div><div><font face="'courier new', monospace">Free inodes count wrong (165564, counted=165454).</font></div>

<div><font face="'courier new', monospace">Fix? no</font></div><div><font face="'courier new', monospace"><br></font></div><div><font face="'courier new', monospace"><br></font></div><div><font face="'courier new', monospace">_Fedora-16-x86_6: ********** WARNING: Filesystem still has errors **********</font></div>

<div><font face="'courier new', monospace"><br></font></div><div><font face="'courier new', monospace">_Fedora-16-x86_6: 96580/262144 files (0.3% non-contiguous), 667130/1048576 blocks</font></div></div><div>

<font face="'courier new', monospace"><br></font></div><div><font face="'courier new', monospace"><br></font></div><div><font face="'courier new', monospace">After removing and recreating the snapshot as read-write,</font></div>

<div><font face="'courier new', monospace"><br></font></div><div><font face="'courier new', monospace"><div># e2fsck -f -y /dev/dm-0 </div><div><br></div><div>e2fsck 1.41.14 (22-Dec-2010)</div><div>_Fedora-16-x86_6: recovering journal</div>

<div>Clearing orphaned inode 162164 (uid=0, gid=0, mode=0100644, size=10898776)</div><div>Clearing orphaned inode 17442 (uid=0, gid=0, mode=0100755, size=27520)</div><div>Clearing orphaned inode 156288 (uid=0, gid=0, mode=0100755, size=291672)</div>

<div>Pass 1: Checking inodes, blocks, and sizes</div><div>Pass 2: Checking directory structure</div><div>Pass 3: Checking directory connectivity</div><div>Pass 4: Checking reference counts</div><div>Pass 5: Checking group summary information</div>

<div><br></div><div>_Fedora-16-x86_6: ***** FILE SYSTEM WAS MODIFIED *****</div><div>_Fedora-16-x86_6: 96688/262144 files (0.3% non-contiguous), 672875/1048576 blocks</div><div><br></div><div># e2fsck -p /dev/dm-0 </div>
<div>
<br></div><div>_Fedora-16-x86_6: clean, 96688/262144 files, 672875/1048576 blocks</div><div><br></div><div># dmsetup status</div><div><br></div><div>item: 0 8388608 snapshot 202424/204800 800</div><div><br></div><div><br>

</div><div>Subsequent mounting (read-only for safety) succeeded in showing the</div><div>preexisting content.</div><div><br></div><div><br></div><div>I agree with Douglas that there is a significant class of non-technical</div>

<div>Live USB users who would benefit from a fail safe mechanism for their</div><div>content based in overlays of a read-only origin.</div><div><br></div><div>For example, students and teachers using the Sugar on a Stick Spin,</div>

<div><br></div><div><a href="http://spins.fedoraproject.org/soas/">http://spins.fedoraproject.org/soas/</a></div><div><br></div><div>have been frustrated when their portfolio of work has been 'lost'</div><div>after a couple of months of classwork.</div>

<div><br></div><div>We are working to provide better file system support, viz.,</div><div><br></div><div><a href="http://wiki.sugarlabs.org/go/LiveOS_image">http://wiki.sugarlabs.org/go/LiveOS_image</a></div><div><br></div>

<div>and any Device-mapper support would be much appreciated!</div><div><br></div><div>       --Fred</div></font></div><div><font face="'courier new', monospace"><br></font></div><div><font face="'courier new', monospace"><br>

</font></div><div style="font-family: 'courier new', monospace; "><br></div><div style="font-family: 'courier new', monospace; "><br></div><div style="font-family: 'courier new', monospace; "><br>
</div>
<div style="font-family: 'courier new', monospace; "><br></div></div><div><font face="'courier new', monospace"><br></font></div><div><br></div></div>