[CentOS] Convert "bare partition" to RAID1 / mdadm?

Michael Hennebry hennebry at web.cs.ndsu.nodak.edu
Mon Jul 28 17:48:05 UTC 2014


How about something like this:
Use find to process each file with a script that does something like this:
if foo not soft link :
     if foo open for output (lsof?) :
         add foo to todo list
     else :
         make foo read-only
         if foo open for output :
             add foo to todo list
             restore foo's permissions
         else :
             copy foo to raid
             replace original with a soft link into raid
             give copy correct permissions

move the todo list to where it will not be written the script
process the todo list files with the same script making a new todo list
rinse and repeat until the todo list is empty

for the endgame, make the entire source read-only
run find again, this time there is no need for most of the tests:
if foo not soft link :
     copy foo to raid
     replace original with a soft link into raid
     give copy correct permissions

after the last copy, make the entire source unreadable and unwriteable
wait for last user to close file
rename the old files' top directory
rename the raid's top directory
let users back in

-- 
Michael   hennebry at web.cs.ndsu.NoDak.edu
"SCSI is NOT magic. There are *fundamental technical
reasons* why it is necessary to sacrifice a young
goat to your SCSI chain now and then."   --   John Woods



More information about the CentOS mailing list