LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-30-2014, 10:38 AM   #1
Dathaeus
LQ Newbie
 
Registered: Jan 2014
Posts: 13

Rep: Reputation: Disabled
Copying Linux Flash Drive


Hi all... first I wasnt sure if this should go here or Debian or.... please let me know and I will next time since I have more questions coming, thanks.

As with the onset of mining (sorry if this has left a sour taste here, any opinions on that are welcome too), I am sure you have been inundated with BAMT and other questions, and I am one of them on BAMT, which I heard run on Debian.

I am running it on an 8GB Sandisk USB drive. The system has been crashing way too often and I have cool temps and good power, so someone suggested I use another drive, that some are not good running Linux, is that true?

Anyways, is it as simple as doing a file copy and paste to another drive in my Win7 machine, or is it a true bootup where I have to start from scratch and burn the img file again? I have a lot of setting in the config files so I rather not have to type that all in, unless there is a way to copy and paste from my Win7 to my mstsc remote window to my BAMT.

Thanks a lot!
 
Old 01-30-2014, 01:12 PM   #2
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,882
Blog Entries: 13

Rep: Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930
You can use the dd command to copy your entire disk, byte by byte; therefore getting the partitioning and file systems, as well as boot information all intact.

To copy to a file on your system:
Code:
sudo dd if=/dev/<disk-letter-for-your-thumbstick-no-number> of=<filename> bs=10M
Example:
Code:
dd if=/dev/sdf of=backup-01292014 bs=10M
In that example, the thumbstick is discovered as /dev/sdf, which you can see in your system log; or if something mounts and you see that you have like /dev/sdf1 mounted to somewhere. You use /dev/sdf because it means the entire disk, not just the one mounted partition. There may be only one partition, who knows, it's a case-by-case basis.

To copy from disk to disk, similar, just using the target disk letter. Say one thumbstick is in /dev/sdf and the other one is in /dev/sdg. First make sure that you know where the source and target are because the dd command will copy in and copy out all the data regardless and it will take a brand new, empty disk as the copy in and put that information onto the one you intended to be your source disk. As a result if you type the command wrong, you'll not only not get a backup, you'll lose your data.
Code:
dd if=/dev/sdf of=/dev/sdg bs=10M
It helps to know that if means input file and of means output file.

The other things which are important are that the output disk needs to have sufficient space (more) space than the input disk. Also be aware that there are some cases where a 4G thumbstick may have more bytes of available space than another 4G thumbstick and as a result the copy may fail because the target drive is ever so slightly smaller than the source drive. For that there are other things one can do. I can describe in more detail that case. Short summary is to copy each partition, certain file systems can be resized. For instance, you can view the partitions, for example one FAT32 boot partition and one ext4 partition. Create partitions on your other disk to match or exceed. Manually copy the boot stuff, say from the FAT32, and for the root file system part, you can create a larger sized ext2 file system on disk, tune it, copy the RFS from your source into that file system (mounted as loop), the umount and resize the ext2 file system to be the minimum size required. Then you should be able to reverse that process to get the RFS to your target disk.
 
Old 01-30-2014, 01:19 PM   #3
qlue
Member
 
Registered: Aug 2009
Location: Umzinto, South Africa
Distribution: Crunchbangified Debian 8 (Jessie)
Posts: 747
Blog Entries: 1

Rep: Reputation: 172Reputation: 172
One caveat, You can't copy a system from the same disk you boot from. So you need to boot from a different drive to the one you want to copy.
 
Old 01-30-2014, 01:29 PM   #4
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,882
Blog Entries: 13

Rep: Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930
Quote:
Originally Posted by qlue View Post
One caveat, You can't copy a system from the same disk you boot from. So you need to boot from a different drive to the one you want to copy.
Sorry, I feel you can do that. You just can't copy it, onto itself. Say for a Beagleboard Black, you have everything on the MMC0 you can copy that entire drive; while running; to a mounted drive. I've done exactly that because one gets a Beagle preloaded with a distribution. Once you tune it to be what you want, you can copy a backup off of it, also so you can make a duplicate system.

In that scenario, copying "back" to the MMC is a "don't do".
 
1 members found this post helpful.
Old 01-30-2014, 01:45 PM   #5
Dathaeus
LQ Newbie
 
Registered: Jan 2014
Posts: 13

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by rtmistler View Post
To copy from disk to disk, similar, just using the target disk letter. Say one thumbstick is in /dev/sdf and the other one is in /dev/sdg. First make sure that you know where the source and target are because the dd command will copy in and copy out all the data regardless and it will take a brand new, empty disk as the copy in and put that information onto the one you intended to be your source disk. As a result if you type the command wrong, you'll not only not get a backup, you'll lose your data.
Code:
dd if=/dev/sdf of=/dev/sdg bs=10M
It helps to know that if means input file and of means output file.

The other things which are important are that the output disk needs to have sufficient space (more) space than the input disk. Also be aware that there are some cases where a 4G thumbstick may have more bytes of available space than another 4G thumbstick and as a result the copy may fail because the target drive is ever so slightly smaller than the source drive. For that there are other things one can do. I can describe in more detail that case. Short summary is to copy each partition, certain file systems can be resized. For instance, you can view the partitions, for example one FAT32 boot partition and one ext4 partition. Create partitions on your other disk to match or exceed. Manually copy the boot stuff, say from the FAT32, and for the root file system part, you can create a larger sized ext2 file system on disk, tune it, copy the RFS from your source into that file system (mounted as loop), the umount and resize the ext2 file system to be the minimum size required. Then you should be able to reverse that process to get the RFS to your target disk.
First, thanks for taking the time to help.

Ok the simplest way for me is to have BAMT running (off an 8GB flash), and then put in the target 8GB flash drive in another port. Then I look in file manager and detect the disk letters. Then I use

Code:
dd if=/dev/sdf of=/dev/sdg bs=10M
(what is 10M?)

I am assuming I wont have to worry about the available space issue since the original already has 500MB+ data on it and the new target is empty? Or do u mean total capacity, which would be a whole another story.

Also, I am sure I can "figure it out" but while you guys are here, how do I get the proper command prompt up to type this?
 
Old 01-30-2014, 01:52 PM   #6
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,882
Blog Entries: 13

Rep: Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930
Quote:
Originally Posted by Dathaeus View Post
Then I use

Code:
dd if=/dev/sdf of=/dev/sdg bs=10M
(what is 10M?)
bs is blocksize, 10 meg, you can user other values, if you leave that out it will assume bs=1 I forget if it's byte, Kbyte, Mbyte, it will take longer though if you don't tell it to do larger chunks.

And sorry, it should be:
Code:
sudo dd if=/dev/sdf of=/dev/sdg bs=10M
I had shown the sudo in my first example and then left it out. Sudo is a way for a normal user to run a super-user (root) privilege command. If your system doesn't have sudo, then you'll have to know your root password and then login as root.

Quote:
Originally Posted by Dathaeus View Post
I am assuming I wont have to worry about the available space issue since the original already has 500MB+ data on it and the new target is empty? Or do u mean total capacity, which would be a whole another story.
Total capacity of target should be equal to or larger than the total capacity of the source. This command pays attention to the entire disk.

Quote:
Originally Posted by Dathaeus View Post
Also, I am sure I can "figure it out" but while you guys are here, how do I get the proper command prompt up to type this?
Not sure. Do you get a window manager with menus? Many times "Terminal" shows up under one of the application menus and that is the same as a command prompt.
 
Old 01-30-2014, 03:19 PM   #7
Doc CPU
Senior Member
 
Registered: Jun 2011
Location: Stuttgart, Germany
Distribution: Mint, Debian, Gentoo, Win 2k/XP
Posts: 1,099

Rep: Reputation: 344Reputation: 344Reputation: 344Reputation: 344
Hi there,

Quote:
Originally Posted by Dathaeus View Post
Hi all... first I wasnt sure if this should go here or Debian or.... please let me know and I will next time since I have more questions coming, thanks.

As with the onset of mining (sorry if this has left a sour taste here, any opinions on that are welcome too), I am sure you have been inundated with BAMT and other questions, and I am one of them on BAMT, which I heard run on Debian.
just for the sake of curiosity ...
I ran a few Google searches to find out what you're talking about, but still couldn't get a grip on it. What is BAMT, and more important, what do you mean by "mining" in this context? I know mining as digging for coal, ore, diamonds, something like that - but here??

Quote:
Originally Posted by Dathaeus View Post
I am running it on an 8GB Sandisk USB drive. The system has been crashing way too often and I have cool temps and good power, so someone suggested I use another drive, that some are not good running Linux, is that true?

Anyways, is it as simple as doing a file copy and paste to another drive in my Win7 machine, or is it a true bootup where I have to start from scratch and burn the img file again? I have a lot of setting in the config files so I rather not have to type that all in, unless there is a way to copy and paste from my Win7 to my mstsc remote window to my BAMT.

Thanks a lot!
You already got some advice on how to clone your USB drive. But if the OS already has issues, I think it's unlikely that they're connected with hardware phenomena. I'd rather assume that the reason is some misconfiguration or damaged files. By duplicating the system to another USB drive, you would only duplicate the faults, too.
The clean way would be to reinstall the system from scratch, or from a backup you know was still okay.

[X] Doc CPU
 
Old 01-30-2014, 04:31 PM   #8
jefro
Moderator
 
Registered: Mar 2008
Posts: 21,982

Rep: Reputation: 3626Reputation: 3626Reputation: 3626Reputation: 3626Reputation: 3626Reputation: 3626Reputation: 3626Reputation: 3626Reputation: 3626Reputation: 3626Reputation: 3626
If on windows... "Anyways, is it as simple as doing a file copy and paste to another drive in my Win7 machine, or is it a true bootup where I have to start from scratch and burn the img file again? "

No, but you can get dd for windows or some other clone type app for windows like acronis or ghost.

Some usb's are made by using a trick and may still have fat. It may be possible to cut and paste files but you'd have to apply syslinux maybe to get it to boot.

There are many apps to copy in linux but as noted above, you'd need to boot to a live cd/dvd/ or different usb/hard drive to use linux.

Last edited by jefro; 01-31-2014 at 03:47 PM.
 
Old 01-31-2014, 12:54 AM   #9
Dathaeus
LQ Newbie
 
Registered: Jan 2014
Posts: 13

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by rtmistler View Post
bs is blocksize, 10 meg, you can user other values, if you leave that out it will assume bs=1 I forget if it's byte, Kbyte, Mbyte, it will take longer though if you don't tell it to do larger chunks.

Total capacity of target should be equal to or larger than the total capacity of the source. This command pays attention to the entire disk.

Not sure. Do you get a window manager with menus? Many times "Terminal" shows up under one of the application menus and that is the same as a command prompt.
I dont really care about how long this takes, just want the most reliable... which means I should be using smaller blocks or larger? Total used capacity on the 8GB is about 560MB if that matters. If you can, tell me what # u would use so I dont have to "guess."

Actually even more than that, I tried first burning the BAMT image file again to the new Centon flash drive, and then in Win7 (I know, this may have been dumb) I copied over all the files from the Sandisk, and then tried... it booted up, but it didnt really run, so that didnt work, had to try, LMAO... but out of curiosity, what is I did the same thing but in this file manager gui thing in BAMT? Would that be the same thing as using dd? or maybe safer, which I am trying now but making sure I wont have problems down the line if this does work, I am burning a fresh copy of BAMT into the Centon again, and will insert into the BAMT rig, but this file manager is not displaying the different drives, and the "/root" is empty... somehow I feel like thats a cant miss, easiest solution, but maybe I can just copy those files only over in terminal?

There is a LXTerminal root terminal thing I can bring up, not sure how that differs with the file manager for transferring/copying/deleting files etc.... never used it before this month.


Quote:
Originally Posted by Doc CPU View Post
Hi there,
just for the sake of curiosity ...
I ran a few Google searches to find out what you're talking about, but still couldn't get a grip on it. What is BAMT, and more important, what do you mean by "mining" in this context? I know mining as digging for coal, ore, diamonds, something like that - but here??

You already got some advice on how to clone your USB drive. But if the OS already has issues, I think it's unlikely that they're connected with hardware phenomena. I'd rather assume that the reason is some misconfiguration or damaged files. By duplicating the system to another USB drive, you would only duplicate the faults, too.
The clean way would be to reinstall the system from scratch, or from a backup you know was still okay.

[X] Doc CPU
Totally understand your perspective... I was only doing the hw check because someone in a BAMT forum told me but then he disappeared, LOL. I figured I have another drive right here, why fool around if it could be the hw and not software.

BAMT is as simple as they get as a Linux distro offshoot (Debian)... just a Linux interface to basically direct all GPU power (and CPU if needed but worthless) to a "mining pool" through some stratum+tcp address (instead of http) and just uses my GPU to solve blocks of code (usually with tens/hundreds of others at the same time on the same block), and when that is "solved," we get rewarded with some cryptocoin which is pretty much a volatile stock commodity, which we can sell, buy or hold for value. Hope thats clear, my head is mush.


Quote:
Originally Posted by jefro View Post
If on windows... "Anyways, is it as simple as doing a file copy and paste to another drive in my Win7 machine, or is it a true bootup where I have to start from scratch and burn the img file again? "

No, but you can get dd for windows or some other clone type app for windows like acronis or ghost.

Some usb's are made by using a trick and may still have fat. It may be possible to cut and paste files but you'd have to apply syslinux maybe to get it to boot.

There are many apps to copy in linux but as noted above, you'd need to boot to a live cd/dvd/ or different usb.
All makes sense, so I ask u the same as above, is creating the whole BAMT disc from the image, which I am assuming here, will adhere to all the boot files it needs as the Sandisk version, and then copy over just the 4 edited files in terminal be viable? I may need help wioth that code just to make sure I dont do something stupid.
________________________________________

Thanks guys, for all your time and participation... I know Linux isnt that bad since I grew up on DOS and BASIC, but I am much mroe of a graphic/web designer than a programmer so my brain always fights learning this stuff, but u guys are making it good.

Last edited by Dathaeus; 01-31-2014 at 01:30 AM.
 
Old 01-31-2014, 02:33 AM   #10
Doc CPU
Senior Member
 
Registered: Jun 2011
Location: Stuttgart, Germany
Distribution: Mint, Debian, Gentoo, Win 2k/XP
Posts: 1,099

Rep: Reputation: 344Reputation: 344Reputation: 344Reputation: 344
Hi there,

Quote:
Originally Posted by Dathaeus View Post
BAMT is as simple as they get as a Linux distro offshoot (Debian)... just a Linux interface to basically direct all GPU power (and CPU if needed but worthless) to a "mining pool" through some stratum+tcp address (instead of http) and just uses my GPU to solve blocks of code (usually with tens/hundreds of others at the same time on the same block), and when that is "solved," we get rewarded with some cryptocoin which is pretty much a volatile stock commodity, which we can sell, buy or hold for value. Hope thats clear, my head is mush.
so it's an approach to anonymous distributed computing? They try to link all unused processing capacity together into one big virtual computer and then distribute it among those who need it right now?

Okay, some sort of SETI@home, then. ;-)

Thanks for the explanation.

[X] Doc CPU
 
Old 01-31-2014, 02:41 AM   #11
Dathaeus
LQ Newbie
 
Registered: Jan 2014
Posts: 13

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by Doc CPU View Post
Hi there, so it's an approach to anonymous distributed computing? They try to link all unused processing capacity together into one big virtual computer and then distribute it among those who need it right now?

Okay, some sort of SETI@home, then. ;-)

Thanks for the explanation.

[X] Doc CPU
Ya I guess u can see it like a SETI thing, except this is for our own possible selfish profit rather than for the good of the universe, LMAO... I used to partake in that SETI thing actually... then got bored of it, haha.
 
Old 01-31-2014, 04:51 AM   #12
salasi
Senior Member
 
Registered: Jul 2007
Location: Directly above centre of the earth, UK
Distribution: SuSE, plus some hopping
Posts: 4,070

Rep: Reputation: 897Reputation: 897Reputation: 897Reputation: 897Reputation: 897Reputation: 897Reputation: 897
Described here.

(I didn't go through the whole thread...it has many pages).
 
Old 02-01-2014, 02:16 AM   #13
Doc CPU
Senior Member
 
Registered: Jun 2011
Location: Stuttgart, Germany
Distribution: Mint, Debian, Gentoo, Win 2k/XP
Posts: 1,099

Rep: Reputation: 344Reputation: 344Reputation: 344Reputation: 344
Hi there,

Quote:
Originally Posted by salasi View Post
Described here.
that thread builds a very detailed description of how BAMT is supposed to work.

Quote:
Originally Posted by salasi View Post
(I didn't go through the whole thread[...]).
Neither did I. Too much material. ;-)

Yet one question remains unanswered: What do these guys mean by "mining"?
I know the term from every-day life, where it means digging for natural resources. In a wider sense it is also understood as digging for information. The way it is used with BAMT, it has the connotation of something illegal or unethical, which is therefore not mentioned clearly in the open.
To me, it looks like they're trying to concentrate CPU power for cracking codes, for discovering concealed information or for controlling a botnet. Highly suspicious, anyway.

[X] Doc CPU
 
Old 02-01-2014, 02:39 AM   #14
Dathaeus
LQ Newbie
 
Registered: Jan 2014
Posts: 13

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by Doc CPU View Post
Yet one question remains unanswered: What do these guys mean by "mining"?
I know the term from every-day life, where it means digging for natural resources. In a wider sense it is also understood as digging for information. The way it is used with BAMT, it has the connotation of something illegal or unethical, which is therefore not mentioned clearly in the open.
To me, it looks like they're trying to concentrate CPU power for cracking codes, for discovering concealed information or for controlling a botnet. Highly suspicious, anyway.
Basically you are earning stock in the form of virtual currency that becomes "real" currency when u sell for USD. However, bitcoin, litecoin and dogecoin right now can be considered "real" currency because there are retailers and ATM's that deal with them. The term "real currency" is what people have a problem with and think its a scam. However, even the USD is a relative currency with values that fluctuate with other valuables like the Euro, pound, gold, silver, etc... Just because the cryptocoins are the youngest of the lost doesnt mean its all criminal, there is a risk in everything in life, just a matter of percentages.

Anyone else here can help with my problem or am I just waiting for rtmistler... I thought it would be a bit more active here with Linux experts.
 
Old 02-01-2014, 09:51 AM   #15
qlue
Member
 
Registered: Aug 2009
Location: Umzinto, South Africa
Distribution: Crunchbangified Debian 8 (Jessie)
Posts: 747
Blog Entries: 1

Rep: Reputation: 172Reputation: 172
As far as I can tell, you're using a modified Debian system.
To copy the image from one drive to another, you need to unmount the drives first. This is why I say you can't use dd to copy the one drive to the other while you are using it.

Since the pc you're using only has Windows installed, I would suggest you use a live cd like Puppy Linux to do the transfer with.

You need to identify the drives correctly. Start by booting into the live cd with nothing else attached to the computer. Then connect the drive you want to image from.

In a terminal window, you can use the command blkid to identify the drives
In this example from my system, I have two external drives, /dev/sdd is a flash drive and /dev/sdb is a 1TB HDD
Code:
qlue@nishaat-gardens:~$ blkid
/dev/sda1: LABEL="SYSTEM" UUID="B8FA3912FA38CDFE" TYPE="ntfs" 
/dev/sda2: UUID="A26675CB6675A129" TYPE="ntfs" 
/dev/sda3: LABEL="RECOVERY" UUID="70D2E9CBD2E9961E" TYPE="ntfs" 
/dev/sda5: UUID="717f5195-cb17-4f3c-b0b4-a450e2dabb54" TYPE="ext4" 
/dev/sda6: UUID="c88328a3-b858-453b-9492-5e2d0b1d7248" TYPE="swap" 
/dev/sdb1: LABEL="wd-backup" UUID="5EE089495A3F421C" TYPE="ntfs" 
/dev/sdd1: LABEL="transcend" UUID="80C0-2F64" TYPE="vfat" 
qlue@nishaat-gardens:~$
If I was to clone the flash drive to the external HDD I would now type;
Code:
gksu dd if=/dev/sdd of=/dev/sdb bs=1M
After entering my password, the copying would commence. (it can take a long time to complete and won't show anything on screen until it does.)
WARNING: This will wipe out data on /dev/sdb (or whichever device you set as of= )
After I've done that, the drive size of the HDD would show as being only 4GB +-
To fix that, I'd have to grow the partition to fill the available space. I normally use gparted for that.


Any live cd should work, I only suggest Puppy as it is easy to use and runs entirely from ram. I normally use SystemRescueCd myself but it can be a bit daunting to a new user.
 
  


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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
drag-drop copying and cp command both hang at last few KB when copying to flash drive slacker_ Linux - Newbie 1 09-05-2013 07:17 AM
Copying files from Fedora to a usb flash drive? walkman9314 Linux - Newbie 3 02-17-2012 03:02 PM
Copying downloaded mint OS by unetbootin is not getting fully onto flash drive. glenellynboy Linux - Newbie 31 10-03-2011 04:26 PM
Copying files to USB Flash Drive Mr. Alex Ubuntu 2 11-10-2010 11:29 PM
Problem copying to/from USB flash drive Joe Soap Linux - General 1 06-05-2008 06:10 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:44 PM.

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