Unix Technical Forum

SEO

vBulletin Search Engine Optimization


Go Back   Unix Technical Forum > Unix Operating Systems > Linux Operating System

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 01-17-2008, 07:10 AM
Linux Lover
 
Posts: n/a
Default How to copy the /boot partition?

My 4GB HDD is dying. I need to transfer it ASAP to another HDD. I
tried copying it to an 8.4GB HDD I had lying around. I used Partition
Magic (hereby PM) to copy all partitions and at first all seemed well.
But when I tried to boot using the new HDD, it refused. I used Linux's
fdisk to view it and was surprised that Linux's "Extended" partition
(id=5)is not the same as the one PM placed while copying the various
partitions (id=f). I corrected it, but I am still having problem
copying the /boot partition so that it would boot.

My original (failing) HDD looks like this:

~> /sbin/fdisk -lu /dev/hda
Device Boot Start End Blocks Id System
/dev/hda1 63 40319 20128+ 83 Linux
/dev/hda2 40320 7814015 3886848 5 Extended
/dev/hda5 40383 3322367 1640992+ 83 Linux
/dev/hda6 3322431 6604415 1640992+ 83 Linux
/dev/hda7 6604479 7136639 266080+ 83 Linux
/dev/hda8 7136703 7668863 266080+ 83 Linux
/dev/hda9 7668927 7805951 68512+ 82 Linux swap


The new disk, OTOH, has for some reason (the way PM set it up), the
extended partition as /dev/hdb1 and the boot partition as /dev/hdb2
(all other partitions are correctly positioned/copied).

My questions are:
1) Why is PM and fdisk are having such a hard time "talking" to each
other?
2) How do I copy the /boot partition, so that not only its contents is
copied but it also boots when I replace the old HDD with the new HDD
(i.e. /dev/hdb becomes /deb/hda). Do I use LILO to do that? If so, how
do I change lilo.conf so that it doesn't change in anyway the original
drive (I still need it, in case something goes awfully wrong with the
new HDD. I cannot boot from a floppy).

Thanks in advance!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 01-17-2008, 07:10 AM
Alan Connor
 
Posts: n/a
Default Re: How to copy the /boot partition?

On 29 Sep 2003 09:38:25 -0700, Linux Lover <linuxlover992000@yahoo.com> wrote:

I'd mount the new drive and use cfdisk to lay out the partitions, then
format each one with mke2fs.

Then mount each partition and from each top-level directory to be copied, run
cp -a * /mnt/whatever.

Then edit /etc/fstab and /etc/lilo.conf on the new system and run lilo.

--
Later, Alan C
You can find my email address at the website:
elrav1.html --> ACKNOWLDEGEMENTS/CONTACT (20k or less, plain text)
take control of your mailbox ----- elrav1 ----- http://tinyurl.com/l55a
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 01-17-2008, 07:10 AM
Peter T. Breuer
 
Posts: n/a
Default Re: How to copy the /boot partition?

Linux Lover <linuxlover992000@yahoo.com> wrote:
> My 4GB HDD is dying. I need to transfer it ASAP to another HDD. I
> tried copying it to an 8.4GB HDD I had lying around. I used Partition
> Magic (hereby PM) to copy all partitions and at first all seemed well.


Don't use PM. Just use normal tar. Or cp.


> But when I tried to boot using the new HDD, it refused. I used Linux's


Well, why would you expect it to boot? The mbr will be all wrong, no?

> fdisk to view it and was surprised that Linux's "Extended" partition
> (id=5)is not the same as the one PM placed while copying the various
> partitions (id=f). I corrected it, but I am still having problem


Doesn't matter. Just don't use PM anyway!

> copying the /boot partition so that it would boot.


Why are you copying! Don't! Just edit your $&&$&$$ lilo.conf to bvecome
correct and run lilo!

> 1) Why is PM and fdisk are having such a hard time "talking" to each
> other?


They aren't. You are. Don't use PM.

> 2) How do I copy the /boot partition, so that not only its contents is


What's your problem with "cp"?

Peter
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 01-17-2008, 07:10 AM
Eric Moors
 
Posts: n/a
Default Re: How to copy the /boot partition?

> My 4GB HDD is dying. I need to transfer it ASAP to another HDD. I
> tried copying it to an 8.4GB HDD I had lying around. I used Partition
> Magic (hereby PM) to copy all partitions and at first all seemed well.
> But when I tried to boot using the new HDD, it refused. I used Linux's
> fdisk to view it and was surprised that Linux's "Extended" partition
> (id=5)is not the same as the one PM placed while copying the various
> partitions (id=f). I corrected it, but I am still having problem


Correcting it may not be the correct word. I guess PM corrected
the incorrect original table for you. Anyway 0x05 may be wrong,
0x0F won't be. Use 0x0F instead. (or 0x85 in your case as there are
only linux partitions inside)

> copying the /boot partition so that it would boot.


That won't work.
Make a bootflop, boot from that, and afterwards run lilo to fix
the MBR. Or use grub (I can't believe I said that ;-) ).

> My original (failing) HDD looks like this:
>
> ~> /sbin/fdisk -lu /dev/hda


Don't skip the geometry info.
For hda it's not that important, but to tell if PM fixed something
or just prefers to be on the safe side, the geometry info if hdb
is important

> Device Boot Start End Blocks Id System
> /dev/hda1 63 40319 20128+ 83 Linux
> /dev/hda2 40320 7814015 3886848 5 Extended
> /dev/hda5 40383 3322367 1640992+ 83 Linux
> /dev/hda6 3322431 6604415 1640992+ 83 Linux
> /dev/hda7 6604479 7136639 266080+ 83 Linux
> /dev/hda8 7136703 7668863 266080+ 83 Linux
> /dev/hda9 7668927 7805951 68512+ 82 Linux swap
>
>
> The new disk, OTOH, has for some reason (the way PM set it up), the
> extended partition as /dev/hdb1 and the boot partition as /dev/hdb2


I have no idea how you copied the disc in PM. If you can just say to
copy a disc as a whole, blame it on PM. If you manually selected the
partitions to be copied, you probably selected hem in the wrong order.

Anyway, use fdisk to partition the new disc, and use cp to copy the
data. (or tar or cpio or whatever)

> (all other partitions are correctly positioned/copied).
>
> My questions are:
> 1) Why is PM and fdisk are having such a hard time "talking" to each
> other?


?
They don't talk to each other. The follow a certain ruleset that
describes a valid partitiontable. linux fdisk doesn't have all
DOS/windows limitations incorporated though. PM is usually more strict.
(or more on the safe side)

> 2) How do I copy the /boot partition, so that not only its contents is
> copied but it also boots when I replace the old HDD with the new HDD
> (i.e. /dev/hdb becomes /deb/hda). Do I use LILO to do that? If so, how
> do I change lilo.conf so that it doesn't change in anyway the original
> drive (I still need it, in case something goes awfully wrong with the
> new HDD. I cannot boot from a floppy).


Booting from a floppy would be easiest.
If that's not possible, create a temporary lilo.conf that expicitly
states that hdb is known by the BIOS as 0x80. lilo will probably
complain when you run it, as that information is incorrect at that time.
It will however make hdb bootable after hda is disconnected.

Eric
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 01-17-2008, 07:11 AM
Linux Lover
 
Posts: n/a
Default Re: How to copy the /boot partition?

Eric - thank you so much for your thoughtful answer!

Eric Moors <scare.crow@oz.land> wrote in message news:<pan.2003.09.30.08.52.49.798860.10893@oz.land >...
> > fdisk to view it and was surprised that Linux's "Extended" partition
> > (id=5)is not the same as the one PM placed while copying the various
> > partitions (id=f). I corrected it, but I am still having problem

>
> Correcting it may not be the correct word. I guess PM corrected
> the incorrect original table for you. Anyway 0x05 may be wrong,
> 0x0F won't be. Use 0x0F instead. (or 0x85 in your case as there are
> only linux partitions inside)


You may be correct (no pun intended ) but I have been running this
server for years while it was with id=5. I didn't specify it. RedHat
6.2's install program partitioned everything automatically (at the
time of the install back then, I just accepted the installation
program's defaults).

> > copying the /boot partition so that it would boot.

>
> That won't work.
> Make a bootflop, boot from that, and afterwards run lilo to fix
> the MBR. Or use grub (I can't believe I said that ;-) ).


That's exactly (sort of) what I did. I used Linuxcare's Bootable
Toolbox CD. (don't ask how difficult it was to burn that CD... Nero on
W2K wouldn't burn it *bootable*. Fortunately, my old Linux HDD was
still somehow operable, so I used cdrecord to do that.)

> Don't skip the geometry info.


What do you mean by that? Where did I skip the geometry info?

> > The new disk, OTOH, has for some reason (the way PM set it up), the
> > extended partition as /dev/hdb1 and the boot partition as /dev/hdb2

>
> I have no idea how you copied the disc in PM. If you can just say to
> copy a disc as a whole, blame it on PM. If you manually selected the
> partitions to be copied, you probably selected hem in the wrong order.


That was exactly the problem: I simplified my original posting by
describing th e destination disk as new. It is newer then the faulty
one, but it had one partition I couldn't loose (nor backup, since the
backup program was on the faulty drive and ceased functioning
properly). It was /home ...

so, I had to use PM to resize, move, add, delete, add, etc.
PM didn't have any problem with that: it reported the partitions
according to their physical order. I thought Linux's fdisk would do
that, too. It didn't.

> Anyway, use fdisk to partition the new disc, and use cp to copy the
> data. (or tar or cpio or whatever)


I couldn't. I used the convoluted ordering as above. Used LBT to run
lilo (very carefully) and bingo - it works! MBR now on /dev/hda, which
happens to be reported by fdisk ad /dev/hda2. Weird (but works ).
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 01-17-2008, 07:11 AM
Eric Moors
 
Posts: n/a
Default Re: How to copy the /boot partition?

>> > fdisk to view it and was surprised that Linux's "Extended" partition
>> > (id=5)is not the same as the one PM placed while copying the various
>> > partitions (id=f). I corrected it, but I am still having problem

>>
>> Correcting it may not be the correct word. I guess PM corrected
>> the incorrect original table for you. Anyway 0x05 may be wrong,
>> 0x0F won't be. Use 0x0F instead. (or 0x85 in your case as there are
>> only linux partitions inside)

>
> You may be correct (no pun intended ) but I have been running this
> server for years while it was with id=5.


0x05 is correct as far as linux is concerned. Even for DOS/windows
it may be correct. Depends on the location of the partition. If it is
even partly beyond cylinder 1024, DOS/windows requires the type to be
0x0F.

> I didn't specify it. RedHat
> 6.2's install program partitioned everything automatically (at the
> time of the install back then, I just accepted the installation
> program's defaults).


There's no harm in having it 0x05 in your case. Linux doesn't care.
Windows get's confused if it isn't correct. That's why PM tries to fix
the table if something doesn't match the windows requirements.

>> Don't skip the geometry info.

>
> What do you mean by that? Where did I skip the geometry info?


The output from fdisk -l also contains geometry info. (CHS values)
You didn't include them in your post.

> That was exactly the problem: I simplified my original posting by
> describing th e destination disk as new. It is newer then the faulty
> one, but it had one partition I couldn't loose (nor backup, since the
> backup program was on the faulty drive and ceased functioning
> properly). It was /home ...
>
> so, I had to use PM to resize, move, add, delete, add, etc.
> PM didn't have any problem with that: it reported the partitions


Then that's how they got shuffled. It doesn't really matter though.

> according to their physical order. I thought Linux's fdisk would do
> that, too. It didn't.


both programs report the table as found on disc. If the output is
different, there is something weird with your table. I do trust the
output of fdisk though, so I believe they are shuffled. This isn't
wrong, just a bit awkward. You could easily reorder the partitions
with sfdisk, but I wouldn't bother.

>> Anyway, use fdisk to partition the new disc, and use cp to copy the
>> data. (or tar or cpio or whatever)

>
> I couldn't.


From a rescue system you would have been able to do this.

> I used the convoluted ordering as above. Used LBT to run
> lilo (very carefully) and bingo - it works! MBR now on /dev/hda, which
> happens to be reported by fdisk ad /dev/hda2. Weird (but works ).


?
The MBR is *never* part of a partition.
I think you mean your boot partition (I guess) is now hda2 instead of
hda1. That may hold a boot record, but not the master boot record.

Eric
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 01-17-2008, 07:12 AM
Linux Lover
 
Posts: n/a
Default Re: How to copy the /boot partition?

Eric Moors <scare.crow@oz.land> wrote in message news:<pan.2003.09.30.16.28.25.38915.12123@oz.land> ...
> The MBR is *never* part of a partition.
> I think you mean your boot partition (I guess) is now hda2 instead of
> hda1. That may hold a boot record, but not the master boot record.


Thanks for this clarification. I am ashamed to admit that I wasn't
aware of this distinction. I thought that the boot record of the first
sector in a HDD (usually hda1, but in my case is hda2) is also the
boot record of hda (which is the MBR). Obviously, this is not so.

(To my defense, I would just mention that I *used* to know what you've
just explained. I just fell asleep for a week or two... )

You guessed correctly that my boot partition is now hda2 (which is
physically located *before* hda1).
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 01-17-2008, 07:13 AM
Nico Kadel-Garcia
 
Posts: n/a
Default Re: How to copy the /boot partition?

Linux Lover wrote:

> Eric Moors <scare.crow@oz.land> wrote in message news:<pan.2003.09.30.16.28.25.38915.12123@oz.land> ...
>
>>The MBR is *never* part of a partition.
>>I think you mean your boot partition (I guess) is now hda2 instead of
>>hda1. That may hold a boot record, but not the master boot record.


??? It most certainly can be, or what do you think "grub-install
/dev/hda1" does?

The MBR is typically installed at the beginning of the disk, but it can
also be accessed via a partition marked as "active". I'm not sure how
many other ways there are to locate one.

> Thanks for this clarification. I am ashamed to admit that I wasn't
> aware of this distinction. I thought that the boot record of the first
> sector in a HDD (usually hda1, but in my case is hda2) is also the
> boot record of hda (which is the MBR). Obviously, this is not so.


That is correct. One of the most confusing things to run into is when
one person or tool installed an MBR in /dev/hda, and another tool put
one in /dev/hda1, and the one iin /dev/hda takes precedence.

> (To my defense, I would just mention that I *used* to know what you've
> just explained. I just fell asleep for a week or two... )
>
> You guessed correctly that my boot partition is now hda2 (which is
> physically located *before* hda1).


Why would you ever do this? I know Compaq does this sort of whackiness
with their system management tools, putting it on /dev/sda3 which is
located at the beginning of the disk, and it still irritates the hell
out of me....

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #9 (permalink)  
Old 01-17-2008, 07:13 AM
Eric Moors
 
Posts: n/a
Default Re: How to copy the /boot partition?

On Thu, 02 Oct 2003 06:54:03 +0200, Nico Kadel-Garcia wrote:

> Linux Lover wrote:
>
>> Eric Moors <scare.crow@oz.land> wrote in message news:<pan.2003.09.30.16.28.25.38915.12123@oz.land> ...
>>
>>>The MBR is *never* part of a partition.
>>>I think you mean your boot partition (I guess) is now hda2 instead of
>>>hda1. That may hold a boot record, but not the master boot record.

>
> ??? It most certainly can be, or what do you think "grub-install
> /dev/hda1" does?


It installs the bootloader GRUB in hda1.
NOT in the MBR
grub-install /dev/hda would do that (I guess: I'm a lilo user)

The MBR is *always* located at CHS=001
try `fdisk -lu`
check where hda1 starts.

> The MBR is typically installed at the beginning of the disk, but it can
> also be accessed via a partition marked as "active".


no way.
mark eg. hda5 active. and reboot.
nothing changes. (unless your MBR contains the default DOS loader)
grub and lilo, usually installed partly in the MBR will ignore
this.

> I'm not sure how many other ways there are to locate one.


There can be only one. (finally a highlander quote I can use ;-))
The MBR is always at cyl 0, head 0, sector 1.
There is always discussion whether you can call the MBR at a second
disc (hdb) also MBR, 'cause there can be only one (Did it again :-))
You cannot remove it, you cannot relocate it.
You obviously can blank it, and remove all bootcode from it.
You can even remove the partitiontable entries from it.
But that's basically it.

>> Thanks for this clarification. I am ashamed to admit that I wasn't
>> aware of this distinction. I thought that the boot record of the first
>> sector in a HDD (usually hda1, but in my case is hda2) is also the
>> boot record of hda (which is the MBR). Obviously, this is not so.

>
> That is correct. One of the most confusing things to run into is when
> one person or tool installed an MBR in /dev/hda, and another tool put
> one in /dev/hda1, and the one iin /dev/hda takes precedence.


You are mixing up bootrecords with bootcode.

>> (To my defense, I would just mention that I *used* to know what you've
>> just explained. I just fell asleep for a week or two... )
>>
>> You guessed correctly that my boot partition is now hda2 (which is
>> physically located *before* hda1).

>
> Why would you ever do this? I know Compaq does this sort of whackiness
> with their system management tools, putting it on /dev/sda3 which is
> located at the beginning of the disk, and it still irritates the hell
> out of me....


Please read the original post. The OP did this unintentionally.
Though I agree that it is annoying, it is not incorrect as far as I know.

Eric
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 09:45 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
UnixAdminTalk.com

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581