I presently backup my multi-OS multi-paritition boot drive (fedora core 4/ext3, WinXPServer/NTFS, WinXPHome/FAT32) with the command:
telinit 1; cp /dev/sda /dev/sdb
And this works.
Is there a command to only copy a single partition instead of an entire device?
And what about the grub stuff. Is that in a partition? My grub stuff is corrupted or the grub.conf file is bad. I can boot windows manually via grub but not fedora. How can I restore the grub and linux partitions but not the windows partition?
Partitions for /dev/sda are going to be like /dev/sda1, /dev/sda2, /dev/sda3, etc. You can copy them too.
The master boot record is outside of all partitions. It is the very, very first sector on the hard drive. You can copy just the boot sector like this:
A corrupt grub can't boot anything. If you can boot windows with grub, then grub is not corrupted, but maybye your partitions are, or grub.conf, and maybye you can't remember which partition number you need etc.
I'd boot the system with some sort of linux livecd to see what's going on with your partitions, and edit your grub.conf if need be.
As for how to restore a selected partition from that giant everything-backup file, I don't know. There doesn't seem to be anything like a loop device for splitting a file into partitions the way linux handles hard drives... I'll do some experimenting and see.
You can restore your boot sector easily, though, if that's the problem.
Be sure to back it up on a flash drive or something before you do that of course.
Last edited by Corona688; 08-19-2006 at 03:24 AM..
It should have partitions /dev/sdb1 /dev/sdb2 etc. You might need to do this to get them to become visible on /dev/sdb however, since linux needs to be told when the partition table changes. Either that, or reboot after you do that cp thing to see the new partitions.
DO NOT type 'w' if you get anything but a blank message! All you want to do is write back the SAME boot sector to make fdisk tell Linux to reread it's partition table.
Yes -- my backup is a triple *bootable* drive (thank goodness -- I can verify that everything still works).
So you gave me several dd commands but not one that would copy an entire partition from one disk to another. Could you give me an example of that? On your dd commands, how do you select a block size? Where do those other numeric values come from?
So if I'm getting a grub prompt but grub cannot find the grub.conf file (which I believe is in a linux partition) that could indicate the linux partition is corrupted.
I wonder if grub could do a dd for me? hmmm... if not, then knoppix probably could.
Let's suppose I book with knoppix. Would fdisk -l enumerate my drives?
I don't understand the dd command for copying a boot sector. Where is the destination and source specified?
Here is the scoop: /dev/sdb is the good disk which boots fedora and /dev/sda is the disk with the bad fedora partition. When I try to boot this latter partition with grub it says: Error 17 Cannot mount selected partition.
How do I restore the partition attributes so grub will boot from it again?
Thanks,
Sieg
Here is what parted says:
linux:~ # parted
Using /dev/sda
(parted) print
Disk geometry for /dev/sda: 0kB - 160GB
Disk label type: msdos
Number Start End Size Type File system Flags
1 32kB 126GB 126GB primary ntfs type=07
3 126GB 136GB 10GB primary ntfs boot, type=07
2 136GB 160GB 24GB extended lba, type=0f
5 136GB 157GB 21GB logical ext3 type=83
6 157GB 159GB 2089MB logical linux-swap type=82
(parted) select /dev/sdb
Using /dev/sdb
(parted) print
Disk geometry for /dev/sdb: 0kB - 160GB
Disk label type: msdos
Number Start End Size Type File system Flags
1 32kB 126GB 126GB primary ntfs boot, type=07
2 126GB 160GB 34GB extended lba, type=0f
5 126GB 136GB 10GB logical ntfs type=07
6 136GB 157GB 21GB logical ext3 type=83
7 157GB 159GB 2089MB logical linux-swap type=82
(parted)
Yes -- my backup is a triple *bootable* drive (thank goodness -- I can verify that everything still works).
So you gave me several dd commands but not one that would copy an entire partition from one disk to another. Could you give me an example of that?
You don't need special commands, the ones you already have will work quite fine. Linux gives you special files for partitions that you can use the same way you use the special files it gives you for disks. I'd always use dd instead of cp for copying whole drives or partitions but GNU cp is apparently smart enough to handle nearly anything.
For the record, copying from disk A partition 1 to disk B partition 1:
The "conv=noerror,sync" is something important that cp does not have as far as I know... in the case of error, it will skip that sector in the input and write a sector full of zeroes on the output. cp would probably just stop on any errors.
Quote:
So if I'm getting a grub prompt but grub cannot find the grub.conf file (which I believe is in a linux partition) that could indicate the linux partition is corrupted.
That's what I'd think.
Quote:
I wonder if grub could do a dd for me? hmmm... if not, then knoppix probably could.
knoppix could, yes. Though a full-on graphical interface is probably overkill. I prefer Gentoo liveCDs, or those old little Redhat sysadm disks.
Quote:
Let's suppose I book with knoppix. Would fdisk -l enumerate my drives?
...apparently it does. I did not know that.
Quote:
I don't understand the dd command for copying a boot sector. Where is the destination and source specified?
The input file is specified with the "if=something", and the output file is specified with "of=something". If they are not given, they are assumed to be standard input and standard output. the "bs=512" tells it to assume 512 bytes per sector. The count=1 tells it to copy one and ONLY one sector. So, it copies the first and ONLY the first sector from the hard drive to file. tadah!
good evening,
hi, I have problem for copy file, size more > 1 TB, just only for single file.
error said, capacity not enough, even my storage I set to 4 TB, file always reject during finish copy.
but, if I copy with multiple file/separate file, total calculation file is 2 TB, always success.... (10 Replies)
I need to copy a complete directory structure into a new location. But I want to have all files copied into one directory and leave out the directory structure. So all files must be placed in one directory. (4 Replies)
I have the following script that I use to copy a list of files from one dir to another,
#!/usr/bin/bash
# $1=filename of file with the list of files to copy
# $2=column header for col in list file with filenames (filePath in most cases)
# $3=src dir
# $3=destination dir
FILE_LIST="$1"... (6 Replies)
Hello,
someone please suggest me how write a script or command to create partition and label whole disk as LVM . I have multiple servers that I to label as LVM using fdisk, that will very hard process.
This is what I currently doing to create to partition and label.
# fdisk /dev/sdb
... (0 Replies)
Here's a conundrum. I use a ThinkPad (T30) which has a slot on the side for the hard drive. It is very easy to swap this with another hard drive which I keep as a backup. Now when I copy the Linux partition from my (in use) hard drive to the backup one (in my UltraBay slot) it takes only 30... (0 Replies)
This is now a larger script than I would customarily post. But many folks have become accustom to getting it off this forum.
Every couple of years I update my favorite scripts. This script is one that I use regularly and have posted older versions every couple of years. I noticed that it has... (3 Replies)
Scenario:
I would want to copy my / to /mnt, and to avoid recursion exclude /mnt.
cp -avx / /mnt
If i use the above i believe it would run recursively, and end up in mess. So how to do it ?!
Basically this / is sda1, and /mnt is sda2 and sda1 is where only OS is available & currently... (2 Replies)
Hello dear........this is karan singh.
I want to ask a question that how can we install more than one OS in a single partition of any hard disk.
I am not asking about to install more than one os in a hard disk,but on a single partition.
NOTE:I am confident that it is possible to install... (2 Replies)
Please help - I need to copy a single file to multiple directories.
Dir structure:
Parent_Directoy
Filename1
Child_Directory1
Child_Directory2
Child_Directory3
Child_Directory4
....
So I need to copy Filename1 to all of the... (2 Replies)
Hi
Can anyone help me with the task below?
Example:
The contents in fileA.txt are:
HELLO
HOW DO U DO?
The contents in fileA.txt are:
HI
I AM FINE.
how to combine the data in 2 files into one with the format below?
Case A-fileA.txt
HELLO
HOW DO U DO?
Case B-fileB.txt (4 Replies)