Hi! I decided to start using NetBSD, so I saw the opportunity to do it when I upgraded my main machine, a Lenovo IdeaPad 320-15AST, a little. It is based on the AMD A9-9420 (which, according to a mailing list message I found, should be supported by NetBSD), has now 8 GB of RAM, a "500 GB" 7200 rpm HDD and the newest BIOS. I indended to use it in a multiboot configuration, along with FreeDOS 1.3 and Microsoft Windows 7 SP1 64-bit.

So first came to partitioning the disk. All the MBR partitions were created during FreeDOS' installation. Later I installed Windows 7 and formatted relevant partitions to NTFS. As usual, the laptop now booted only to Windoze. NetBSD came the last - here is the resulting layout, as seen in the installer (which I ran from an USB stick):

       Start(MB)      Size(MB) Flag Kind             Mount    Bootmenu
   ------------- ------------- ---- ---------------- -------- --------
a:             0          2055      Windows FAT32    FREEDOS2 FreeDOS
b:          2055           203      NTFS                      Windoze
c:          2259        146044 Ia   NetBSD                    NetBSD
d:        148303        328634      Extended partition, LBA
e:        148303         16386      NTFS
f:        164689        115624      NTFS
g:        280313         98311      NTFS
h:        378625         98311      Windows FAT32, L DOS_DANE

I was a little surprised by the ability to configure multiboot in the installer, since I searched a bit previously about multibooting NetBSD and Windows 7, only to find very little information on the subject. I thought about using BCD, as I did previously with OpenBSD, which involves copying the first 512 B of the root partition to a file. Anyway, I decided to give the NetBSD's boot selector a try.

Next came partitioning the NetBSD's slice. I mostly replicated the layout I tended to use with OpenBSD:

     Start (MB)     End (MB)    Size (MB)  FS type Flag Filesystem
   ------------ ------------ ------------ -------- ---- ----------
a:         2388         5390         3003    FFSv2 N    /
b:         5391        21775        16385     swap
c:         2259       148302       146044 NetBSD partition
d:            0       476939       476940 Whole disk
e:         2260         2387          128    MSDOS N
f:        21776        27780         6005    FFSv2 N    /usr
g:        27781        33538         5758    FFSv2 N    /var
h:        33539        42545         9007    FFSv2 N    /usr/local
i:        42546        44594         2049    FFSv2 N    /var/log
j:        44595        46396         1802    FFSv2 N    /usr/X11R7
k:        46397        47597         1201    FFSv2 N    /usr/src
l:        47598        49999         2402    FFSv2 N    /usr/obj
m:        50000       148302        98303    FFSv2 N    /home

All partitions created successfully.

I chose to install the following distribution sets:

  • Kernel (GENERIC)
  • Kernel modules
  • Base
  • Configuration files (/etc)
  • Compiler tools
  • Games
  • Manual pages
  • All X11 sets
  • Kernel sources (from Source and debug sets)
  • Base sources (from Source and debug sets)

Initially I wanted to install Share sources, GNU sources and X11 sources as well but during every installation attempt they threw errors related to creating directories and links, so I eventually gave up on them. This didn't affect the main problem in any way. I don't know if this is relevant, but I chose to delete downloaded files after installation.

So it came to final configuration. The network worked during downloading the sets, as well as pkgin and pkgsrc. I added a second user, with /bin/ksh as the shell. The screen looked as follows:

a: Configure network                         configure
b: Timezone                                  Europe/Warsaw
c: Root shell                                /bin/sh
d: Change root password                      password set
e: Enable installation of binary packages    DONE
f: Fetch and unpack pkgsrc                   DONE
g: Enable sshd                               NO
h: Enable ntpd                               NO
i: Run ntpdate at boot                       NO
j: Enable mdnsd                              NO
k: Enable xdm                                NO
l: Enable cgd                                NO
m: Enable lvm                                NO
n: Enable raidframe                          NO
o: Add a user
x: Finished configuring

By default, cgd and raidframe were enabled - I tried this too. Other time I enabled xdm and disabled everything else on the list. No difference in any way, when it comes to main problem.

Installation finished, so I chose to reboot the computer. The following menu appeared:

Fn: diskn
1: FreeDOS
2: Windoze
3: NetBSD

Pressing 3 gives me "Error 3". What's interresting however, FreeDOS 1.3 and Microsoft Windows 7 SP1 64-bit boot fine, out of the box.

I searched about this problem. I found some threads on mailing lists, but the information was sparse. Someone mentioned being able to boot from the installer's boot prompt using the command boot hd0a:netbsd. In my case I got the following:

open: hd0a:netbsd: No such file or directory
boot: hd0a:netbsd: Input/output error

I also tried "wd0a" and "rwd0a" in place of "hd0a", the I tried ommiting the "a" letter but nothing worked. Finally I ran a shell from the installer and managed to successfully mount the root partition, with it's proper contents being in place.

I tried to find some more extensive documentation on NetBSD's boot selector but no success there. Besides the image of 9.2 release, I tried 9.2_STABLE images from between 30th April and 3rd May (doing a fresh installation in place of the previous one) - no difference. So I decided to register here and give all details regarding my installation, so maybe someone more experienced or knowledgeable will spot a mistake I'm not aware of or point out other cause of the problem. Any advice/assistance/solution/help will be highly appreciated!

  • rvp replied to this.

    JaWie_66 The Error 3 means that a valid boot signature was not found in the 1st sector of the NetBSD partition. Maybe the PBR wasn't written to the right place? Or, not written at all?

    In any case, you'll have to redo the install because you've created an overlapping partition:

         Start (MB)     End (MB)    Size (MB)  FS type Flag Filesystem
       ------------ ------------ ------------ -------- ---- ----------
    f:        21776        27788         6005    FFSv2 N    /usr
    g:        27781        33538         5758    FFSv2 N    /var

    /var begins within /usr:

    Recommendations:

    1. Having a MS-DOS partition at the beginning of the NetBSD disk space (oddly offset by 1MB) is unusual. Normally / sits here; swap is next. Not sure why this partition is needed at all.

    2. I would increase the size of /, /usr and /usr/src. Full source alone requires 3-4 GB. Installing the debug sets will take up a lot more space in /usr. You might have to increase /usr/obj too for a full system rebuild.

    3. Create a /usr/pkg instead of /usr/local. On NetBSD, external packages are installed in /usr/pkg instead of /usr/local (FreeBSD/OpenBSD location). In fact, a /usr/local dir. isn't created at all as part of a standard install.

    4. 16 GB of swap may be a bit excessive. So is a separate /usr/X11R7 partition.

    JaWie_66 I also tried "wd0a" and "rwd0a" in place of "hd0a"

    wdNx or sdNx would be correct. At a prompt, use sysctl hw.disknames to get a list.

      JuvenalUrbino Are they? ; boot(8) uses hdNx for anything but floppy drives.

      You're right. Got it confused with the root command which does use wdNx and sdNx. In fact, the man-page explicitly states (section BUGS):

      There isn't any distinction between ``sd'' and ``wd'' devices at the bootloader level.

      Retracted. (Keep it comin'.)

      rvp you've created an overlapping partition

      I'm sorry, that was a typo, a case of mistaking a 0 for 8 - no partitions overlap actually, I edited my post to correct this mistake.

      Besides that thank you very much for your advices, they are certainly welcome. I didn't know about /usr/pkg, so I applied it during the recent installation attempt. I also got rid of separate /usr/X11R7 partition, combining its space into /usr. I'm going to think about a new space assignment scheme, to take your recommendation number 2 into consideration.

      rvp Having a MS-DOS partition at the beginning of the NetBSD disk space (oddly offset by 1MB) is unusual. Normally / sits here; swap is next. Not sure why this partition is needed at all.

      As far as I understood the messages during installation, it is needed by the boot selector. It is already there when I get to add new partitions to the slice and set their sizes - its filesystem is specified as (Other: MSDOS <Boot>).

      Unfortunately, the problem with booting perisists.

      JuvenalUrbino @JaWie_66 probably needs hd0c to select the NetBSD disklabel

      I eventually managed to boot NetBSD from the USB installer's boot prompt by entering boot hd1a:netbsd. However, several initial attempts failed by stopping on the following line:
      [ 5.6740817] video0 at uvideo0: Chicony Electronics Co.,Ltd. (0x4f2) EasyCamera (0xb5d8), rev 2.00/26.22, addr 4
      I entered the BIOS to see if I can disable the webcam, but there wasn't any such option. I turned off the laptop and did other things, then sat to finally reply to you all (sorry for the delay, I've been a little busy for a while) using a second PC and decided to try again, because why not. This time the webcam didn't prevent the system from booting and NetBSD finally ran on my laptop for the first time. I'm now doing some initial settings, as well as trying to learn about the whole PBR thing.

      • rvp replied to this.
      • Jay likes this.

        JaWie_66 Unfortunately, the problem with booting perisists.

        JaWie_66 I eventually managed to boot NetBSD from the USB installer's boot prompt by entering boot hd1a:netbsd

        After you boot into NetBSD, can you post the output of these 2 commands:

        ls -l /boot
        dd if=/dev/wd0c bs=1k count=1 | hexdump -C

        (Assuming your disk is wd0)

        JaWie_66 I entered the BIOS to see if I can disable the webcam, but there wasn't any such option.

        How about under (internal) USB devices?

          rvp After you boot into NetBSD, can you post the output of these 2 commands:

          ls -l /boot
          dd if=/dev/wd0c bs=1k count=1 | hexdump -C

          (Assuming your disk is wd0)

          Yes, my disk is wd0. However, both commands return errors. When it comes to ls -l /boot, I get:

          ls: /boot: No such file or directory

          Meanwhile, in case of dd if=/dev/wd0c bs=1k count=1 | hexdump -C the output is:

          dd: /dev/wd0c: Device not configured

          I decided to take a look at the MS-DOS partition under /dev/wd0e. It has a simple, single-branch directory structure: ./efi/boot/. There are two files in that directory: bootia32.efi and bootx64.efi.

          rvp JaWie_66 I entered the BIOS to see if I can disable the webcam, but there wasn't any such option.

          How about under (internal) USB devices?

          There isn't even such category. Unfortunately, this is one of the laptops witha a very dumbed-down BIOS. I searched for a way to show more advanced options, which some vendors offer, however it's not the case here. Apparently there is some modified BIOS image for this machine with much more features, however the information isn't very excessive and it requires being flashed directly onto the IC on the motherboard, using special adapter and a programming device, so, at least for now, I gave myself a miss.

          • rvp replied to this.
          • Jay likes this.

            JaWie_66

            ls: /boot: No such file or directory
            dd: /dev/wd0c: Device not configured

            JaWie_66 I decided to take a look at the MS-DOS partition under /dev/wd0e. It has a simple, single-branch directory structure:./efi/boot/. There are two files in that directory: bootia32.efi and bootx64.efi.

            OK. I think I know what's going on here. There are 2 USB-install images for amd64 (for STABLE; RELEASE combines these, but, I've not tried an MBR install with RELEASE):

            • NetBSD-9.2_STABLE-amd64-bios-install.img.gz for BIOS with MBR, and,
            • NetBSD-9.2_STABLE-amd64-install.img.gz for UEFI with GPT.

            and, going by those error messages, you probably picked the UEFI image.

            At this point, you can take one of 3 paths:

            1. Redo your entire install so that it uses UEFI and GPT. This would be the least troublesome option in the long run, but, you'll have to reinstall everything on the disk. Windows might cope with GPT, but, I don't know if FreeDOS can handle it.

            2. Download the correct image and redo the NetBSD install again.

            3. Keep everything as is and only fix the NetBSD boot issue.

            Did you choose to install the bootbllocks when you were presented with that option?

              rvp Did you choose to install the bootbllocks when you were presented with that option?

              That's a good question. If you mean something like figure 3.17 in The NetBSD Guide, then honestly I cannot remember such step being there at all. Unfortunately I forgot to take an Ethernet cable with me to where I am now, so unless I find somebody with one, I won't be able to perform a new installation for the next 8 days.

              • rvp replied to this.

                JaWie_66 If you mean something like figure 3.17 in The NetBSD Guide, then honestly I cannot remember such step being there at all.

                On a system with UEFI and GPT paritions, sysinst won't present that screen because in that setup bootblocks aren't needed. Only BIOS + MBR must have bootblocks installed. I don't know what happens if you have boot UEFI and have MBR on a disk (I'll have to read the sysinst source to figure this out...)

                Can you post the typescript file after running this command:

                script -c 'fdisk wd0; disklabel -r wd0'

                Edit: If sysctl machdep.bootmethod says UEFI, then most likely you wouldn't have been asked to install bootblocks.

                  rvp Can you post the typescript file after running this command:

                  script -c 'fdisk wd0; disklabel -r wd0'

                  The following got returned:

                  Script started on Thu May 19 20:28:29 2022
                  Disk: /dev/rwd0
                  NetBSD disklabel disk geometry:
                  clinders: 969021, heads: 16, sectors/track: 63 (1008 sectors/cylinder)
                  total sectors: 976773168, bytes/sector: 512
                  
                  BIOS disk geometry:
                  cylinders: 1024, heads: 255, sectors/track: 63 (16065 sectors/cylinder)
                  total sectors: 976773168
                  
                  Partitions aligned to 16065 sector boundaries, offset 63
                  
                  Partition table:
                  0: Primary DOS with 32 bit FAT (sysid 11)
                      bootmenu: FreeDOS
                      start 63, size 4208967 (2055 MB, Cyls 0-261)
                  1: NTFS, OS/2 HPFS, QNX2 or Advanced UNIX (sysid 7)
                      bootmenu: Windoze
                      start 4209030, size 417690 (204 MB, Cyls 262-287)
                  2: NetBSD (sysid 169)
                      bootmenu: NetBSD
                      start 4626720, size 299098170 (146044 MB, Cyls 288-18905), Active
                          PBR is not bootable: All bytes are identical (0xf6)
                  3: Ext. partition - LBA (sysid 15)
                      start 303724890, size 673043175 (328634 MB, Cyls 18906-60800)
                  E0: NTFS, OS/2 HPFS, QNX2 or Advanced UNIX (sysid 7)
                      start 303724953, size 33559722 (16387 MB, Cyls 18906-20994)
                  E1: NTFS, OS/2 HPFS, QNX2 or Advanced UNIX (sysid 7)
                      start 337284738, size 236798037 (115624 MB, Cyls 20995-35734)
                  E2: NTFS, OS/2 HPFS, QNX2 or Advanced UNIX (sysid 7)
                      start 574082838, size 201342582 (98312 MB, Cyls 35735-48267)
                  E3: Primary DOS with 32 bit FAT - LBA (sysid 12)
                      start 775425483, size 201342582 (98312 MB, Cyls 48268-60800)
                  Bootselector disabled.
                  First active parition: 2
                  Drive serial number: 520024 (0x0007ef58)
                  # /dev/rwd0:
                  type: unknown
                  disk: wd
                  label: Laptop
                  flags:
                  bytes/sector: 512
                  sectors/track: 63
                  tracks/cylinder: 16
                  sectors/cylinder: 1008
                  cylinders: 969021
                  total sectors: 976773168
                  rpm: 3600
                  interleave: 1
                  trackskew: 0
                  cylinderskew: 0
                  headswitch: 0           # microseconds
                  track-to-track seek: 0  # microseconds
                  drivedata: 0
                  
                  13 partitions:
                  #        size    offset     fstype [fsize bsize cpg/sgs]
                   a:   6150144   4890624     4.2BSD      0     0     0  # (Cyl.   4851*-  10953*)
                   b:  33556480  11040768       swap                     # (Cyl.  10953*-  44243*)
                   c: 299098170   4626720     unused      0     0        # (Cyl.   4590 - 301314*)
                   d: 976773168         0     unused      0     0        # (Cyl.      0 - 969020)
                   e:    262144   4628480      MSDOS                     # (Cyl.   4591*-   4851*)
                   f:  15988736  44597248     4.2BSD      0     0     0  # (Cyl.  44243*-  60105*)
                   g:  11792384  60585984     4.2BSD      0     0     0  # (Cyl.  60105*-  71803*)
                   h:   4196352  72378368     4.2BSD      0     0     0  # (Cyl.  71803*-  75966*)
                   i:   2459648  76574720     4.2BSD      0     0     0  # (Cyl.  75966*-  78407*)
                   j:   4919296  79034368     4.2BSD      0     0     0  # (Cyl.  78407*-  83287*)
                   k: 201324544  83953664     4.2BSD      0     0     0  # (Cyl.  83287*- 283014*)
                   l:  18446336 285278208     4.2BSD      0     0     0  # (Cyl. 283014*- 301314*)
                  
                  Script done on Thu May 19 20:28:29 2022

                  The line PBR is not bootable: All bytes are identical (0xf6) in particular is pretty telling, although searching for it has so far returned results not multiboot-related, thus i'm unsure whether the found solutions would apply to my case.

                  rvp Edit: If sysctl machdep.bootmethod says UEFI, then most likely you wouldn't have been asked to install bootblocks.

                  And indeed you are right, it said machdep.bootmethod = UEFI. This a little puzzling to me, since I was sure the HDD has been partitioned using MBR, not GPT, at the time I ran the installer. At no point of the NetBSD installation have I been asked to choose between MBR and GPT, so I assumed that the installer auto-detects the present scheme. Or am I simply wrong and the HDD is actually GPT-partitioned?

                  • rvp replied to this.

                    JaWie_66 Or am I simply wrong and the HDD is actually GPT-partitioned?

                    No, the fdisk output shows that the disk is using MBR. You would've had far less trouble had you used GPT (not sure if FreeDOS supports it). But never mind. Do this to install bootblocks onto the NetBSD PBR. You may have to run this command from a USB stick--try it from the main system first, though

                    mount /dev/wd0a /mnt		# mount NetBSD / (USB-stick only)
                    cp /usr/mdec/boot /mnt		# copy secondary bootloader to /
                    umount /mnt

                    Now, we install the primary bootloader.

                    # Create a wedge which covers the entire NetBSD partition
                    # the actual wedge created (here, `dk15') will be different for you.
                    dkctl sd0 addwedge nbsd 4626720 299098170 ffs
                    dk15 created successfully.
                    
                    # Install primary bootstrap onto wedge (ie. onto the PBR)
                    # use the correct wedge device
                    installboot -v /dev/rdk15 /usr/mdec/bootxx_ffsv2 /boot
                    File system:         /dev/rdk15
                    File system type:    ffs (blocksize 16384, needswap 0)
                    Primary bootstrap:   /usr/mdec/bootxx_ffsv2
                    Secondary bootstrap: /boot
                    Boot options:        timeout 5, flags 0, speed 9600, ioaddr 0, console pc
                    
                    # Delete wedge
                    dkctl wd0 delwedge dk15

                      rvp The method you described worked, NetBSD is finally capable of booting on its own, the other OS-s continue to work as well. Thank you very much for all the help and patience! When I return home, I'm going to try few things and maybe will redo the process, so I will report on Friday. Meanwhile, best wishes!

                        5 days later

                        JaWie_66 When I return home, I'm going to try few things and maybe will redo the process

                        If you do,
                        a) try a GPT partitioning scheme instead of MBR,
                        b) if you do choose MBR + disklabel for NetBSD, make sure that you use the BIOS intall image, and
                        c) the first a partition (usually holding /) starts at the same location as the c (whole NetBSD) partition like this:

                        root@x202e:~ # disklabel da0s3
                        # /dev/da0s3:
                        8 partitions:
                        #          size     offset    fstype   [fsize bsize bps/cpg]
                          a:    4096000     890432    4.2BSD        0     0     0
                          b:    2048000    4986432      swap                    
                          c:   14439872     890432    unused        0     0     # "raw" part, don't edit
                          d:   15330304          0    unused        0     0   
                          e:    4096000    7034432    4.2BSD        0     0     0
                          g:    4096000   11130496    4.2BSD        0     0     0
                          h:      66522         63     MSDOS                    

                        You can see that the a and c partition have the same offset; and while a MSDOS "spoofed" partition h is included in the disklabel, it is actually "outside" the NetBSD c partn. space.

                          rvp Apologies again for a delayed response, I had to get through some unexpected stuff first. Besides that I decided to give NetBSD some more HDD space, which required altering the disk layout and reinstalling Windows 7 as well as NetBSD. This time I must've overlooked something during the process, because, as it came out during testing the boot menu, Windoze screwed FreeDOS by for whatever reason using its FAT32 slice as "System Reserved". After fixing FreeDOS Windoze wouldn't boot and the installer's boot repair tools were of no use, so I installed it again from scratch. Then I reinitialized NetBSD's boot selector and so far everything has been fine.

                          rvp b) if you do choose MBR + disklabel for NetBSD, make sure that you use the BIOS intall image, and
                          c) the first a partition (usually holding /) starts at the same location as the c (whole NetBSD) partition

                          I eventually went with MBR - while there seems to be a way to boot FreeDOS from a GPT-partitioned disk, it looks rather complicated, so I gave myself a miss. Your advices are very helpful, as I might have misunderstood the INSTALL document, when it came to the images available for download - the wording seemed to suggest that NetBSD-9.99.97-amd64-install.img is a general-purpose image for both MBR and GPT setups, meanwhile NetBSD-9.99.97-amd64-bios-install.img is a solution for older AMD64 hardware. In case of my laptop, the later worked flawlessly, without all the hassle required previously and no DOS partitions in the slice. In the end, disklabel reports the following layout:

                          12 partitions:
                          #        size    offset     fstype [fsize bsize cpg/sgs]
                           a:  12298271   4642785     4.2BSD      0     0     0  # (Cyl.   4605*-  16806*)
                           b:  33556480  16941056       swap                     # (Cyl.  16806*-  50096*)
                           c: 366265935   4642785     unused      0     0        # (Cyl.   4605*- 367964)
                           d: 976773168         0     unused      0     0        # (Cyl.      0 - 969020)
                           e:  31977472  50497536     4.2BSD      0     0     0  # (Cyl.  50096*-  81820*)
                           f:  25681920  82475008     4.2BSD      0     0     0  # (Cyl.  81820*- 107298*)
                           g:   6293504 108156928     4.2BSD      0     0     0  # (Cyl. 107298*- 113542*)
                           h:  36896768 114450432     4.2BSD      0     0     0  # (Cyl. 113542*- 150146*)
                           i:   8390656 151347200     4.2BSD      0     0     0  # (Cyl. 150146*- 158470*)
                           j:   9840640 159737856     4.2BSD      0     0     0  # (Cyl. 158470*- 168232*)
                           k: 201328640 169578496     4.2BSD      0     0     0  # (Cyl. 168232*- 367963*)

                          I adjusted the sizes according to what you wrote earlier, as well as in regards to what I read in the "NetBSD - A little guide for newcomers" thread. After few months of actual usage, I will probably be able to tell how much space will be optimal for each partition.

                          In the end, the system fully works without any issues so far. I've already done initial configuration, as well as first successfull software installations from source. Thus when it comes to me, this thread has served its purpose, providing a satisfying solution to my problem. Thank you again @rvp for all your help and patience, you brought NetBSD a new user!

                          • Jay likes this.