NetBSD-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: disks, partitions, slices, etc.



On Sat, Oct 03, 2026 at 04:42:46AM +0200, Jeff wrote:
> Based on advice I got elsewhere, I would like to put an ext2
> filesystem on an existing partition that I can share between NetBSD and
> Gentoo on a dual boot system. The advice was to create the filesystem
> from in NetBSD.

I understand the MBR vs. disklabel vs. GPT confusion - it is a disaster
for historical raisins.

The GPT start is most straigth forward and portable to other OSes:

If you have a disk with GPT it will autoconfigure wedges. So if your
device is, say, sd0 you can list all wedges with:

	dkctl sd0 listwedges

If your partitions have usefull GPT labels, this should be enough to
identify them. Example form one machine here:

# dkctl wd0 listwedges
/dev/rwd0: 2 wedges:
dk0: G5root, 943718400 blocks at 64, type: ffs
dk1: G5swap, 56496704 blocks at 943718464, type: swap

my root file system is labeled "G5root", so I can acces it as dk0.

Without label you need to rely on "type", which might not be unique.
Worst case you get a UUID, and then you may compare it to

	gpt show -a sd0

output (again assuming your disk is sd0).

Once you know the N for your target dkN device, you can create an ext2fs
file system on it using newfs_ext2fs(8) like:

	newfs_ext2fs -v "myVolume" /dev/rdk0

(if your dkN from the search above is dk0)

The MBR case is more complicated because you have a disklabel in between
that other systems do not understand, so you will jump through additioonal
hoops.

Martin


Home | Main Index | Thread Index | Old Index