dd question

Polytropon freebsd at edvax.de
Sun Sep 27 14:43:40 UTC 2015

On Sun, 27 Sep 2015 09:22:48 -0453.75, William A. Mahaffey III wrote:
> On 09/27/15 09:12, Polytropon wrote:
> > On Sun, 27 Sep 2015 09:05:52 -0453.75, William A. Mahaffey III wrote:
> >> On 09/27/15 09:00, Polytropon wrote:
> >>> Maybe the installation media, even though on writable media, is
> >>> mounted ro? The easiest thing to capture logs is to perform the
> >>> installation from a "fully writable" live file system, or simply
> >>> mount a network resource r/w.
> >>
> >> How can I figure that out (mounted ro) ? I have ISO's & img's available
> >> on my LAN, can I install from them directly ? If so, how :-) (URL's
> >> welcome) ?
> > Depends on how the boot process is being performed. A look
> > in /etc/fstab or maybe (customized?) rc.diskless could tell
> > you more. Basically, it's simple to boot the media, get to
> > a command line, and look at the "mount -v" output.
> >
> > Another option woule be to use disklabel and and add a new
> > partition, for example letter 'd', which ends at the end
> > of the media (where 'c' usually ends). Note that no partition
> > can be bigger than 'c' ("the whole thing").
> If I use disklabel to add a 'd' slice, will that mess up what is already 
> there ?

It shouldn't. It will add a new partition entry (da0d, for
example) that can be initialized with newfs, so you can then
mount it r/w with UFS.

> What is the syntax for that, I don't see it in the 
> disklabel/bsdlabel man page ?

Take the disklabel editor screen as an example. Make sure
'c' is as big as the whole device, then take the end of
the last partition, 'a', as an offset, and add the desired
size for 'd'.

It will then look comparable to this:

% disklabel ad4s1
# /dev/ad4s1:
8 partitions:
#          size     offset    fstype   [fsize bsize bps/cpg]
  a:    2097152          0    4.2BSD        0     0     0
  b:    4194304    2097152      swap                    
  c:  625142385          0    unused        0     0     # "raw" part, don't edit
  d:    2097152    6291456    4.2BSD        0     0     0
  e:    2097152    8388608    4.2BSD        0     0     0
  f:  104857600   10485760    4.2BSD        0     0     0
  g:   10485760  115343360    4.2BSD        0     0     0
  h:  499313265  125829120    4.2BSD        0     0     0

The size of 'c' is the size of the slice (in this case), and
you can see that "offset" accumulates from the "size" column
of the previous entries.

It's okay to have only 'a', 'c' and 'd' entries, as long as
the math magic adds up properly. :-)

> The man page for disklabel/bsdlabel shows 
> a way to initialize a whole disk using 'fdisk -BI <dev>' & implies that 
> this will create a 'da0s1' slice in the process. However it will also 
> wipe out what is already there.

Invoke the disklabel editor:

	# bsdlabel -e <device>

and make the changes in $EDITOR (yes, it actually uses the
editor program $EDITOR points to). See mdconfig idea following.
I'm not sure if bsdlabel can operate on image files directly.

> If I do that, can I then copy the 
> img-file contents in some way ?

It's probably possible to use mdconfig to turn the image file
into a device file and then modify that device file (add
partitions), resulting in a change of the image file.

	# mdconfig -a -t vnode -u 0 -f image.dd
		(now /dev/md0, /dev/md0a, /dev/md0c should appear)
	# bsdlabel -e /dev/md0
		(make changes, save & exit)
		(and /dev/md0d should appear)
	# mdconfig -d -u 0

Actually, I've never tried that, so it's more of a thought
experiment than an educated and tested advice. :-)

Magdeburg, Germany
Happy FreeBSD user since 4.0
Andra moi ennepe, Mousa, ...

More information about the freebsd-questions mailing list