View Single Post
  #3   (View Single Post)  
Old 5th October 2021
Sehnsucht94's Avatar
Sehnsucht94 Sehnsucht94 is offline
Real Name: Paolo Vincenzo Olivo
Package Pilot
 
Join Date: Oct 2017
Location: Rome
Posts: 169
Default

To expand on my previous reply, and referring more specifically to your use case, first consider that a NVMe SSD will be presented as a disk array controller by the the ld(4) driver, and will show as ld* amid the attached wedges. Assuming that this SSD is actually the first available disk, it should be assigned a ld0 devnode.

Note that, unlike OpenBSD, NetBSD does not write a BSD label to the secondary GPT header, meaning there won't be any a-z slices for wd*, sd* and ld* disks (i.e., no ld0a, ld0b...), but just dk* logical disk wedges (dk1, dk2, dkn...), since the filesystem won't be structured as a single BSD label (partition) containing various slices, but as a set of standard independent partitions (similarly to Linux or Windows). I think this is meant to allow for better compatibility with other OSs. See dk(4).

Practically speaking, if your NVMe disk is attached at ld0 and has a GPT layout containing 9 partitions, including the EFI system partition, you should see something like:
Code:
# sysctl hw.disknames
 hw.disknames = ld0 dk0 dk1 dk2 dk3 dk4 dk5 dk6 dk7 dk8
Code:
# dkctl ld0 listwedges
  /dev/rld0: 9 wedges:
  dk0: EFI system, 262144 blocks at 2048, type: msdos
  ...
  dk8: 2dfc926e-42bd-43fb-9bb5-b227c2c3fc99, 2560000 blocks at 264192, type: ffs
Code:
gpt show ld0
 
      start       size  index  contents
          0          1         PMBR (active)
          1          1         Pri GPT header
          2         32         Pri GPT table
         34       4062         Unused
       4096     262144         GPT part - EFI system
     266248  134215680      1  GPT part - NetBSD FFSv1/FFSv2
  134219776   16539648      2  GPT part - NetBSD swap

        ...       ....      *  ...
At this point use gpt(8) to create or modify new partitions, or delete existing ones. For instance, you can add a partition occupying all the free space left on the SSD by:
Code:
# gpt add -a 2m -t ffs -l "netbsd” ld0
Otherwise, if you're dealing with a MBR disk (is that really the case? you mentioned extended/logical partitions), you can convert it to a GPT disk with `gpt migrate', otherwise you can inspect the disk with disklabel(8). Use `disklabel -iI ld0', to enter the interactive mode and type 'P' (uppercase) to print the current partition layout. Should be something like:
Code:
11 partitions:
#        size    offset     fstype [fsize bsize cpg/sgs]
 a:  62093312    458752     4.2BSD      0     0     0  # (Cyl.    224 -  30542)
 b:    262144    196608       swap                     # (Cyl.     96 -    223)
 c:  62552064         0     unused      0     0        # (Cyl.      0 -  30542)
 d:  62093312    458752     unused      0     0        # (Cyl.    224 -  30542)
e-k:        *         *          *      *     *        # (Cyl.      * -      *)
  • "a" is the root partition, partition type is "4.2BSD" (a slice in a BSD label)
  • "b" is traditionally the swap partition, partition type is "swap".
  • "c" is the space addressed by the MBR table on i386 and amd64.
  • "d" addresses the whole disk on x86/AMD64. Neither alter this one, or the one before.
  • e-k The other partitions, may be "4.2BSD" just like "a".
Type the letter of any partition (lowercase) to edit it, eventually type 'W' and 'Q' (uppercase) to write the new disk layout and exit, respectively.

Either way, you can format the newly created raw partition(s) (note the prepended 'r' below, before the device node indentifier) with newfs(8):
Code:
# newfs -O 2 -V2 -f 2048 /dev/rld0* # on MBR
# newfs -O 2 -V2 -f 2048 /dev/rdk*  # on GPT

`-O2'
will tell newfs to format the partitions as FFsv2. Naturally you can use FFSv1 for compatibility reasons (e.g. mount across BSDs), or use ZFS or LFS.
Quote:
Originally Posted by dchmelik View Post
[...] and want to install NetBSD on a logical partition in the extended one.
As far as I know BSDs require root to be on a primary partition and cannot be installed on an extended one. Depending on your goal, it would be better to use LVM on NetBSD. Also, see lvm(8).

If you still insist on creating an extended partition, use fdisk(8).

As a side note, to display a human-readable summary of the nvme0 IDENTIFY_CONTROLLER data, you can use:
Code:
# nvmectl identify nvme0
__________________
“Mi casa tendrá dos piernas y mis sueños no tendrán fronteras„

Last edited by Sehnsucht94; 5th October 2021 at 12:32 PM.
Reply With Quote