View Single Post
  #6   (View Single Post)  
Old 13th October 2017
jggimi's Avatar
jggimi jggimi is offline
More noise than signal
 
Join Date: May 2008
Location: USA
Posts: 7,977
Default

This may help. I created a little 10G "drive" using vnconfig(8), just to show how to set up an FDE environment when multibooting.

I created an MBR, and set the OpenBSD partition to begin about half way, so it is 5G in size. This simulates a multiboot system, where only part of the disk is being used for OpenBSD. Below, you can see the MBR partition in both sectors and in GB.
Code:
# fdisk -e vnd0
Enter 'help' for information
fdisk: 1> p
Disk: vnd0      geometry: 209715/1/100 [20971520 Sectors]
Offset: 0       Signature: 0xAA55
            Starting         Ending         LBA Info:
 #: id      C   H   S -      C   H   S [       start:        size ]
-------------------------------------------------------------------------------
 0: 00      0   0   0 -      0   0   0 [           0:           0 ] unused      
 1: 00      0   0   0 -      0   0   0 [           0:           0 ] unused      
 2: 00      0   0   0 -      0   0   0 [           0:           0 ] unused      
*3: A6 104857   0   1 - 209714   0  20 [    10485700:    10485720 ] OpenBSD     
fdisk: 1> p g
Disk: vnd0      geometry: 209715/1/100 [20971520 Sectors]
Offset: 0       Signature: 0xAA55
            Starting         Ending         LBA Info:
 #: id      C   H   S -      C   H   S [       start:        size ]
-------------------------------------------------------------------------------
 0: 00      0   0   0 -      0   0   0 [           0:           0G] unused      
 1: 00      0   0   0 -      0   0   0 [           0:           0G] unused      
 2: 00      0   0   0 -      0   0   0 [           0:           0G] unused      
*3: A6 104857   0   1 - 209714   0  20 [    10485700:           5G] OpenBSD     
fdisk: 1>
Then, I created a disklabel with several partitions, to simulate having an existing system.
Code:
disklabel -p g vnd0
# /dev/rvnd0c:
type: vnd
disk: vnd device
label: fictitious
duid: ed6d7ca984c23716
flags:
bytes/sector: 512
sectors/track: 100
tracks/cylinder: 1
sectors/cylinder: 100
cylinders: 209715
total sectors: 20971520 # total bytes: 10.0G
boundstart: 10485700
boundend: 20971420
drivedata: 0 

16 partitions:
#                size           offset  fstype [fsize bsize   cpg]
  a:             1.0G         10485700  4.2BSD   2048 16384     1 
  b:             1.0G         12582880    swap                    
  c:            10.0G                0  unused                    
  d:             1.0G         14680000  4.2BSD   2048 16384     1 
  e:             1.0G         16777184  4.2BSD   2048 16384     1 
  f:             1.0G         18874272  4.2BSD   2048 16384     1
So far, what I have simulates your existing system. To "reinstall" as FDE, I can back up data (such as what may be in /root, /etc, /home, and /var) and my list of manually installed packages with $ pkg_info -qm and now I am ready to "reinstall" in my little test system. In reality, I would reboot with the RAMDISK kernel (bsd.rd) and use its shell, but I'm just replicating the disk management components of a reinstall.
  1. I'll use the disklabel(8) "z" command to delete all of the partitions I'd previously had on the drive. Notice that after "z", there are no disklabel partitions other than the partition representing the whole drive, but that the disklabel() program still knows the "OpenBSD area" defined by the MBR partition.
    Code:
    # disklabel -E vnd0
    Label editor (enter '?' for help at any prompt)
    > p
    OpenBSD area: 10485700-20971420; size: 10485720; free: 28
    #                size           offset  fstype [fsize bsize   cpg]
      a:          2097180         10485700  4.2BSD   2048 16384     1 
      b:          2097120         12582880    swap                    
      c:         20971520                0  unused                    
      d:          2097184         14680000  4.2BSD   2048 16384     1 
      e:          2097088         16777184  4.2BSD   2048 16384     1 
      f:          2097120         18874272  4.2BSD   2048 16384     1 
    > z
    > p
    OpenBSD area: 10485700-20971420; size: 10485720; free: 10485720
    #                size           offset  fstype [fsize bsize   cpg]
      c:         20971520                0  unused
  2. Now, I'll create a single "a" disklabel partition, of type RAID. Note that the starting sector offset is at the beginning of the OpenBSD area, based on the MBR partition. The "w" command writes the revised disklabel, so when I quit with "q" there are no additional changes to be saved.
    Code:
    > a a
    offset: [10485700] 
    size: [10485720] 
    FS type: [4.2BSD] raid
    > p
    OpenBSD area: 10485700-20971420; size: 10485720; free: 0
    #                size           offset  fstype [fsize bsize   cpg]
      a:         10485720         10485700    RAID                    
      c:         20971520                0  unused                    
    > w
    > q
    No label changes.
  3. Now, I can run bioctl, to create a new pseudo sd(4) device. In this case, the backing device and partition is vnd0a, but in your case you would use the real drive number. I have several sd() devices already, so the new device created is sd3 here.
    Code:
    # bioctl -c C -l /dev/vnd0a softraid0
    New passphrase: 
    Re-type passphrase: 
    softraid0: CRYPTO volume attached as sd3
  4. Now, in your RAMDISK kernel shell you would run MAKEDEV(8) to add your device nodes for your newly attached pseudo drive, then run the install script. Then use pkg_add(1) to reinstall your packages, then restore your backups. Here, I have a new 5G sd() device I can now slice up with new partitions.

Last edited by jggimi; 13th October 2017 at 01:03 PM. Reason: one miniscule typo, but I'm pedantic
Reply With Quote