2 # xfscrash # crash testing setup for XFS
7 work-in-progress, buyer-beware, your-mileage-may-vary, this-is-a-hack
9 *** what xfscrash does ***
11 xfscrash allows realistic testing of XFS log recovery and XFS check/repair
12 by generating log activity on an XFS partition, then rebooting the machine
13 at a random point. When the machine comes back up, xfscrash is restarted
14 and then tests either the log recovery or xfs_repair on the dirtied
15 filesystem. All going well the process continues.
17 *** getting ready for crash testing ***
19 Most filesystems (ext2 included) can't withstand having the machine
20 they're running on rebooted while they're active. So the crash test
21 machine needs to have all filesystems other than the test FS mounted
22 read-only so they won't get trashed when the machine reboots.
24 *** mouting FSes read-only ***
26 Following is a recipe for making a redhat linux (6.2) machine with a single
27 ext2 FS mounted on root able to be booted read-only. Your Mileage May
28 Vary - don't try this on an important machine.
30 The idea is to move anything that needs to be r/w into the /initrd_init
31 directory, replacing the moved directories with links to the moved ones.
32 That way the /initrd_init directory may be copied to a ramdisk, and
33 mounted over /initrd on the root FS which never gets remounted r/w.
38 # make a mount point for the ramdisk
41 # link across to the /initrd_init directory for when
42 # the ramdisk isn't mounted
43 ln -s /initrd_init/dev .
44 ln -s /initrd_init/etc .
45 ln -s /initrd_init/proc .
46 ln -s /initrd_init/sbin .
47 ln -s /initrd_init/tmp .
48 ln -s /initrd_init/var .
50 # make the /initrd_init directory
57 ln -s /dev /initrd/dev
61 ln -s /etc /initrd/etc
69 ln -s /tmp /initrd/tmp
74 # setup a tree for parts of /var
75 mkdir var var/cache var/lock var/lock/console var/lock/subsys
76 mkdir var/log var/preserve var/run
78 touch /var/run/utmp /var/log/utmp /var/log/wtmp
81 rm -rf /var/cache /var/lock /var/log /var/preserve /var/run
82 ln -s /initrd/var/cache /var/cache
83 ln -s /initrd/var/lock /var/lock
84 ln -s /initrd/var/log /var/log
85 ln -s /initrd/var/preserve /var/preserve
86 ln -s /initrd/var/run /var/run
88 # make a mount for /var/shm
90 ln -s /var/shm /initrd/var/shm
94 mkdir var/spool/mail var/spool/anacron var/spool/at var/spool/lpd
95 mkdir var/spool/rwho var/spool/mqueue var/spool/cron
97 ln -s /var/spool /initrd/var/spool
102 ln -s /var/tmp /initrd/var/tmp
104 # trim /dev - too many inodes here - remove anything you don't need
105 # (small ramdisk has a small number of inodes)
106 rm -rf /initrd/dev/<....>
108 All going well, all the directories you've made should link through
109 /initrd and into /initrd_init, and the machine should come back up
112 You want to keep the contents of /initrd_init to a minimum because
113 this stuff has to fit into the ramdisk.
115 *** getting the ramdisk going ***
117 See the rc.sysinit file for some details of what to do to get the
118 ro-root/ramdisk up and running.
120 Once everything is going, the root FS should never be remounted to
121 r/w on boot and should be in r/o mode when the machine comes up.
123 All going well, any open files have been redirected through the
124 symlinks onto the ramdisk, so you should be able to remount the
125 root FS to r/w and then remount it back to r/o.
127 Since there's no r/w filesystems mounted, it should be ok to
128 reboot the machine with 'reboot -fn' and everything should come
129 back without dirty filesystems and without having to fsck.
131 *** starting xfscrash ***
133 The simplest way to restart xfscrash on reboot is to start it
134 in the background from rc.local. The script logs to /dev/tty1,
135 /dev/console & a logfile by default, so the output should be
138 Link the xfscrash directory off an NFS mounted FS so you can make
139 changes while the machine is rebooting and so you can touch the
140 'stop' and 'start' control files.
142 To configure the system, change the parameters in the configuration
143 section of the 'xfscrash' script.
145 To start the system, touch the 'start' control file and then either
146 reboot or manually run the 'xfscrash' script.
148 To stop the system, touch the 'stop' control file and wait for the
149 next cycle to start when the control file will be checked and