Moving raw system image to another drive breaks GELI

David Christensen dpchrist at holgerdanske.com
Wed Feb 27 02:43:23 UTC 2019


On 2/26/19 10:00 AM, David Christensen wrote:
> I have a computer:
> 
> 2019-02-26 09:50:14 dpchrist at ragnar ~
> $ freebsd-version ; uname -a
> 11.2-RELEASE-p9
> FreeBSD ragnar 11.2-RELEASE-p9 FreeBSD 11.2-RELEASE-p9 #0: Tue Feb  5 
> 15:30:36 UTC 2019 
> root at amd64-builder.daemonology.net:/usr/obj/usr/src/sys/GENERIC  amd64
> 
> 
> I installed to a SanDisk Ultra Fit USB 3.0 16 GB flash drive:
> 
>        Partitioning                      Auto (ZFS)
>          Pool Type/Disks                 stripe,da0
>          Pool Name                       zroot
>          Force 4K Sectors                YES
>          Encrypt Disks                   YES
>          Partition Scheme                MBR (BIOS)
>          Swap Size                       2g
>          Mirror Swap                     NO
>          Encrypt Swap                    YES
>          Install
> 
> 
> If I do a raw binary copy of the USB flash drive to a Intel 520 Series 
> SSD 60 GB with dd(1) and boot the SSD, GELI rejects the passphrase and I 
> end up at a "mountroot>" prompt.
> 
> 
> I would like to be able to move raw FreeBSD system images from drive to 
> drive and have them work.


McKusick 2015 p. 214 states "GELI's metadata is found in the last sector 
of the underlying device or partition".


Examine the slice/ partition tables for the USB flash drive:

         root at ragnar:~ # gpart show da0 da0s1
         =>      63  30031809  da0  MBR  (14G)
                 63         1       - free -  (512B)
                 64  30031808    1  freebsd  [active]  (14G)

         =>       0  30031808  da0s1  BSD  (14G)
                  0   4194304      1  freebsd-zfs  (2.0G)
            4194304   4194304      2  freebsd-swap  (2.0G)
            8388608  21643200      4  freebsd-zfs  (10G)


Examine the last sector of MBR primary partition 1, which is also the 
last sector of the drive:

         root at ragnar:~ # dd if=/dev/da0 skip=30031871 status=none |
hexdump | tee usb-sector-30031871.hexdump
         00000000  47 45 4f 4d 3a 3a 45 4c  49 00 00 00 00 00 00 00 
|GEOM::ELI.......|
         <snip>


Examine the slice/ partition tables for the SSD:

         root at ragnar:~ # gpart show ada1 ada1s1
         =>       63  117231345  ada1  MBR  (56G)
                  63          1        - free -  (512B)
                  64   30031808     1  freebsd  [active]  (14G)
            30031872   87199536        - free -  (42G)

         =>       0  30031808  ada1s1  BSD  (14G)
                  0   4194304       1  freebsd-zfs  (2.0G)
            4194304   4194304       2  freebsd-swap  (2.0G)
            8388608  21643200       4  freebsd-zfs  (10G)


The last sector of MBR primary partition 1 contains the same binary data 
as that of the USB flash drive.

         root at ragnar:~ # dd if=/dev/ada1 skip=30031871 count=1 
status=none | hexdump | tee ssd-sector-30031871.hexdump
         00000000  47 45 4f 4d 3a 3a 45 4c  49 00 00 00 00 00 00 00 
|GEOM::ELI.......|
         <snip>


Fetch a copy of the data:

         root at ragnar:~ # dd if=/dev/ada1 skip=30031871 count=1 
of=last-block.bin
         1+0 records in
         1+0 records out
         512 bytes transferred in 0.001179 secs (434316 bytes/sec)


Write it to the last sector of the SSD:

         root at ragnar:~ # dd if=last-block.bin of=/dev/ada1 seek=117231407
         1+0 records in
         1+0 records out
         512 bytes transferred in 0.012096 secs (42327 bytes/sec)


Power down, remove USB flash drive, boot SSD -- GELI still broken.


Ideas?


David



More information about the freebsd-questions mailing list