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 |
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.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
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.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
|
09-27-2006, 03:22 PM
|
#226
|
|
Member
Registered: Aug 2005
Distribution: Slackware 12
Posts: 106
Rep:
|
lol... if there were such wonderful commands for windows/dos, it would not be windows, and one would not have to spend a fortune for purchasing acronis true image.....
|
|
|
|
09-28-2006, 10:49 PM
|
#227
|
|
LQ Newbie
Registered: Dec 2004
Location: pune,India
Posts: 4
Rep:
|
Hello Sir,
This has reference to the web page: "How To Do Eveything With DD -.htm"
> "Make an iso image of a CD"
Done every thing as under,
-------------------------------------------------------------------------------------------------------------------------------------------
knoppix@localhost:~$ su
Password:
root@localhost:/home/knoppix# dd if=/dev/cdrom of=mycd.iso bs=2048 conv=notrunc
358254+0 records in
358254+0 records out
733704192 bytes transferred in 354.825077 seconds (2067791 bytes/sec)
root@localhost:/home/knoppix#
mycd.iso has permissions  -rw-r--r--)to chage the permissions:
root@localhost:/home/knoppix# chmod a+rwx mycd.iso
root@localhost:/home/knoppix#
Now mycd.iso has permissions  -rwxrwxrwx)
to mount the image,
root@localhost:/home/knoppix#mkdir /mnt/mycd
root@localhost:/home/knoppix#
root@localhost:/home/knoppix#kedit /etc/fstab
added the line /home/knoppix/mycd.iso /mnt/mycd iso9660 rw, user, noauto 0 0 and saved it.
root@localhost:/home/knoppix# mount -o loop /mnt/mycd
root@localhost:/home/knoppix#
The file system IS available as files & directories.
---------------------------------------------------------------------------------------------------------------------------------------------
however sorry to inform you that,
can NOT edit "mycd.iso" as it gets mounted with "-r-xr-xr-x" permissions!
Prof S W Damle
Email : swdamle@sancharnet.in
________________________________________________________________________
|
|
|
|
09-29-2006, 01:19 AM
|
#228
|
|
Moderator
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 22,903
|
Even if you COULD edit the file, it wouldn't be a valid iso afterwards.
You CANNOT directly edit a loop-back mounted ISO image, you have to copy
the file-system, work on that, and create a new ISO.
Cheers,
Tink
|
|
|
|
10-02-2006, 02:54 PM
|
#229
|
|
LQ Newbie
Registered: Oct 2006
Posts: 10
Rep:
|
Backup of /dev/sda over network to share
Hi,
Thanks so much for all that info on DD...
I´m trying to make a backup of a whole SATA disk over a network to a share on another computer.
The share is larger than the disc being copied and I´m gzipping it. This is the command I´m using:
dd if=/dev/sda ibs=4096 | gzip --best > /media/backup/Recovery.gz
/media/backup is where I mounted the share and I´m using Knoppix 5.0.1.
DD works fine until it reaches a file size of ~2GB when it stops accusing a file size limit error. I´m guessing this is a network protocol limit... Is this right?
How can I change this mine command to split the resulting gzipped file into regular sized files (like 700MB, 2GB, etc.)?
Thanks for reading and trying to help...
|
|
|
|
10-03-2006, 06:59 AM
|
#230
|
|
LQ Newbie
Registered: Oct 2006
Posts: 10
Rep:
|
Hi again...
I myself found a solution for my question. If this may help someone, here´s a command to use when completeley raw imaging a SATA HDD, compressing it with gzip, and splitting it in files, all going over a network to a share on a remote PC:
dd if=/dev/sda | gzip --best | split -b 2000m /media/backup/Recovery
This was done using Knoppix 5.0.1. I first mounted the network share on /media/backup/. The split parameter
-b 2000m
tells split to split the file in 2.000 MB (2.048.000 KB) ant the parameter
/media/backup/Recovery
is the base destination file. Split created in this case Recoveryaa, Recoveryab, Recoverac, etc...
I hope this can help someone as I need help now  ...
Upon running this command I found that dd does a COMPLETE (in all senses) raw image of the device, that is, including empty areas of the HDD, which is precisely what I do not need...
So, is there any way to make a raw image of only used clusters/chunks/bytes/whatever but still preserving the whole of the disk structure and partitioning and MBR???
Please help, anyone?
|
|
|
|
10-03-2006, 07:06 AM
|
#231
|
|
LQ Newbie
Registered: Oct 2006
Posts: 10
Rep:
|
Ooops... small correction, the command is actually:
dd if=/dev/sda | gzip --best | split -b 2000m - /media/backup/Recovery
|
|
|
|
10-03-2006, 08:04 AM
|
#232
|
|
Senior Member
Registered: Sep 2005
Location: Newcastle upon Tyne UK
Distribution: Any free distro.
Posts: 3,398
Rep: 
|
Personally I feel dd is being misused if a user wants a sector-to-sector transfer but does not wish to include empty area entries. In such a case there are many Linux back up programs, like cp, tar, rsync, that work with the filing system and by default will not back up empty space.
If a user has an interest to copy the MBR both Lilo (by lilo -b) and Grub (by grub-install) can mirror the image of the MBR in any partition or in a floppy. What is more any boot loader can be restored. For MS system it is by just a Dos floppy (with fdisk.exe inside) or the system installation CD. A Linux's boot loader can be restored by any Live CD or its installation CD that has a rescue option.
Regarding the partition table I just keep a record of its sizes and types of the partitions. Sometimes I accidentally lost between 55 to 60 partitions in a disk (about a dozen times) but all can be rebuilt without losing a single byte, as the content inside the partitions will not be damaged even the entire partition table is nuked.
I think dd is a hardware-type back up and is the only one that copies the boot sector of each partition so it should be used when such a need is required, as by itself it doesn't compress the data even the whole disk is empty. As it doesn't deal with the filing system but faithfully duplicates the hard disk sector by sector it is ideally suitable to clone disk with different filing systems or different operating systems.
Last edited by saikee; 10-03-2006 at 10:12 AM.
|
|
|
|
10-03-2006, 08:48 AM
|
#233
|
|
LQ Newbie
Registered: Oct 2006
Posts: 10
Rep:
|
Oh, Saikee, I´m so sorry if I offended you. I assure I didn´t and don´t mean do "abuse" anyone or anything.
Thanks anyway for your (to me useless) reply. Maybe you should have considered the possibility that I´m a newbie to Linux (as I am).
Anyway, my second attempt is to backup the MBR of the disk using dd and copying the SATA partition (there´s only one) using cp or tar. Either way I go I need two things: (1) the ability to split the copied and compressed files into regular sized files and (2) the ability to recover my disk by first recovering the MBR with dd and then by uncompressing the compressed files to /dev/sda1.
Is this all I need to do? Is this feasible? Please answer constructively and don´t use this forum as an outlet for your misdirected anger.
Thanks.
|
|
|
|
10-03-2006, 10:12 AM
|
#234
|
|
Senior Member
Registered: Sep 2005
Location: Newcastle upon Tyne UK
Distribution: Any free distro.
Posts: 3,398
Rep: 
|
I regret the use of the word "abuse" and the correct word should have been "misuse" becuase that is what it appears to me on technically ground. I have since altered it. It is like using a chisel as a screwdriver. Yes one can use it that way but a chisel is better used for cutting wood.
If you want to save a copy of Grub, just slip a floppy into the drive, click terminal and type
Code:
grub-insall /dev/fd0
If your Linux uses Lilo then it is just a line of
Should at any future date you nuke your MBR then put the floppy in will boot up the Linux. Repeating the above command with "fd0" replaced by "sda" will write the stored MBR back to your Sata.
Furthermore you can have the Linux unbootable, say after accidental losing the MBR, boot up the PC with a Linux Live CD, mount your Linux partition and charge root into it and you will be inside the unbootable Linux. Once inside it you can repeat the above statements to restore the MBR. Don't waste time to compress just 512 bytes of the MBR. Just get hold of any Live CD and learn how to get inside an unbootable Linux.
Most of the detials are documented in the last link of my signature.
Last edited by saikee; 10-03-2006 at 10:17 AM.
|
|
|
|
10-03-2006, 09:06 PM
|
#235
|
|
Senior Member
Registered: Jan 2005
Location: USA and Italy
Distribution: Debian Testing; OpenSuSE 12.1; Fedora 17
Posts: 1,541
Original Poster
Rep: 
|
OK, enough
Quote:
|
Originally Posted by idamien
Oh, Saikee, I´m so sorry if I offended you. I assure I didn´t and don´t mean do "abuse" anyone or anything.
Thanks anyway for your (to me useless) reply. Maybe you should have considered the possibility that I´m a newbie to Linux (as I am).
Anyway, my second attempt is to backup the MBR of the disk using dd and copying the SATA partition (there´s only one) using cp or tar. Either way I go I need two things: (1) the ability to split the copied and compressed files into regular sized files and (2) the ability to recover my disk by first recovering the MBR with dd and then by uncompressing the compressed files to /dev/sda1.
Is this all I need to do? Is this feasible? Please answer constructively and don´t use this forum as an outlet for your misdirected anger.
Thanks.
|
There is a method using netcat to dd between machines using ip address and port. If you read the whole OP you will see it. Some kernel versions, and file systems have a 2 GB file size limit, but dd does not have such a limit because files don't matter to dd. Dd doesn't even care if the drive is mounted or not. Use netcat, or nc to image the drive, and image it as a file. Like this:
On source machine
dd if=/dev/hda bs=16065b | gzip | netcat 192.168.1.1 1234
where 192.168.1.1 is the ip of the target and 1234 is the port.
Hit enter on Target machine first:
netcat -l -p 1234 | dd of=/home/sam/partition.img bs=16065b
Bs=16065b means the byte size is 255 (heads) x 63 (sectors per track) = (16065) x 512 (bytes per sector, b) , which is exactly one cylinder. Since only complete cylinders can be contained in a partition, and partitions will always will always have a whole number of cylinders it is safe to assume this particular bs= will copy the entire partition. If you have a file size barrier you should get rid of it, not split the file. Only old kernels and bad filesystems have a 2 GB limit.
|
|
|
|
10-03-2006, 09:50 PM
|
#236
|
|
Senior Member
Registered: Jan 2005
Location: USA and Italy
Distribution: Debian Testing; OpenSuSE 12.1; Fedora 17
Posts: 1,541
Original Poster
Rep: 
|
Quote:
|
Originally Posted by prashant.gupta
This article on dd command is very nice. Can we get the dd command for windows/dos?
|
There is a "dd" for Windows and DOS. It isn't quite as full featured as the UNIX version, but it will do many of the same things.
|
|
|
|
10-05-2006, 08:09 AM
|
#237
|
|
LQ Newbie
Registered: Oct 2006
Posts: 10
Rep:
|
Hi again,
Actually, I have been able to do the first half of my task (apparently). I used the following commands after booting a live CD Knoppix v5.0.1, to bakcup a Windows XP MCE 2005 SP2 harddisk to a network share (also Windows XP SP2):
su
mkdir /media/backup
mount //microsoft-pc/root /media/backup
mount /dev/sda1 /media/sda1
tar --create --preserve-permissions --recursion --gzip /media/sda1 | split -b 2000m - /media/backup/recovery.
dd if=/dev/sda of=/media/backup/mbr.dd bs=446 count=1
My only doubt has been the last line... Shouldn´t bs read bs=512? I got this example line of script right here in this thread (checkout page 1) but am somewhat unsure about it. Can anyone help?
For the second half I´m going to burn the recovery.* files onto the root of a DVD Live Distribution (I´m thinking about using SLAX, any suggestions...?) and also the following script which I´ll link to with an icon on the desktop so I´ll have One-Click recovery. I´m assuming it is a correct command and that all recovery.* files will be on the root dir of the same DVD disc. Please remember I´m a newbie. OK, so here it goes:
su
dd if=/media/cdrom/mbr.dd of=/dev/sda bs=446 count=1
mount /dev/sda1 /media/sda1
dir --sort=extension /media/cdrom/recovery.* | cat | tar --extract --same-permissions --overwrite --ungzip /media/sda1
Is this right? Will it work? Again I´m in doubt about the bs option of dd and wether I need a reboot after the dd command... Also I´m piping from a dir command to a cat (I assume it concatenates binary files split with SPLIT) command and from that to the tar --extract...
Is this right? Will this work? Please any comments and suggestions are more than welcome.
Thanks.
|
|
|
|
10-05-2006, 09:18 AM
|
#238
|
|
LQ Newbie
Registered: Oct 2006
Posts: 10
Rep:
|
Hi again,
Just tested my last post commands for recovery and found some bugs...
The DIR and LS commands, when piping to CAT, output text and CAT creates a text file with the name listing of the recovery files...
So, after a little meddling, I found this sequence of commands to work (apparently) correctly:
su
dd if=/media/cdrom/mbr.dd of=/dev/sda bs=446 count=1
mount /dev/sda1 /media/sda1
cat /media/cdrom/recovery.* | tar --extract --same-permissions --overwrite --ungzip --directory=/media/sda1
Having the same basename, CAT orders the input files by extension and successfully feeds it to TAR.
However, I found that: (1) the dd command to restore the MBR works and (2) although it works if you are creating an identical partition table to what you had previously (my case), the files on the partitions (I have only one) remain! I´ve tested a reboot after the DD command but it was of no use: the files are still there and the TAR command to restore from the archive can´t overwrite them (even though I´m using the --overwrite option) accusing, for each file/directory, an error something like:
/dev/sda1/filename.blahblahblah: can´t change permissions to rwxrwxrwx: can´t overwrite.
It´s not EXACTLY this but it´s something to this effect...
So, maybe I need to format the partition after the DD MBR restore command? Right? How do I go about doing that? I´ve tried FORMAT --help (doesn´t exist) and FDISK --help (exists but only partitions) and even FORMATD --help (silly attempt, doesn´t exist either) but I can´t seem to find a command to format partitions in Knoppix Live CD v5.0.1...
Any help, anyone, please?
I think my recovery script should look something like this:
su
dd if=/media/cdrom/mbr.dd of=/dev/sda bs=446 count=1
mount /dev/sda1 /media/sda1
formatcommand -partitiontypeoption ntfs -quickformatoption /dev/sda1
cat /media/cdrom/recovery.* | tar --extract --same-permissions --overwrite --ungzip --directory=/media/sda1
So, what do you think?
Thanks for reading and trying to help...
|
|
|
|
10-05-2006, 10:46 AM
|
#239
|
|
LQ Newbie
Registered: Oct 2006
Posts: 10
Rep:
|
Hi,
I found the format command... I think.
Now, right after DD, I´m using:
mkntfs --quick /dev/sda1
It apparently quickformats correctly /dev/sda1.
But here´s another issue I´m getting. Apparently it´s from my lack of experience with TAR. When using TAR the files are being extracted to /dev/sda1 to the folder they were in Windows (their full path in Windows) INSIDE a folder called /media/sda1 (which is the folder I mounted the files on when creating the backup). For example, autoexec.bat is being extracted to /dev/sda1 to the following folder/filename:
/media/sda1/autoexec.bat
My first thought was that this was the --directory option, but I removed it and it continues to do so. Also, I´m getting for MANY of the files the following error:
tar: /media/sda1/ORIGINAL_WINDOWS_FULL_PATH_HERE/filename.ext: Cannot open: Operation not supported
Can someone please help???
Thanks.
|
|
|
|
10-07-2006, 04:55 AM
|
#240
|
|
Senior Member
Registered: Jan 2005
Location: USA and Italy
Distribution: Debian Testing; OpenSuSE 12.1; Fedora 17
Posts: 1,541
Original Poster
Rep: 
|
Thread hijacking
Quote:
|
Originally Posted by idamien
Hi,
I found the format command... I think.
Now, right after DD, I´m using:
mkntfs --quick /dev/sda1
It apparently quickformats correctly /dev/sda1.
But here´s another issue I´m getting. Apparently it´s from my lack of experience with TAR. When using TAR the files are being extracted to /dev/sda1 to the folder they were in Windows (their full path in Windows) INSIDE a folder called /media/sda1 (which is the folder I mounted the files on when creating the backup). For example, autoexec.bat is being extracted to /dev/sda1 to the following folder/filename:
/media/sda1/autoexec.bat
My first thought was that this was the --directory option, but I removed it and it continues to do so. Also, I´m getting for MANY of the files the following error:
tar: /media/sda1/ORIGINAL_WINDOWS_FULL_PATH_HERE/filename.ext: Cannot open: Operation not supported
Can someone please help???
Thanks.
|
idamien,
You have hijacked this thread. And I mean that in the nicest possible way. Please either keep your posts pertinent to the OP, or start a new thread. You can read about thread hijacking here:
http://www.linuxquestions.org/questi...89#post2453289
|
|
|
|
|
Tags
|
backup, best, clonezilla, cloning, command, data, dd, disk, drive, duplicate, erase, explanation, formatting, ghost, hard, image, iso, memory, ping, popular, recover, recovery, rescue, search, security, stick, upgrade, usb, wipe  |
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 03:35 AM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|