LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Sorry another dd question (https://www.linuxquestions.org/questions/linux-newbie-8/sorry-another-dd-question-745234/)

GottaLearnLINUX 08-05-2009 04:17 AM

Sorry another dd question
 
Greetings everyone, I am new to linux, I have a hdd running win xp and Kubuntu(how I did it, I don't remember:)). My question is about dd.
I have a bootable 128MB CF card in a USB card reader, I want to back it up. I have used the following:

$ dd if=/media/disk of=/home/backup/test.iso

and this is the result:

dd: reading `/media/disk': Is a directory
0+0 records in
0+0 records out
0 bytes (0 B) copied, 0.001155 s, 0.0 kB/s

When I check the drive with Dolphin it doesn't give me the option of unmounting the CF drive, I believe the drive is /dev/sdb/sdb1.
I think /dev/sdb is mounted to /media/disk because I see the files and folders that I want to backup there.

What am I doing wrong?

I ran
$ lsusb
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 003: ID 1019:0c55 Elitegroup Computer Systems (ECS) USB Flash Reader, Desknote UCR-61S2B
Bus 002 Device 002: ID 043d:0072 Lexmark International, Inc. X6170 Printer
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub.

I got the dd and lsusb commands from this forum.

Thanx

Tinkster 08-05-2009 04:26 AM

Hi, welcome to LQ!

For dd to back the CF card up you want to use the raw device,
not the mounted file-system as the origin.

Something like (assuming the dev entry is correct - check dmesg
output to make sure):

dd if=/dev/sdb1 of=your.img bs=2048


Cheers,
Tink

pwc101 08-05-2009 04:28 AM

I think you want to read from the raw device, not the mounted directory. Thus, replace /media/disk with /dev/sdb1, and you should be good to go.

That is assuming /dev/sdb1 is the correct device. Check the output of the mount command (without arguments) to see what's mounted where. Look for the output relating to /media/disk.

vonbiber 08-05-2009 04:54 AM

Quote:

Originally Posted by GottaLearnLINUX (Post 3631996)
dd.
I have a bootable 128MB CF card in a USB card reader, I want to back it up. I have used the following:

$ dd if=/media/disk of=/home/backup/test.iso

1. first find out the device name of your CF card (it used
to be /dev/sd[a-z] but it has changed recently).
Insert your card, wait for a few seconds then run this command:

cat /proc/partitions

Toward the end of the output in the last column you should see
your device name
For instance, on my computer
when I insert my digital camera memory card I get this

.... mmcblk0p1

2. now use dd on /dev/the_name_you_just_saw

In my case I would do this

cd
dd if=/dev/mmcblk0p1 of=backup.img

just replace by the device you got, and the name and location
of your output file

GottaLearnLINUX 08-05-2009 11:05 AM

changing disk size
 
Greetings and thank all of you for your very prompt help, the 128MB CF was /dev/sdb,
I was able to copy it, the rewrite was slow but it worked.
I had to use sudo to get permission first.

I didn't write the bs=2048 when I copied it back
sudo dd if=/home/test.img of=/dev/sdb
does bs=2048 make it write faster?

How do I put this 128mb image on a 256MB or a 512MB CF

I am anxious to learn linux and leave my dependancy of windows.
I'm comfortable using the command line but, I don't know too many commands :)

thanks again

GrapefruiTgirl 08-05-2009 11:17 AM

Hi,

I just wanted to throw in a friendly FYI: There's an *excellent* post/tutorial on LQ somewhere, by a member named 'Awesome Machine', titled 'Learn the dd command' or something very similar to this title.

It goes into detail of MANY examples of using dd to do lots of neat stuff!

You can find it here

Sasha

tredegar 08-05-2009 12:04 PM

Quote:

How do I put this 128mb image on a 256MB or a 512MB CF
You just dd it to the device:

Code:

sudo dd if=/home/test.img of=/dev/sdc
but thereafter it'll be seen as a 128MB device (not 256 or 512MB) until you repartition it. There's no "harm" in this, it's just that dd copies over the partition table as well as the filesystem if you use it like this. So the 512MB device will (lie and) say it is only 128MB.

The first time I copied a partition to a file with dd, and then mounted that file as a filesystem (so I could read and write files from & to it) was a real eye-opener for me, as I realised I could never have done that with DOS / windows. So dd can be quite seductive, but always be very careful with the dd command making triply sure the destination is correct, or you'll hose some vital data.

Now I almost never use dd as there are usually better, safer, tools / methods to achieve what I want.

Explore, experiment (after backups, please), have fun and learn something new :)

Tinkster 08-05-2009 12:10 PM

And with that said: you can use parted or its graphical
cousin gparted to resize the migrated partition after the
fact .... (depending on the file-system on there, of course).

Out of curiosity:
What makes you use dd instead of e.g. a cp?


Cheers,
Tink

GottaLearnLINUX 08-06-2009 07:32 PM

Speeding up
 
Greetings all, and thank you for your help.
I was able to copy the CF card, is there part of the dd command that can speed up the file transfer?

I don't use Linux much but I'm trying to do a complete move to Linux once I get the programs I use to work with it, I've tried WINE but not everything works with it, like an EPROM programmer connected to a PCI card parallel port and my Lexmark X6170 printer and other hardware.

I have Debian, Suse, Knoppix, Ubuntu disks around here but I installed Kubuntu and winxp on this machine.

Again, thanks for all the help.

Tinkster 08-06-2009 08:59 PM

Quote:

Originally Posted by GottaLearnLINUX (Post 3634222)
Greetings all, and thank you for your help.
I was able to copy the CF card, is there part of the dd command that can speed up the file transfer?

Increasing the block-size should. bs=2048, for example...


But I'd like you to understand that you're NOT transferring
files, not even file-systems. You're copying the devices
content on a hardware-level.

And dd's default is to do that byte by byte, which isn't
the smartes choice for block-devices. Hence the suggested
block-size ... 2048 works well with most block-devices,
if it were a RAID with a large stripe-size you could up
that to e.g. 16384

GottaLearnLINUX 08-08-2009 10:51 PM

Speeding up data transfer
 
Greetings, I did some tests on my CF card, I increased bs=8192 and went up to 32768 and found no difference in the speed after 8192, the transfer rate was 1MB/s did a 512MB card in 8 minutes.

Thanks again

markush 08-09-2009 01:48 AM

I often use dd to copy whole windows-drives. I connect two HDs in on computer and boot with a slax live-CD.
With linux the only reason for copying raw data is when doing something with the masterbootrecord.
A linux system (other than windows) can be copied completely using "cp" since the system is "connected" to the harddrive only by /etc/fstab and the settings for the bootloader.

Markus


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