March 18, 20242 yr Hi. I've got a general question around file copying. I've got a small backup script that I run that uses rsync to keep a backup of my media files up to date on a seperate (unassigned - aka not in the array or cache) hard drive in my Unraid server. Unconventional I know, and probably un-needed with the parity drive, but it's been more a case of playing around with the server, NAS, Linux etc. as this is all fairly new to me. Anyway, the script runs, does the backup no problem, and once it's finished, I can see the write count on the backup disk still increments aftrwards (it seems to jump at the end - presumably when the unmount is done). Having done a little research in the past, I know write counts can go up after the action has seemingly completed due to the files being written to RAM first, and then copied to the disk, so there's (apparently) a delay between rsync thinking the file is copied, and the actual data blocks making it onto the hard drive. All perfectly normal and nothing to be worried about. However... As the backup drive is unassigned, and is a normal (non-NAS) hard drive, I don't necessarily want to keep it spinning and mounted after the backup has finished. To that end, my script originally utilised rc.unassigned umount after the rsync to unmount the drive. This worked fine, and the hard drive was unmounted. But it got me thinking - if the system is still copying files from RAM to the backup drive, and I issue the unmount command, is it going to mean the backup doesn't finish ? Is that jump in the writes at the end of the script due to the unmount being delayed until all the data blocks are written ? Should I put a delay in between the rsync and unmount ? Is there a better way to do it ? Am I talking complete rubbish ? Tl;dr - if a file is being copied to a disk and the disk is unmounted, will the file still be copied in full before the unmount is actioned, or will it potentially abourt the write before completion ? Edited March 18, 20242 yr by BlueFolf spelling
March 18, 20242 yr Community Expert Read here and see if this answers your questions: https://man7.org/linux/man-pages/man8/umount.8.html I suspect it waits because of the problems with unclean shutdowns that folks have with the array not being able to be stopped before a forced shutdown is initialized. (The force shutdown was required because otherwise the system would remained trapped between running and shutdown or rebooted. Even though a forced shutdown is messy and forces a parity check on restart, that was deemed preferable to the suspended state.)
March 18, 20242 yr Community Expert 29 minutes ago, BlueFolf said: if a file is being copied to a disk and the disk is unmounted, Then unmount should not complete until all data in RAM is written to the device, you also invoke a sync command before the unmount, then it should unmount immediately.
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.