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.
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.....
Click here to see the post LQ members have rated as the most helpful post in this thread.
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!
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:
/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.)?
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:
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???
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.
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.
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
Code:
lilo -b /dev/fd0
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.
Distribution: Debian testing/sid; OpenSuSE; Fedora; Mint
Posts: 5,524
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.
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):
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:
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.
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:
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
Distribution: Debian testing/sid; OpenSuSE; Fedora; Mint
Posts: 5,524
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:
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.