Copying entire file system to new drive

I recently built an aac raid array. I've been trying for a few days to copy everything over and get it going. The first time, I partitioned the drive with sade, set up encryption on /home with gbdm, and copied everything over with tar. The loader kept saying "invalid partition" and I couldn't figure out why.

So I tried installing a base system to the root partition, verifying it would boot, then again setting up encryption on /home and copying everything with tar. Now when the loader comes up and I hit F1 to boot, it just displays a #. Obviously it becomes unbootable at the point of copying the files but I can't figure out why.
 
I suspect something you're doing is destroying the boot loader in you bsdlabel. You'll need to show us every step that you perform...
 
I,m not sure, but aren't /boot/boot and /boot/mbr sort of special files? It might go wrong if they are copied like all other files, since their correct location on the disk for booting is changed.
 
never heard of gbdm. how does it work?

the files in the /boot directory are not special. /boot/mbr is the master boot record and /boot/boot = /boot/boot1 + /boot/boot2 is the boot code embedded into the disk label. these files are inactive. their contents will be installed into the partition tables by various tools.

traditionally, to boot the system, you want to setup an fdisk partition table on your drive or array. The first sector (512 bytes) holds the partition table and the master boot code.

you can choose between /boot/mbr (the standard boot code) and /boot/boot0* (the boot manager).
use fdisk -B to (re)install the standard boot code.
use boot0cfg to install the boot manager
!never touch the boot sector manually with dd!

the boot manager is the one that accepts the F1 key. the loader is executed later in the boot process. don't mix it up.

normally, if you hit F1, the boot manager will look for a freebsd fdisk partition and runs the boot code embedded into the bsd disklabel.

if you are using a gpt partition, you have to put boot code into a separate partition with the gpt tool.

you can try the following command:
Code:
gpart show

which will output a list of all partitions on your system on a recent freebsd installation. if you post the output, I can take a look at your setup.
 
First of all, gdbm was a type. It should be gdbe.

That said, here's how I got to where I am. First, I burned a cd with 8.0 RC1 on it. I'm running RELENG_8 already. I do a minimal install on the raid array. While doing so, I made a slice that spans most of the disk. In it, I have a swap partition and a / partition. I left most of the slice available for an encrypted /home partition. The / partition is not and will not be encrypted. Once it completed, I verified I could boot to it. I could, so I rebooted to my old hard drive. I used sade to create another partition covering the rest of the slice. I followed the instructions in the handbook to initialize it as an encrypted partition. I used the command under examples in "man tar" to transfer everything from the partitions on the old drive to the partitions on the raid array. I made the necessary changes in fstab on the new drive, also setting the swap partition to be encrypted, and set gbde to run at boot in rc.conf. So that we're all on the same page, here's a list of the partitions and what they are.

/dev/aacd0s1a = /
/dev/aacd0s1b.bde = encrypted swap
/dev/aacd0s1d.bde = encrypted /home

Then I tried to reboot to the raid array, but at this point it just displayed a # every time I hit F1. So I booted back to the old disk and that's where I'm at now.

bb: You say fdisk -B (which I've used) installs the standard boot code and boot0cfg installs the boot manager. Is there a way to reinstall the disklabel boot code? I have a feeling that's where things are messing up. Here's the output from gpart show:

Code:
[kenshi@bahamut ~]% gpart show        
=>       63  488397105  ad6  MBR  (233G)
         63  488392002    1  freebsd  [active]  (233G)
  488392065       5103       - free -  (2.5M)

=>        63  1950330816  aacd0  MBR  (930G)
          63  1677716082      1  freebsd  [active]  (800G)
  1677716145   272614734         - free -  (130G)

=>        0  488392002  ad6s1  BSD  (233G)
          0   83886080      1  freebsd-ufs  (40G)
   83886080  404505922      4  freebsd-ufs  (193G)

=>         0  1677716082  aacd0s1  BSD  (800G)
           0    50331648        2  freebsd-swap  (24G)
    50331648   134217728        1  freebsd-ufs  (64G)
   184549376  1493166706        4  freebsd-ufs  (712G)

Again, the disk we're concerned with is aacd0.
 
After it breaks, try recreate the bsdlabel:

Code:
bsdlabel aacd0s1 >/tmp/label
bsdlabel -R -B aacd0s1 /tmp/label
 
your label doesn't look sane:

swap goes from zero to 50331648.
partition a goes from 50331648 to 134217728.

here is what it normally looks like:
Code:
=>        0  321672897  ad6s1  BSD  (153G)
          0         16         - free -  (8.0K)
         16    2097152      1  freebsd-ufs  (1.0G)
    2097168   16777216      2  freebsd-swap  (8.0G)
   18874384  302798513      4  freebsd-ufs  (144G)

important is the free block at the beginning, because this is where the boot code gets installed. since you have swap at the
beginning, you can repair it. you can make your swap partition smaller, by changing offset to 16 and size to 50331632.

i'd sugest to use
Code:
bsdlabel -e aacd0s1

and then simply
Code:
bsdlabel -B aacd0s1


I didn't use sade, and I don't know why it setup the label like this. I like the new gpart tool much more, and before, I used to write the label manually.

To move an existing installation to a new drive, I use dump and restore (in a pipeline) instead of tar after setting up the partitions with gpart.
 
bb said:
important is the free block at the beginning, because this is where the boot code gets installed.

You'll notice that the other drive also starts at 0 and it works fine. Just to rule it out though, I tried editing it with bsdlabel so that there's a 16 byte gap before the first partition and between each one like yours. When I tried to save, it said "class not found". It says the same thing when I tried to write the bootstrap code. What does this mean? I can find examples of other people getting similar errors in different situations but no explanation of what it means.

To move an existing installation to a new drive, I use dump and restore (in a pipeline) instead of tar after setting up the partitions with gpart.

I tried dump and restore first but it was slower and didn't show progress.
 
kenshi said:
When I tried to save, it said "class not found". It says the same thing when I tried to write the bootstrap code. What does this mean?
That is normal. It is caused by old geom code in bsdlabel I think, and is non-consequential in my experience.
 
I thought there wasn't but there was. However, it still doesn't change after unmounting it. There's no error other than about the class.
 
Other question: Can your bios boot directly from the array? Maybe the chain-loading (hitting F1) doesn't even work on your system.

You can disconnect the old drive, and try to do a fresh install from the cd directly to the array. The disk label setup by the freebsd installation has normally a root filesystem (starting at offset 16) on the first partition, swap space on the second, and usr on the third (auto-defaults).

a hint about dump: increase cache size: -C 128, use live dump: -L and watch progress by hitting Ctrl-T (only works in csh/tcsh and /bin/sh).
 
Yes, the bios can boot directly from the array. I'm gonna try installing a base system from the installation cd again, but set up all partitions this time during install. If sade is causing these problems, that should take care of it.
 
Just wanted to check in and say it worked. Apparently sade was wrecking the MBR/boot loader/something even though I told it to install the FBSD loader. Creating all the partitions initially and then configuring encryption from the other drive got things going. I did get some error that prevented me from loading KDE, but simply doing a make world fixed that. All the files are copied and I'm back to where I was, except for having a much larger drive.
 
Back
Top