LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
LinkBack Search this Thread
Old 02-23-2010, 11:22 PM   #1
greenberet
Member
 
Registered: Jun 2006
Posts: 50

Rep: Reputation: 15
Cloning USB drives using C++


Hi,

I have a device running Linux, which has a master USB and 16 Slave USB's.
I need to make the slaves identical to the master.

What i'm doing is reading bytes from the master by reading /dev/sd{master} and writing to /dev/sd{slaves} . I am doing this since I need to display progress of the operation.

Do you think this will pose any problems? Please comment on this technique....Is there any better technique?

Also, if the source drives size is smaller than the dest drive, will it create any problem....or will the USBs still be identical after that..


Thanks.
 
Old 02-24-2010, 02:39 AM   #2
irmin
Member
 
Registered: Jan 2010
Location: the universe
Distribution: Slackware (modified), Slackware64 (modified), openSuSE (modified)
Posts: 342

Rep: Reputation: 62
Hi,

just to make sure I understood your issue: You have a device running linux, that has 17 USB ports. The purpose of this device is to make a copy of usb mass-storage devices attached to the master USB port and write those copies to the slave USB ports?

There should be no problem in doing a bit-to-bit copy of the disk contents, as long as the final disk is at least of the same size as the source disk. I assume that the disks have a DOS partition table and that there are one or more partitions on it. If the final disk is larger than the source disk, there will be just unallocated space on the disk, that can be used, if the partition table of the final disk is modified afterwards, but not necessarily. So in this situation there should be no problem.

If the final disk is smaller than the source disk, then you can have serious problems, because you cannot store all information on the final disk. Your technique will yield an invalid paritition table and this means that it contains partitions, those boundaries may lay outside the disk. In this case, the filesystems may be usable, but need not to be. Partitions, which totally fit onto the final disk, will work as before.
So you can either copy only certain partitions (note: NTFS partitions need to start at the same position on both the final and source disk!).

Another possibility is to mount all partitions on the source disk and create them on the final disks such that all files will fit in them. Then copy only the files. This method is better and more robust.
 
Old 02-24-2010, 03:00 AM   #3
greenberet
Member
 
Registered: Jun 2006
Posts: 50

Original Poster
Rep: Reputation: 15
Thanks irmin,

Since I am doing a binary Copy from master to slave....im not concerned about partitions or partitions tables......as long as the slave become byte-for-byte identical to the master...the purpose has been achieved.

I am using the linux.sysfs_path property of the device(supplied by hal-get-property) to find out which port a particular storage device occupies

For eg.

/sys/devices/pci0000:00/0000:00:1d.1/usb3/3-2/3-2:1.0/host3/target3:0:0/3:0:0:0/block/sdb

By looking at 0000:00:1d:1/usb3....I find out the port in which the device is plugged. Is this method certain to work? Will any usb plugged into this particular port always have
"/sys/devices/pci0000:00/0000:00:1d.1/usb3" in its sys path?

Thanks,
 
Old 02-24-2010, 04:11 AM   #4
irmin
Member
 
Registered: Jan 2010
Location: the universe
Distribution: Slackware (modified), Slackware64 (modified), openSuSE (modified)
Posts: 342

Rep: Reputation: 62
The PCI device number will not change for sure (except when changing the system). I'm not 100% sure (only 99.9 %), that the bus number and port number (e.g.: 3-2) will not change too. I hope this helps. (Maybe the bus number changes on reboot, but I'm not sure.)
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
cloning hard drives Twister512 Slackware 6 12-11-2007 05:30 PM
cloning multiple hard drives using bootable media michapma Linux - Hardware 4 05-30-2006 09:15 AM
Cloning different sized hard drives? jaykup Linux - General 3 03-10-2006 01:42 AM
Cloning Hard Drives and Partitions! an alternative to Norton ghost thebover Linux - Software 3 08-18-2004 03:40 PM
cloning hard drives with RH8 willcox Linux - Hardware 0 06-10-2003 07:44 PM


All times are GMT -5. The time now is 04:13 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration