Does this sync call work as expected?

Clash Royale CLAN TAG#URR8PPP
up vote
2
down vote
favorite
I'm writing a file (let's call it, xyz.bin) to a USB Flash drive... the flash drive mounts under the path: /media/myUsb ...
In order to prevent data loss, I'm doing a sync command like this:
sync -f /media/myUsb
Then, I detach/removed the flashDrive using other commands like this one: safe removal
The Problem:
The team that consumes this flashdrive is telling me that sometimes the file comes corrupt... I'm debugging my application to discard anything, but I wornder if the sync commnand is being done correctly or I just misunderstood the sync man page.
EDIT
I bring other details about the process being executed (if that helps)...
Using JAVA:
- I copy the file to the attached pendrive or flash drive.
- I call the OS commnad sync like:
sync -f /media/myUsb(using the Process Api - If the command returns OK (I wait for it using: process.waitFor()); then, I execute
udisksctl unmount -b <usbMountPoint>... If the command returns OK (again, I wait for it...) then, I execute
udisksctl power-off -b <usbDevice>If the command returns OK (again, I wait for it...) then, I assume that the writting and detaching was successful! So, I indicate to the operator to remove the pendrive or flashdrive...
Then, another team receives the pendrive and tries to read the file that was written... So times, everything works fine... other times, they said the file comes corrupt and they cannot read the file...
Right now, I'm doing different test to find where is problem... However, my doubt in here is: Are the executed OS commands being executed correctly or I just invoking something that has nosense at all?
linux command-line usb synchronization
add a comment |Â
up vote
2
down vote
favorite
I'm writing a file (let's call it, xyz.bin) to a USB Flash drive... the flash drive mounts under the path: /media/myUsb ...
In order to prevent data loss, I'm doing a sync command like this:
sync -f /media/myUsb
Then, I detach/removed the flashDrive using other commands like this one: safe removal
The Problem:
The team that consumes this flashdrive is telling me that sometimes the file comes corrupt... I'm debugging my application to discard anything, but I wornder if the sync commnand is being done correctly or I just misunderstood the sync man page.
EDIT
I bring other details about the process being executed (if that helps)...
Using JAVA:
- I copy the file to the attached pendrive or flash drive.
- I call the OS commnad sync like:
sync -f /media/myUsb(using the Process Api - If the command returns OK (I wait for it using: process.waitFor()); then, I execute
udisksctl unmount -b <usbMountPoint>... If the command returns OK (again, I wait for it...) then, I execute
udisksctl power-off -b <usbDevice>If the command returns OK (again, I wait for it...) then, I assume that the writting and detaching was successful! So, I indicate to the operator to remove the pendrive or flashdrive...
Then, another team receives the pendrive and tries to read the file that was written... So times, everything works fine... other times, they said the file comes corrupt and they cannot read the file...
Right now, I'm doing different test to find where is problem... However, my doubt in here is: Are the executed OS commands being executed correctly or I just invoking something that has nosense at all?
linux command-line usb synchronization
Related - serverfault.com/questions/115069/â¦
â slmâ¦
Aug 9 at 1:38
The sync command should do a sync of the file system. The question you mention had several answers. What exactly did you do? While a sync is a good idea, it is better to unmount the file system. Some file systems have a flag whether the file system was cleanly unmounted. Unmount will sync anyway, so sync is not necessary. What is important is that you wait for the sync or unmount to finish. This may take a long time depending on the amount of data and the speed of the USB storage.
â RalfFriedl
Aug 9 at 6:02
I would be tempted to do 2 syncs back to back (sync; sync).
â slmâ¦
Aug 9 at 13:50
@slm, according to other forums,sync; sync; syncis not necessary... (but in desperated times... XD )
â Carlitos Way
Aug 9 at 18:57
@RalfFriedl, I just edit my question to bring more details....
â Carlitos Way
Aug 9 at 18:57
add a comment |Â
up vote
2
down vote
favorite
up vote
2
down vote
favorite
I'm writing a file (let's call it, xyz.bin) to a USB Flash drive... the flash drive mounts under the path: /media/myUsb ...
In order to prevent data loss, I'm doing a sync command like this:
sync -f /media/myUsb
Then, I detach/removed the flashDrive using other commands like this one: safe removal
The Problem:
The team that consumes this flashdrive is telling me that sometimes the file comes corrupt... I'm debugging my application to discard anything, but I wornder if the sync commnand is being done correctly or I just misunderstood the sync man page.
EDIT
I bring other details about the process being executed (if that helps)...
Using JAVA:
- I copy the file to the attached pendrive or flash drive.
- I call the OS commnad sync like:
sync -f /media/myUsb(using the Process Api - If the command returns OK (I wait for it using: process.waitFor()); then, I execute
udisksctl unmount -b <usbMountPoint>... If the command returns OK (again, I wait for it...) then, I execute
udisksctl power-off -b <usbDevice>If the command returns OK (again, I wait for it...) then, I assume that the writting and detaching was successful! So, I indicate to the operator to remove the pendrive or flashdrive...
Then, another team receives the pendrive and tries to read the file that was written... So times, everything works fine... other times, they said the file comes corrupt and they cannot read the file...
Right now, I'm doing different test to find where is problem... However, my doubt in here is: Are the executed OS commands being executed correctly or I just invoking something that has nosense at all?
linux command-line usb synchronization
I'm writing a file (let's call it, xyz.bin) to a USB Flash drive... the flash drive mounts under the path: /media/myUsb ...
In order to prevent data loss, I'm doing a sync command like this:
sync -f /media/myUsb
Then, I detach/removed the flashDrive using other commands like this one: safe removal
The Problem:
The team that consumes this flashdrive is telling me that sometimes the file comes corrupt... I'm debugging my application to discard anything, but I wornder if the sync commnand is being done correctly or I just misunderstood the sync man page.
EDIT
I bring other details about the process being executed (if that helps)...
Using JAVA:
- I copy the file to the attached pendrive or flash drive.
- I call the OS commnad sync like:
sync -f /media/myUsb(using the Process Api - If the command returns OK (I wait for it using: process.waitFor()); then, I execute
udisksctl unmount -b <usbMountPoint>... If the command returns OK (again, I wait for it...) then, I execute
udisksctl power-off -b <usbDevice>If the command returns OK (again, I wait for it...) then, I assume that the writting and detaching was successful! So, I indicate to the operator to remove the pendrive or flashdrive...
Then, another team receives the pendrive and tries to read the file that was written... So times, everything works fine... other times, they said the file comes corrupt and they cannot read the file...
Right now, I'm doing different test to find where is problem... However, my doubt in here is: Are the executed OS commands being executed correctly or I just invoking something that has nosense at all?
linux command-line usb synchronization
linux command-line usb synchronization
edited Aug 9 at 18:54
asked Aug 8 at 22:46
Carlitos Way
1113
1113
Related - serverfault.com/questions/115069/â¦
â slmâ¦
Aug 9 at 1:38
The sync command should do a sync of the file system. The question you mention had several answers. What exactly did you do? While a sync is a good idea, it is better to unmount the file system. Some file systems have a flag whether the file system was cleanly unmounted. Unmount will sync anyway, so sync is not necessary. What is important is that you wait for the sync or unmount to finish. This may take a long time depending on the amount of data and the speed of the USB storage.
â RalfFriedl
Aug 9 at 6:02
I would be tempted to do 2 syncs back to back (sync; sync).
â slmâ¦
Aug 9 at 13:50
@slm, according to other forums,sync; sync; syncis not necessary... (but in desperated times... XD )
â Carlitos Way
Aug 9 at 18:57
@RalfFriedl, I just edit my question to bring more details....
â Carlitos Way
Aug 9 at 18:57
add a comment |Â
Related - serverfault.com/questions/115069/â¦
â slmâ¦
Aug 9 at 1:38
The sync command should do a sync of the file system. The question you mention had several answers. What exactly did you do? While a sync is a good idea, it is better to unmount the file system. Some file systems have a flag whether the file system was cleanly unmounted. Unmount will sync anyway, so sync is not necessary. What is important is that you wait for the sync or unmount to finish. This may take a long time depending on the amount of data and the speed of the USB storage.
â RalfFriedl
Aug 9 at 6:02
I would be tempted to do 2 syncs back to back (sync; sync).
â slmâ¦
Aug 9 at 13:50
@slm, according to other forums,sync; sync; syncis not necessary... (but in desperated times... XD )
â Carlitos Way
Aug 9 at 18:57
@RalfFriedl, I just edit my question to bring more details....
â Carlitos Way
Aug 9 at 18:57
Related - serverfault.com/questions/115069/â¦
â slmâ¦
Aug 9 at 1:38
Related - serverfault.com/questions/115069/â¦
â slmâ¦
Aug 9 at 1:38
The sync command should do a sync of the file system. The question you mention had several answers. What exactly did you do? While a sync is a good idea, it is better to unmount the file system. Some file systems have a flag whether the file system was cleanly unmounted. Unmount will sync anyway, so sync is not necessary. What is important is that you wait for the sync or unmount to finish. This may take a long time depending on the amount of data and the speed of the USB storage.
â RalfFriedl
Aug 9 at 6:02
The sync command should do a sync of the file system. The question you mention had several answers. What exactly did you do? While a sync is a good idea, it is better to unmount the file system. Some file systems have a flag whether the file system was cleanly unmounted. Unmount will sync anyway, so sync is not necessary. What is important is that you wait for the sync or unmount to finish. This may take a long time depending on the amount of data and the speed of the USB storage.
â RalfFriedl
Aug 9 at 6:02
I would be tempted to do 2 syncs back to back (
sync; sync).â slmâ¦
Aug 9 at 13:50
I would be tempted to do 2 syncs back to back (
sync; sync).â slmâ¦
Aug 9 at 13:50
@slm, according to other forums,
sync; sync; sync is not necessary... (but in desperated times... XD )â Carlitos Way
Aug 9 at 18:57
@slm, according to other forums,
sync; sync; sync is not necessary... (but in desperated times... XD )â Carlitos Way
Aug 9 at 18:57
@RalfFriedl, I just edit my question to bring more details....
â Carlitos Way
Aug 9 at 18:57
@RalfFriedl, I just edit my question to bring more details....
â Carlitos Way
Aug 9 at 18:57
add a comment |Â
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f461395%2fdoes-this-sync-call-work-as-expected%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Related - serverfault.com/questions/115069/â¦
â slmâ¦
Aug 9 at 1:38
The sync command should do a sync of the file system. The question you mention had several answers. What exactly did you do? While a sync is a good idea, it is better to unmount the file system. Some file systems have a flag whether the file system was cleanly unmounted. Unmount will sync anyway, so sync is not necessary. What is important is that you wait for the sync or unmount to finish. This may take a long time depending on the amount of data and the speed of the USB storage.
â RalfFriedl
Aug 9 at 6:02
I would be tempted to do 2 syncs back to back (
sync; sync).â slmâ¦
Aug 9 at 13:50
@slm, according to other forums,
sync; sync; syncis not necessary... (but in desperated times... XD )â Carlitos Way
Aug 9 at 18:57
@RalfFriedl, I just edit my question to bring more details....
â Carlitos Way
Aug 9 at 18:57