Skip to content

Commit 2a03d59

Browse files
committed
improved documentation for 'fsremap --resume-job=N' usage, added warnings for catastrophic consequences on incorrect usage
1 parent 69a996a commit 2a03d59

File tree

2 files changed

+43
-22
lines changed

2 files changed

+43
-22
lines changed

README.md

+32-14
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,16 @@ are larger than half the device or larger than the available space.
6969

7070
### REQUIREMENTS
7171

72-
There are four requirements for fstransform to have a chance to succeed:
72+
There are five requirements for fstransform to have a chance to succeed:
7373

74-
1. the device must have a little free space, typically at least 5%
74+
1. the device must be unmountable, i.e. `umount DEVICE` must work.
75+
In particular, if some running programs are using the device,
76+
you must first close or kill them.
77+
78+
Transforming the current root directory does not work. For that, you should
79+
boot from a different installation (for example a live CD, DVD or USB).
80+
81+
2. the device must have a little free space, typically at least 5%
7582

7683
WARNING: transforming an almost full device to 'xfs' file-system
7784
can be tricky:
@@ -82,7 +89,7 @@ There are four requirements for fstransform to have a chance to succeed:
8289
before resuming fstransform.
8390
A future fstransform version may automate this operation.
8491

85-
2. the filesystem on the device must support SPARSE FILES, i.e. files with holes
92+
3. the filesystem on the device must support SPARSE FILES, i.e. files with holes
8693
(see for example http://en.wikipedia.org/wiki/Sparse_file for an explanation of what they are)
8794
and at least one of the two system calls "ioctl(FS_IOC_FIEMAP)" or "ioctl(FIBMAP)"
8895
(see the file Documentation/filesystems/fiemap.txt in any recent Linux kernel
@@ -91,37 +98,45 @@ There are four requirements for fstransform to have a chance to succeed:
9198
ioctl(FIBMAP) is limited by design to 2G-1 blocks, which typically translates to 8TB - 4kB.
9299
To transform file systems equal or larger than 8TB, ioctl(FIEMAP) is required.
93100

94-
3. the initial and final filesystems must be supported by the Linux kernel
101+
4. the initial and final filesystems must be supported by the Linux kernel
95102
(i.e. it must be able to mount them)
96103
and by the tools 'mkfs' and 'fsck'
97104
(i.e. it must be possible to create them and check them for errors)
98105

99-
4. the following programs must be available:
106+
5. the following programs must be available:
100107
the two custom-made programs 'fsmove' and 'fsremap' (distributed with the script)
101108
and several common Linux tools:
102109
which, expr, id, blockdev, losetup, mount, umount,
103110
mkdir, rmdir, rm, mkfifo, dd, sync, fsck, mkfs
104111

105112

106-
### KNOWN LIMITS
107-
108-
* If the device contains a HUGE number of files with multiple hard links,
109-
fstransform will be very slow and consume a LOT of memory.
110-
Devices with more than one million files with multiple hard links
111-
can cause fstransform to crash with "out of memory" errors.
113+
### KNOWN LIMITATIONS
112114

115+
1) As stated above, at a certain step during the conversion, fstransform needs
116+
to unmount the device being transformed.
117+
For this reason, running fstransform on the device currently mounted as /
118+
(i.e. the root directory) fails.
119+
For the same reason, running fstransform on the device currently mounted
120+
as /usr, /home or /var or similar heavily-used directories is difficult,
121+
because quite often there are programs using those, which prevents
122+
them from being unmounted.
123+
124+
2) If the device contains a HUGE number of files with multiple hard links,
125+
fstransform will be very slow and consume a LOT of memory.
126+
Devices with more than one million files with multiple hard links
127+
can cause fstransform to crash with "out of memory" errors.
113128

114-
2) JFS file systems equal or larger than 8TB cannot be converted due to
129+
3) JFS file systems equal or larger than 8TB cannot be converted due to
115130
missing support for ioctl(FIEMAP) in the kernel:
116131
the fallback ioctl(FIBMAP) is limited by design to < 8TB (assuming 4k blocks)
117132

118-
3) REISERFS file systems using format "3.5" (the default) and equal or larger than 2TB
133+
4) REISERFS file systems using format "3.5" (the default) and equal or larger than 2TB
119134
cannot be converted due to their maximum file size = 2TB - 4k:
120135
fstransform needs to create a sparse file as large as the device itself.
121136

122137
REISERFS file systems using format "3.6" are immune to this problem.
123138

124-
4) for the same reason, a device cannot be converted _to_ REISERFS format "3.5"
139+
5) for the same reason, a device cannot be converted _to_ REISERFS format "3.5"
125140
if it contains files larger than 2TB - 4k.
126141

127142

@@ -215,6 +230,9 @@ To pass the same option to 'fstransform', you must execute something like
215230
by running 'fsremap --resume-job=<MMM> {device}'.
216231
Also, 'fsremap' will show at its startup the exact command line
217232
needed to resume its execution.
233+
234+
The loop file created by fstransform must NEVER be as argument to
235+
'fsremap --resume-job=<MMM> {...}'. You would IRREVERSIBLY LOSE YOUR DATA!
218236

219237
REAL-WORLD TESTS
220238

fsremap/src/remap.cc

+11-8
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ int fr_remap::usage(const char * program_name)
117117
quit_immediately = true;
118118

119119
ff_log(FC_NOTICE, 0, "Usage: %s [OPTION]... %s %s [%s]", program_name, LABEL[0], LABEL[1], LABEL[2]);
120-
ff_log(FC_NOTICE, 0, " or: %s [OPTION]... --resume-job=JOB_ID %s", program_name, LABEL[0]);
120+
ff_log(FC_NOTICE, 0, " or: %s [OPTION]... --resume-job=JOB_ID %s", program_name, LABEL[FC_DEVICE]);
121121
ff_log(FC_NOTICE, 0, "Replace the contents of %s with the contents of %s, i.e. write %s onto %s",
122122
LABEL[FC_DEVICE], LABEL[FC_LOOP_FILE], LABEL[FC_LOOP_FILE], LABEL[FC_DEVICE]);
123123
ff_log(FC_NOTICE, 0, "even if %s is inside a file system _inside_ %s\n", LABEL[FC_LOOP_FILE], LABEL[FC_DEVICE]);
@@ -133,13 +133,14 @@ int fr_remap::usage(const char * program_name)
133133
" --clear=none (DANGEROUS) do not clear any free blocks after remapping\n"
134134
" --cmd-umount=CMD command to unmount %s (default: /bin/umount)\n"
135135
" --cmd-losetup=CMD 'losetup' command (default: /sbin/losetup)\n"
136-
" --color=MODE set messages color. MODE is one of:"
136+
" --color=MODE set messages color. MODE is one of:\n"
137137
" auto (default), none, ansi\n"
138138
#ifdef FT_HAVE_IO_PREALLOC
139139
" --device-mount-point=DIR\n"
140140
" set device mount point (needed by --io=prealloc)\n"
141141
#endif
142142
" -f, --force-run continue even if some sanity checks fail\n"
143+
" -i, --interactive ask confirmation after analysis, before actual work\n"
143144
" --io=posix use posix I/O (default)\n"
144145
#ifdef FT_HAVE_IO_PREALLOC
145146
" --io=prealloc use posix I/O with EXPERIMENTAL preallocated files\n"
@@ -163,7 +164,9 @@ int fr_remap::usage(const char * program_name)
163164
" extra: also ask confirmation before dangerous steps\n"
164165
" -q, --quiet be quiet, print less output\n"
165166
" -qq be very quiet, only print warnings or errors\n"
166-
" --resume-job=NUM resume an interrupted job\n"
167+
" --resume-job=NUM resume the interrupted job NUM. The only non-option\n"
168+
" argument must be %s. Do _not_ pass %s\n"
169+
" as argument, or you will LOSE YOUR DATA!\n"
167170
" -s, --secondary-storage=SECONDARY_SIZE[k|M|G|T|P|E|Z|Y]\n"
168171
" set secondary storage file length (default: autodetect)\n"
169172
" -t, --temp-dir=DIR write storage and log files inside DIR\n"
@@ -173,15 +176,15 @@ int fr_remap::usage(const char * program_name)
173176
" -vv be very verbose\n"
174177
" -vvv be incredibly verbose (warning: prints lots of output)\n"
175178
" -xp, --exact-primary-storage=PRIMARY_SIZE[k|M|G|T|P|E|Z|Y]\n"
176-
" set *exact* primary storage length, or fail\n"
179+
" set _exact_ primary storage length, or fail\n"
177180
" (default: autodetect)\n"
178181
" -xs, --exact-secondary-storage=SECONDARY_SIZE[k|M|G|T|P|E|Z|Y]\n"
179-
" set *exact* secondary storage length, or fail\n"
182+
" set _exact_ secondary storage length, or fail\n"
180183
" (default: autodetect)\n"
181184
" --x-OPTION=VALUE set internal, undocumented option. for maintainers only\n"
182185
" --help display this help and exit\n"
183186
" --version output version information and exit\n",
184-
LABEL[FC_DEVICE]);
187+
LABEL[FC_DEVICE], LABEL[FC_DEVICE], LABEL[FC_LOOP_FILE]);
185188
}
186189

187190

@@ -296,8 +299,8 @@ int fr_remap::init(int argc, char const* const* argv)
296299
if (!strcmp(arg, "--"))
297300
allow_opts = false;
298301

299-
/* -a, --automated run automatically without asking any confirmation */
300-
else if (!strcmp(arg, "-a") || !strcmp(arg, "--automated")) {
302+
/* -a, --no-questions run automatically without asking any confirmation */
303+
else if (!strcmp(arg, "-a") || !strcmp(arg, "--no-questions")) {
301304
args.ask_questions = false;
302305
}
303306
/* --clear=all, --clear=minimal, --clear=none */

0 commit comments

Comments
 (0)