[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: The Fine Art of Making a Bootable Drive



Le 03/08/2014 14:45, Martin G. McCormick a écrit :
	I am replacing a nearly 20-year-old 10 GB conventional
hard drive with a slightly-larger flash drive for / on a
Debian-squeeze system; / on flash as it were. I know this can
work as I have an older version of debian on another box that
has been doing this now for a couple of years and running just
fine.
	On that system, I used dd to copy everything including
the boot sector from that 10-GB drive to the new 16-GB flash
drive. At that point, I had a 10-GB flash copy of every byte
that had been on the electromechanical drive. I then resized the
#1 partition to take advantage of the larger new disk and it
ultimately worked but this can be done without quite so many steps.

I do the same everytime I move a very old system (my home router) on a new disk, and it always work perfectly.

	I used fdisk to format a brand new 16 GB flash drive
such that Partition 1 is a bit over 14 GB and the rest is
Logical Partition 5 and called swap. Partition 1 is marked as
bootable but, at the time, I did nothing about a boot sector. I
then used rsync and told it to copy devices which it appears to
have done. It copied devices, /proc and /sys and I ended up with
the new drive looking just like the old one except for being 6
GB larger.

Why did you use another method this time ? Wanted to change the filesystem or something ?

	For the boot sector, I copied the first 446 bytes of the
boot sector on the old drive as in
the following example I lifted from a Google search if the two
drives are different capacities:

    Copy MBR only of a hard drive:
    dd if=/dev/hda of=/dev/hdb bs=446 count=1

	The last 64 bits of the 512 mbr contain partition
information and this is where I may be all wet. I thought the
disk-copy process took care of that but if not, this is why my
new disk just sits there when it is installed.

What happens exactly ? Any error message ?
What is the active boot loader (lilo, grub 1/2, other) ?
Where was it installed ? In the MBR, or in the root/boot partition ?

Things you may like to know about grub and lilo :
Lilo hardcodes sector locations for accessing files and rsync didn't preserve them, so you must reinstall it on the new disk, by running lilo in a chroot.

If the boot loader is grub and was installed in the root/boot partition, then it also hardcodes sector locations for accessing files, so you must reinstall it with grub-install in a chroot.

If the boot loader is grub and is installed in the MBR, then it also uses the 62 "unused" sectors between the MBR and the first partition to store its coreimage (grub 2) or stage 1.5 (grub 1). You can try to copy those sectors to the new disk, but if grub uses the UUID to find the boot partition (not sure about that) it will fail, because you created a new filesystem and the UUID has changed. The simpler solution may be to reinstall grub as above.

Also, if the root= option in the kernel command line is defined with a UUID, you will need to update it in the bootloader config file (/boot/grub/menu.lst for grub 1, /boot/grub/grub.cfg for grub 2, /etc/lilo.conf for lilo). For grub, you can run update-grub in a chroot instead. For lilo, you must run lilo again in a chroot to make the change active.


Reply to: