Linux - NewbieThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Distribution: Debian testing/sid; OpenSuSE; Fedora; Mint
Posts: 5,524
Original Poster
Rep:
Correction noted
Quote:
Originally Posted by Lotharster
This is not correct. Both random and urandom can in theory produce output of any byte size. They use the kernel's entropy pool to compute the random numbers. This entropy pool is filled with random noise gathered from device drivers and other sources. The important difference between the two is that /dev/random produces only as many random bits as the entropy pool contains. This results in high quality randomness, which is neccessary for kryptographic keys. In case the user demands more random bytes than currently contained in the entropy pool, the process stops until the entropy pool is refilled (waggling your mouse helps). /dev/urandom, however, does not have this restriction. If the user demands more bits than currently in the entropy pool, it produces them using a pseudo random number generator. These pseudo random numbers should not be used as cryptographic keys.
[/QUOTE]
I have made the correction
1 members found this post helpful.
Click here to see the post LQ members have rated as the most helpful post in this thread.
Distribution: Debian testing/sid; OpenSuSE; Fedora; Mint
Posts: 5,524
Original Poster
Rep:
You need partitions first
Quote:
Originally Posted by jon_flanders
I would like to clone my 13 gb windows 98 drive, divided into c: programs and d: data to a 100 gb drive via usb which I would pre-partition to say, c: 20gb , d: 30 gb.
The goal would be to then simply pop the 100 gb drive into the ide ribbon in place of the 13 gb drive. My Linux drive is currently 30gb which is sufficient for my purposes. Here's the output of df currently:
I have unmounted partitions and unused space on the 30gb drive.
Is this doable? I know I can partition the hard drive in the usb via Mandriva's Harddrake. I've done that already with an old 3gb drive.
Jon Flanders
I want to make this clear that you have two drives in the case, connected to IDE. You want to take a third drive, connect it via usb, and copy the partitions on hda to it. You will be running a desktop linux installation, and like the GUI stuff. That's fine. You can use hotplug, and just plug in the usb drive. Wait a second. In a terminal window <dmesg | tail>. Look at where linux put the usb device. It will be hd something, or sd something. Once you know the right device, you can proceed to use cfdisk or parted to partition and format your new partitions. Sector size is 512, don't specify cylinders, heads is 255, sectors per track is 63. I want you to learn the partitioning tool by messing it up a few times(man cfdisk). That way, when you have to rescue a partition, and you don't have man, at least you will have learned the tool. cfdisk has a nice user interface. When the new partitions are created, use dd to transfer the data:
Distribution: Debian testing/sid; OpenSuSE; Fedora; Mint
Posts: 5,524
Original Poster
Rep:
Partitions
Quote:
Originally Posted by jon_flanders
I would like to clone my 13 gb windows 98 drive, divided into c: programs and d: data to a 100 gb drive via usb which I would pre-partition to say, c: 20gb , d: 30 gb.
The goal would be to then simply pop the 100 gb drive into the ide ribbon in place of the 13 gb drive. My Linux drive is currently 30gb which is sufficient for my purposes. Here's the output of df currently:
I have unmounted partitions and unused space on the 30gb drive.
Is this doable? I know I can partition the hard drive in the usb via Mandriva's Harddrake. I've done that already with an old 3gb drive.
Jon Flanders
If you want the new partitions different sizes than the ones being copied, make the new partitions first. Hotplug the usb drive, <dmesg | tail> in a terminal, view the new device designation in dmesg, <man cfdisk>, or install cfdisk, partition disk.
I have read through this article. Very in-depth and I appreciate what you have done to explain DD. I might be asking something that you give in your example, so I will apologize in advance, if not, here is my question.
I would like to copy either the entire hard drive or each partition to a single file for which I could restore back to another hard drive later. Kind of like copy one drive to another (making a duplicate), but I don't want to do that. I want to make a copy of a hard drive to a file, store the file some where and then be able to restore that file to another hard drive. End result would be an exact copy of the first drive. The reason I don't want to do a disk to disk copy is, that the new hard drive might be the same size or larger and I do this later.
Scenario # 1
PC has 2 hard drives.
1. I would like to DD the entire Hard Drive to a single file on the 2nd hard drive
A. What would that command look like if I can do it. However, if possible, can I
only copy actual data or will it copy sector by sector. In other words if /dev/sda
is 20 Gigs, my file will be 20 Gigs. Let's say there was only 7 Gigsof data on
drive, can my file be just 7 Gigs?
Scenario # 2
PC has 1 hard drive and a DVD Burner
1. Hard drive is 20 Gigs. I have 4 gigs of Data that I would like to copy to a
single file and burn it to a DVD.
A. What would the command look like to do that if possible.
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195
Rep:
You could better use tar (standard Linux) or star (enhanced tar, freely downloadable from the Internet) for this purpose. It does exactly what you want, preserves everything from the files, compresses if you want, and when unpacking you re-create the entire tree structure.
The advantage is that is does not matter on which disk or which partition you do this, even if your partition scheme is greatly different.
Since your partitions are different, you'd have to partition your disk anyway.
(I know it works, I cloned several machines like this)
The only problem might be your boot sector. You recreate that most easily by running grub-install from a live CD after you copied all the files.
Distribution: Debian testing/sid; OpenSuSE; Fedora; Mint
Posts: 5,524
Original Poster
Rep:
Quote:
Originally Posted by sfrazier9999
I have read through this article. Very in-depth and I appreciate what you have done to explain DD. I might be asking something that you give in your example, so I will apologize in advance, if not, here is my question.
I would like to copy either the entire hard drive or each partition to a single file for which I could restore back to another hard drive later. Kind of like copy one drive to another (making a duplicate), but I don't want to do that. I want to make a copy of a hard drive to a file, store the file some where and then be able to restore that file to another hard drive. End result would be an exact copy of the first drive. The reason I don't want to do a disk to disk copy is, that the new hard drive might be the same size or larger and I do this later.
Scenario # 1
PC has 2 hard drives.
1. I would like to DD the entire Hard Drive to a single file on the 2nd hard drive
A. What would that command look like if I can do it. However, if possible, can I
only copy actual data or will it copy sector by sector. In other words if /dev/sda
is 20 Gigs, my file will be 20 Gigs. Let's say there was only 7 Gigsof data on
drive, can my file be just 7 Gigs?
Scenario # 2
PC has 1 hard drive and a DVD Burner
1. Hard drive is 20 Gigs. I have 4 gigs of Data that I would like to copy to a
single file and burn it to a DVD.
A. What would the command look like to do that if possible.
Thanks for the kudos on the OP. The way you do what you want <of=/path/file> instead of a device
I've got a question and I read through thr first page of this thread but I was wonddering if you knew of a way to do the thing I am trying to do. First this is my system setup:
1 DVD Burner
1 80 GB Hard Drive - used for my iso files and backups
1 30 GB Hard Drive - Used for my linux system
1 Swappable hard drive
What I would like to do is we have a lot of servers for our hosting service and we would like to copy the hard drives that are in each type of machine onto a DVD disc and a hard drive so in case we have a problem with a machine we can either copy the extra hard drive for that machine to a new one and put in the machine and get it working or have a copy on a dvd and jsut copy the dvd to a new hard drive.
The only way I can do it right now is I use dd to copy the hard drive from our server in my swappable hard drive bay over my 80 GB hard drive and then I can pull it out and put in the new one and copy over the data back. I have noticed you can use dd to make iso's but I don't know if the dvd will have all the partitions like the hard drive. I also noticed if the hard drive being copied is bigger than the source you need to skip the first part of the drive.
Can you help me know which commands I would need to use to do the following?
1. Copy a hard drive to a directory on my computer as a ISO. I think this one will do it:
dd if=/dev/hda of=/data/beta.iso bs=2048 conv=notrunc
2. Take an iso and copy it onto the hard drive to make it look like the previous hard drive.
3. Also be able to use the same ISO and burn a DVD.
Thanks for your help and if you have any suggestions on how I could do it differently I am open to suggestions.
Distribution: Debian testing/sid; OpenSuSE; Fedora; Mint
Posts: 5,524
Original Poster
Rep:
.iso files and dd
Quote:
Originally Posted by blakegrover
I've got a question and I read through thr first page of this thread but I was wonddering if you knew of a way to do the thing I am trying to do. First this is my system setup:
1 DVD Burner
1 80 GB Hard Drive - used for my iso files and backups
1 30 GB Hard Drive - Used for my linux system
1 Swappable hard drive
What I would like to do is we have a lot of servers for our hosting service and we would like to copy the hard drives that are in each type of machine onto a DVD disc and a hard drive so in case we have a problem with a machine we can either copy the extra hard drive for that machine to a new one and put in the machine and get it working or have a copy on a dvd and jsut copy the dvd to a new hard drive.
The only way I can do it right now is I use dd to copy the hard drive from our server in my swappable hard drive bay over my 80 GB hard drive and then I can pull it out and put in the new one and copy over the data back. I have noticed you can use dd to make iso's but I don't know if the dvd will have all the partitions like the hard drive. I also noticed if the hard drive being copied is bigger than the source you need to skip the first part of the drive.
Can you help me know which commands I would need to use to do the following?
1. Copy a hard drive to a directory on my computer as a ISO. I think this one will do it:
dd if=/dev/hda of=/data/beta.iso bs=2048 conv=notrunc
2. Take an iso and copy it onto the hard drive to make it look like the previous hard drive.
3. Also be able to use the same ISO and burn a DVD.
Thanks for your help and if you have any suggestions on how I could do it differently I am open to suggestions.
Thanks
Blake
Blake, Thanks for the kudos on the post, and to the excellent string of replies. I try to reply to every question myself, but I compliment others who have replied excellently, and have even caused me to edit the post.
DD is a bitstream duplicator. It reads/writes bit for bit. The copy is an exact bitstream duplicate of the original. Therefore, whatever file system is used for the original will be used for the copy. In other words, naming a file with an iso extension does not cause dd to write an iso9660 filesystem if the source file system is not iso9660. You can, however, write other file systems to a DVD with mkisofs and growisofs. There are linux programs available to back up to DVD, if you don't want to learn the other two commands. The fact that dd won't write to optical media is an endless pain, but that is the way it has to be.
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195
Rep:
I would like to add something about the "you copy a file system" statement.
Recently I copied a disk to another one with a bigger size. I used to use tar for this, but I did it with dd this time.
The new disk booted & worked fine, but when I issued a "df" command, all my partition sizes were reported wrong. Indeed, "df" reported all partition sizes like they were on the old, smaller disk.
This obviously happened because I copied the entire FILE SYSTEM, not the data. At the end of the day I tar-ed all the partitions, put the tar files on a different partition. Reformatted the partitions and un-tar-ed everything again, and all was fine.
IMHO this demonstrates clearly that if you want to CLONE a disk, you should use "dd". But if you want to copy a [disk | partition] to something with a different size, you should use "tar".
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.