xfs: race freeze and fsmap for a while to see if we livelock
[xfstests-dev.git] / crash / README
1 ############
2 # xfscrash #  crash testing setup for XFS
3 ############
4
5 *** disclaimers ***
6
7     work-in-progress, buyer-beware, your-mileage-may-vary, this-is-a-hack
8
9 *** what xfscrash does ***
10
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.
16
17 *** getting ready for crash testing ***
18
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.
23
24 *** mouting FSes read-only ***
25
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.
29
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.
34
35         # go to single user
36         init 1
37
38         # make a mount point for the ramdisk
39         mkdir /initrd
40
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 .
49
50         # make the /initrd_init directory
51         mkdir /initrd_init
52         cd /initrd_init
53
54
55         # move /dev
56         mv /dev .
57         ln -s /dev /initrd/dev
58
59         # move /etc
60         mv /etc .
61         ln -s /etc /initrd/etc
62
63         # make proc mount
64         mkdir proc 
65
66         # move /tmp
67         mkdir tmp
68         rm -rf /tmp
69         ln -s /tmp /initrd/tmp
70
71         # link /sbin 
72         ln -s /sbin .
73
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 
77
78         touch /var/run/utmp /var/log/utmp /var/log/wtmp 
79
80         # move parts of /var
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
87
88         # make a mount for /var/shm
89         mkdir var/shm 
90         ln -s /var/shm /initrd/var/shm
91
92         # move /var/spool
93         mkdir var/spool
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
96         rm -rf /var/spool
97         ln -s /var/spool /initrd/var/spool
98
99         # move /var/tmp
100         mkdir var/tmp
101         rm -rf /var/tmp
102         ln -s /var/tmp /initrd/var/tmp
103
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/<....>   
107
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
110     if you restart it.
111
112     You want to keep the contents of /initrd_init to a minimum because
113     this stuff has to fit into the ramdisk.
114
115 *** getting the ramdisk going ***
116
117     See the rc.sysinit file for some details of what to do to get the
118     ro-root/ramdisk up and running.
119
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.
122     
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.
126     
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.
130     
131 *** starting xfscrash ***
132
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
136     easy to find.
137     
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.
141
142     To configure the system, change the parameters in the configuration
143     section of the 'xfscrash' script.
144     
145     To start the system, touch the 'start' control file and then either
146     reboot or manually run the 'xfscrash' script.
147     
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
150     the test terminated.
151