LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 12-25-2020, 04:24 AM   #1
Nishanth1829
LQ Newbie
 
Registered: Dec 2020
Posts: 3

Rep: Reputation: Disabled
Backup data to Pendrive with c program


Hi all,
I am using a GTK C program in my embedded linux device. I need to backup a folder from my internal memory to pendrive when a button is clicked on the UI. While this, the pendrive is getting mounted as /dev/sda1 and I able to copy files to the /dev/sda1 and after this write cycle from my program, the pendrive volume becomes busy and I am unable to eject it. So when I remove and insert the pendrive, it is getting detected as /dev/sdb1. As the mount location is changing dynamically, I am stuck on how to write my files to pendrive from GTK C program. I am using libudev for pendrive insertion and removal detection.

Is my way correct? If not kindly help me with how to copy a folder from internal memory to pendrive without making the volume busy.

Thanks for your time.
Regards,
Nishanth
 
Old 12-25-2020, 06:25 AM   #2
berndbausch
LQ Addict
 
Registered: Nov 2013
Location: Tokyo
Distribution: Mostly Ubuntu and Centos
Posts: 6,316

Rep: Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002
Quote:
Originally Posted by Nishanth1829 View Post
Is my way correct?
I don't think we can answer this question, since we know too little of your program. Questions I have:

Are you writing to the storage device directly, or to a filesystem on the storage device?
What do you mean by "busy" and how do you know it is busy?
Are there relevant kernel messages?
Quote:
If not kindly help me with how to copy a folder from internal memory to pendrive without making the volume busy.
I would put a filesystem on the pendrive. FAT has the advantage that you can read the drive on other OSs than Linux. ext4 has the advantage of supporting the Linux permissions concept.
Then mount the pendrive to a directory and just copy. To ensure you mount the correct device and avoid confusion between sda and sdb, use the filesystem's UUID for mounting or create a label and use that.

Last edited by berndbausch; 12-25-2020 at 06:26 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to backup nicely a part of HDD's data dirs into a pendrive ? brodo Slackware 5 08-11-2017 03:07 PM
Backup using dd a SD of a plug while it is running to an usb pendrive? Xeratul Linux - General 5 09-23-2012 04:45 PM
Config. of a pendrive DSL installation -works but the Backup utility gives me trouble Benny7440 Linux - Newbie 0 07-11-2009 05:13 PM
lunix command to copy backup file from desktop to pendrive sainiurk Linux - Newbie 1 03-25-2008 05:11 AM
How to install and configure grub on pendrive while os' are on the same pendrive? CeremCem DamnSmallLinux 0 11-07-2006 11:10 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 06:17 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration