#1336 PR merged: Try wipefs and use dd as fallback (issue1327 and related to issue799)

Labels: enhancement, bug, fixed / solved / done

jsmeix opened issue at 2017-04-28 14:07:

Hereby I implemented basically my proposal
https://github.com/rear/rear/issues/1327#issuecomment-296672094
and additionally now dd is used as generic fallback in any case.

I tested it on SLE12 with wipefs in the recovery system
and also without wipefs in the recovery system
(i.e. for me also the dd fallback works).

Details:

With wipefs in the recovery system
I get in diskrestore.sh

# Using wipefs to cleanup '/dev/sda2' before creating filesystem.
wipefs --all --force /dev/sda2 || wipefs --all /dev/sda2 || dd if=/dev/zero of=/dev/sda2 bs=512 count=1 || true

and in the "rear -d -D recover" log file

+ source /usr/share/rear/layout/recreate/default/200_run_script.sh
...
+++ echo -e 'Creating filesystem of type ext4 with mount point / on /dev/sda2.'
+++ wipefs --all --force /dev/sda2
+++ mkfs -t ext4 -b 4096 -i 16377 -U 46d7e8be-7812-49d1-8d24-e25ed0589e94 /dev/sda2

Without wipefs in the recovery system
I get in diskrestore.sh

# Using dd to cleanup the first 512 bytes on '/dev/sda2' before creating filesystem.
dd if=/dev/zero of=/dev/sda2 bs=512 count=1 || true

and in the "rear -d -D recover" log file

+ source /usr/share/rear/layout/recreate/default/200_run_script.sh
...
+++ echo -e 'Creating filesystem of type ext4 with mount point / on /dev/sda2.'
+++ dd if=/dev/zero of=/dev/sda2 bs=512 count=1
1+0 records in
1+0 records out
512 bytes copied, 0.00146513 s, 349 kB/s
+++ mkfs -t ext4 -b 4096 -i 16377 -U 46d7e8be-7812-49d1-8d24-e25ed0589e94 /dev/sda2

jsmeix commented at 2017-04-28 14:22:

@gdha @gozora
I added you as reviewers here mainly FYI.

If there are no furious objections I will "just merge" it soon
because from my point of view it is a noticeable improvement
even if it is not yet the ultimate solution, cf.
https://github.com/rear/rear/issues/1327#issuecomment-297014255
versus
https://github.com/rear/rear/issues/1327#issuecomment-297964501
and the generic missing functionality
https://github.com/rear/rear/issues/799

But it follows the traditional Unix philosopy "Worse is better"
that is basically "simplicity outweighs all", see
https://en.wikipedia.org/wiki/Unix_philosophy
and
https://en.wikipedia.org/wiki/Worse_is_better

jsmeix commented at 2017-04-28 14:39:

@gozora
yes, I know, you are right, the current code is not nice.
The 'wipefs*' variables should be renamed to something
like 'cleanup_disk*' and the whole current wipefs/dd code
should be cleaned up - but I have no time for that now.
So for now I only did some kind of "quick addon hack"
to make "rear recover" working a bit better in practice,
see the comments in my code (I mention "Dirty hacks" ;-)

jsmeix commented at 2017-04-28 14:43:

I removed the "cleanup" label from this pull request
because it really does not cleanup the code
(but it better cleans up the disk now ;-)


[Export of Github issue for rear/rear.]