Table of Contents
fdisk
Linux and NetBSD Partitioning
Partitioning drives in NetBSD is different than Linux. In Linux, there is one MBR table with partitions for as many filesystems as you would like.
In NetBSD, one partition is created from the original four that are found with an MBR table, then disklabel is used to create it's own form of partitions called slices within the MBR partition.
In other words, running fdisk
in Linux on a hard drive with NetBSD installed, would show only one partition created.
netbsd-vm Example
Linux
The drives here are IDE drives, so they show up as wdX
instead of sdX
in NetBSD.
Here's what fdisk -l /dev/sda
would return in Linux, for the MBR partitions:
Disk /dev/sda: 12.9 GB, 12884901888 bytes, 25165824 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00000000 Device Boot Start End Blocks Id System /dev/sda1 * 2048 25165823 12581888 a9 NetBSD
NetBSD
fdisk wd0
will also show the MBR partitions:
Disk: /dev/rwd0d NetBSD disklabel disk geometry: cylinders: 24966, heads: 16, sectors/track: 63 (1008 sectors/cylinder) total sectors: 25165824 BIOS disk geometry: cylinders: 1024, heads: 255, sectors/track: 63 (16065 sectors/cylinder) total sectors: 25165824 Partitions aligned to 2048 sector boundaries, offset 2048 Partition table: 0: NetBSD (sysid 169) start 2048, size 25163776 (12287 MB, Cyls 0-1566/127/33), Active 1: <UNUSED> 2: <UNUSED> 3: <UNUSED> Bootselector disabled. First active partition: 0
Format a NetBSD Hard Drive
There are a lot of different device names for the same thing, so to keep things simple, just use sd0
, sd1
, etc. for the MBR partitions.
Display status of a disk:
fdisk sd0
Initialization
Use fdisk
to create an MBR partition table (same as on Linux).
Do this before disklabel or newfs:
fdisk -u sd0
fdisk: primary partition table invalid, no magic in sector 0 Disk: /dev/sd1 NetBSD disklabel disk geometry: cylinders: 224, heads: 255, sectors/track: 63 (16065 sectors/cylinder) total sectors: 3604865 BIOS disk geometry: cylinders: 1023, heads: 255, sectors/track: 63 (16065 sectors/cylinder) total sectors: 1952448512 Partitions aligned to 16065 sector boundaries, offset 63 Do you want to change our idea of what BIOS thinks? [n] n Partition table: 0: <UNUSED> 1: <UNUSED> 2: <UNUSED> 3: <UNUSED> Bootselector disabled. No active partition. Which partition do you want to change?: [none] 0 The data for partition 0 is: <UNUSED> sysid: [0..255 default: 169] start: [0..224cyl default: 63, 0cyl, 0MB] size: [0..224cyl default: 3604802, 224cyl, 1760MB] bootmenu: [] Partition table: 0: NetBSD (sysid 169) start 63, size 3604802 (1760 MB, Cyls 0-224/100/5) PBR is not bootable: All bytes are identical (0x00) 1: <UNUSED> 2: <UNUSED> 3: <UNUSED> Bootselector disabled. No active partition. Which partition do you want to change?: [none] We haven't written the MBR back to disk yet. This is your last chance. Partition table: 0: NetBSD (sysid 169) start 63, size 3604802 (1760 MB, Cyls 0-224/100/5) PBR is not bootable: All bytes are identical (0x00) 1: <UNUSED> 2: <UNUSED> 3: <UNUSED> Bootselector disabled. No active partition. Should we write new partition table? [n] y
Partition hard drive
Edit the NetBSD partitions (slices):
disklabel -i -I sd1
Enter '?' for help partition> d Filesystem type [?] [4.2BSD]: 4.2BSD Start offset ('x' to start after partition 'x') [0c, 0s, 0M]: Partition size ('$' for all remaining) [953344c, 1952448512s, 953344M]: $ partition> W Label disk [n]? y Label written partition> Q