DaemonForums  

Go Back   DaemonForums > Miscellaneous > Guides

Guides All Guides and HOWTO's.

Reply
 
Thread Tools Display Modes
  #1   (View Single Post)  
Old 17th February 2010
J65nko J65nko is offline
Administrator
 
Join Date: May 2008
Location: Budel - the Netherlands
Posts: 4,125
Default Preserving existing OpenBSD partition layout during a re-install

1. Preserving an existing OpenBSD partition layout during a re-install
  • 1.1 Description of the problem
  • 1.2 Partitioning at MBR level with 'fdisk' step
  • 1.3 Overriding the suggested partition lay-out
  • 1.4 Summary


1.1 Description of the problem

The OpenBSD 4.6 installation program introduced some nice features, like suggesting a disklabel partition lay-out. But if you have quite some experience in installing previous OpenBSD releases, and intend to keep your own custom lay-out, you may be in for a surprise.

Such an experience has been posted in July 2009 in a message to the OpenBSD mailing list, with the subject New disklable doesn"t keep old partitions if requested. A quote from the initial post

Code:
I try to keep the actual partition of the disk as it was before and do a fresh
install, but the snapshots looks like simply do not allow this now.

You can select Custom label and it will show the previous label, but then when
you write it, obviously no changes are present, but when you Quit it, it comes
back to the same question and looks like you can't move on from there.

Good if you want to use the auto label, but if you want to keep the old one,
then what really should be the step then?
The correct steps to be taken will be illustrated in the following capture of an OpenBSD install. We skip the preliminary install steps and join the fun at the 'fdisk' part.


1.2 Partitioning at MBR level with 'fdisk' step

Code:
Available disks are: wd0.
Which one is the root disk? (or 'done') [wd0] Enter
Disk: wd0       geometry: 19457/255/63 [312581808 Sectors]
Offset: 0       Signature: 0xAA55
            Starting         Ending         LBA Info:
 #: id      C   H   S -      C   H   S [       start:        size ]
-------------------------------------------------------------------------------
*0: A6      0   1   1 -   4864 254  63 [          63:    78156162 ] OpenBSD
 1: A5   4865   0   1 -   9728 254  63 [    78156225:    78140160 ] FreeBSD
 2: A5   9729   0   1 -  12161 254  63 [   156296385:    39086145 ] FreeBSD
 3: 00      0   0   0 -      0   0   0 [           0:           0 ] unused

Use (W)hole disk, use the (O)penBSD area, or (E)dit the MBR? [OpenBSD] Enter
Because we want the preserve the current MBR layout we just press Enter.
__________________
You don't need to be a genius to debug a pf.conf firewall ruleset, you just need the guts to run tcpdump
Reply With Quote
  #2   (View Single Post)  
Old 17th February 2010
J65nko J65nko is offline
Administrator
 
Join Date: May 2008
Location: Budel - the Netherlands
Posts: 4,125
Default 1.3 Overriding the suggested partition lay-out

1.3 Overriding the suggested partition lay-out

Code:
The auto-allocated layout for wd0 is:
#                size           offset  fstype [fsize bsize  cpg]
  a:          1024.0M               63  4.2BSD   2048 16384    1 # /
  b:           767.5M          2097215    swap
  c:        152627.8M                0  unused
  d:          2621.6M          3669111  4.2BSD   2048 16384    1 # /tmp
  e:          4145.1M          9038175  4.2BSD   2048 16384    1 # /var
  f:          2048.0M         17527384  4.2BSD   2048 16384    1 # /usr
  g:          1024.0M         21721688  4.2BSD   2048 16384    1 # /usr/X11R6
  h:          3611.5M         23818840  4.2BSD   2048 16384    1 # /usr/local
  i:         38154.4M         78156225 unknown
  j:         19085.0M        156296385 unknown
  k:          1962.1M         31215209  4.2BSD   2048 16384    1 # /usr/src
  l:          1962.1M         35233600  4.2BSD   2048 16384    1 # /usr/obj
  m:         18996.2M         39251991  4.2BSD   2048 16384    1 # /home

Use (A)uto layout, (E)dit auto layout, or create (C)ustom layout? [a] c Enter
Not wishing to use the proposed auto layout, we press 'c' for a '(C)custom layout'.

Code:
You will now create an OpenBSD disklabel inside the OpenBSD MBR
partition. The disklabel defines how OpenBSD splits up the MBR partition
into OpenBSD partitions in which filesystems and swap space are created.
You must provide each filesystem's mountpoint in this program.
While previously the installer asked for the mount points after the disklabel step, now it is required to to specify these during the partitioning with 'disklabel'.

Code:
The offsets used in the disklabel are ABSOLUTE, i.e. relative to the
start of the disk, NOT the start of the OpenBSD MBR partition.

Label editor (enter '?' for help at any prompt)
> help Enter

Available commands:
  ? [cmd]  - show help                  n [part] - set mount point
  A        - auto partition all space   p [unit] - print partitions
  a [part] - add partition              q        - quit & save changes
  b        - set OpenBSD boundaries     s [path] - save label to file
  c [part] - change partition size      r        - display free space
  D        - reset label to default     U        - undo all changes
  d [part] - delete partition           u        - undo last change
  e        - edit drive parameters      w        - write label to disk
  g [d|u]  - [d]isk or [u]ser geometry  X        - toggle expert mode
  l [unit] - print disk label header    x        - exit & lose changes
  M        - disklabel(8) man page      z        - delete all partitions
  m [part] - modify partition

Suffixes can be used to indicate units other than sectors:
        'b' (bytes), 'k' (kilobytes), 'm' (megabytes), 'g' (gigabytes)
        'c' (cylinders), '%' (% of total disk), '&' (% of free space).
Values in non-sector units are truncated to the nearest cylinder boundary.
The shortest command to set the mount point is 'n'. If besides the mount point, you want to modify the file system type as well, the 'm' is the way to go.

If you happen to have a very simple layout with for example only one single 'a' partition for '/' and a swap partition, it is easy to set the mount point. In case of a complex one, having the output of the 'mount' available is a life saver. In my case I had mailed the information to my Gmail account.

Code:
to	x.y.z@gmail.com
date	Sun, Jan 17, 2010 at 11:25 PM
subject	vintrax disk layout

Filesystem     Size    Used   Avail Capacity  Mounted on
/dev/wd0a     61.4M   32.0M   26.3M    55%    /
/dev/wd0m      6.5G    2.8G    3.4G    44%    /backup
/dev/wd0e     19.7G    2.8G   15.9G    15%    /home/j65nko
/dev/wd0d      502M    2.0K    477M     0%    /tmp
/dev/wd0k      3.9G    418M    3.3G    11%    /usr
/dev/wd0l      3.9G    210K    3.7G     0%    /usr/local
/dev/wd0f     1005M    3.0M    952M     0%    /var
/dev/wd0h      502M    122K    477M     0%    /var/log
/dev/wd0g      502M    4.0K    477M     0%    /var/tmp
Because the output of mount is sorted by mount point, I pasted the mount info in a 'tmp' file and sorted on the first field, the device label.

Code:
$ sort < tmp
/dev/wd0a     61.4M   32.0M   26.3M    55%    /
/dev/wd0d      502M    2.0K    477M     0%    /tmp
/dev/wd0e     19.7G    2.8G   15.9G    15%    /home/j65nko
/dev/wd0f     1005M    3.0M    952M     0%    /var
/dev/wd0g      502M    4.0K    477M     0%    /var/tmp
/dev/wd0h      502M    122K    477M     0%    /var/log
/dev/wd0k      3.9G    418M    3.3G    11%    /usr
/dev/wd0l      3.9G    210K    3.7G     0%    /usr/local
/dev/wd0m      6.5G    2.8G    3.4G    44%    /backup
Having the necessary info we can proceed with setting the mount points with the 'n' command. But first we print the partitions with the p command.

Code:
> p
OpenBSD area: 63-78156225; size: 78156162; free: 0
#                size           offset  fstype [fsize bsize  cpg]
  a:           128000           128063  4.2BSD   2048 16384    1
  b:           128000               63    swap
  c:        312581808                0  unused
  d:          1049297           256063  4.2BSD   2048 16384    1
  e:         41943888          1305360  4.2BSD   2048 16384    1
  f:          2097648         43249248  4.2BSD   2048 16384    1
  g:          1049328         45346896  4.2BSD   2048 16384    1
  h:          1049328         46396224  4.2BSD   2048 16384    1
  k:          8389584         47445552  4.2BSD   2048 16384    1
  l:          8389584         55835136  4.2BSD   2048 16384    1
  m:         13931505         64224720  4.2BSD   2048 16384    1

> n a Enter
mount point: [none] / Enter
> n d Enter
mount point: [none] /tmp Enter
> n e  Enter
mount point: [none] /home/xxx Enter
> n f Enter
mount point: [none] /var Enter
> n g Enter
mount point: [none] /var/tmp Enter
> n h Enter
mount point: [none] /var/log  Enter
> n k Enter
mount point: [none] /usr  Enter
> n l Enter
mount point: [none] /usr/local  Enter
> n m Enter
mount point: [none] /home Enter
You can prevent a partition from being formatted. for example your home partition, if you do not specify the mount point here. But as stated in Murphy's Law, mistakes are easily made, so having a backup is always recommended. Remember that you need at least to specify the "/" mount point for the "a" partition.

After setting the mount points we check our work by printing the partitions. As usual, saving is done with the q command.

Code:
> p
OpenBSD area: 63-78156225; size: 78156162; free: 0
#                size           offset  fstype [fsize bsize  cpg]
  a:           128000           128063  4.2BSD   2048 16384    1 # /
  b:           128000               63    swap
  c:        312581808                0  unused
  d:          1049297           256063  4.2BSD   2048 16384    1 # /tmp
  e:         41943888          1305360  4.2BSD   2048 16384    1 # /home/xxx
  f:          2097648         43249248  4.2BSD   2048 16384    1 # /var
  g:          1049328         45346896  4.2BSD   2048 16384    1 # /var/tmp
  h:          1049328         46396224  4.2BSD   2048 16384    1 # /var/log
  k:          8389584         47445552  4.2BSD   2048 16384    1 # /usr
  l:          8389584         55835136  4.2BSD   2048 16384    1 # /usr/local
  m:         13931505         64224720  4.2BSD   2048 16384    1 # /home
> q Enter
No label changes.
Notice the mount points nicely printed as comment at the end of each partition. Without asking any kind of confirmation, the installer now creates the files systems for the partitions for which a mount point has been created.

Code:
/dev/rwd0a: 62.5MB in 128000 sectors of 512 bytes
4 cylinder groups of 15.62MB, 1000 blocks, 2048 inodes each
/dev/rwd0m: 6802.5MB in 13931504 sectors of 512 bytes
34 cylinder groups of 202.47MB, 12958 blocks, 25984 inodes each
/dev/rwd0e: 20480.4MB in 41943888 sectors of 512 bytes
102 cylinder groups of 202.47MB, 12958 blocks, 25984 inodes each
newfs: reduced number of fragments per cylinder group from 65576 to 65312
       to enlarge last cylinder group
/dev/rwd0d: 512.4MB in 1049296 sectors of 512 bytes
5 cylinder groups of 127.56MB, 8164 blocks, 16384 inodes each
/dev/rwd0k: 4096.5MB in 8389584 sectors of 512 bytes
21 cylinder groups of 202.47MB, 12958 blocks, 25984 inodes each
/dev/rwd0l: 4096.5MB in 8389584 sectors of 512 bytes
21 cylinder groups of 202.47MB, 12958 blocks, 25984 inodes each
/dev/rwd0f: 1024.2MB in 2097648 sectors of 512 bytes
6 cylinder groups of 202.47MB, 12958 blocks, 25984 inodes each
newfs: reduced number of fragments per cylinder group from 65576 to 65320
       to enlarge last cylinder group
/dev/rwd0h: 512.4MB in 1049328 sectors of 512 bytes
5 cylinder groups of 127.58MB, 8165 blocks, 16384 inodes each
newfs: reduced number of fragments per cylinder group from 65576 to 65320
       to enlarge last cylinder group
/dev/rwd0g: 512.4MB in 1049328 sectors of 512 bytes
5 cylinder groups of 127.58MB, 8165 blocks, 16384 inodes each
After finishing, the installer shows the labelled partitions, the mount point, the file system type and the automatically chosen mount options.

Code:
/dev/wd0a on /mnt type ffs (rw, asynchronous, local)
/dev/wd0m on /mnt/home type ffs (rw, asynchronous, local, nodev, nosuid)
/dev/wd0e on /mnt/home/xxx type ffs (rw, asynchronous, local, nodev, nosuid)
/dev/wd0d on /mnt/tmp type ffs (rw, asynchronous, local, nodev, nosuid)
/dev/wd0k on /mnt/usr type ffs (rw, asynchronous, local, nodev)
/dev/wd0l on /mnt/usr/local type ffs (rw, asynchronous, local, nodev)
/dev/wd0f on /mnt/var type ffs (rw, asynchronous, local, nodev, nosuid)
/dev/wd0h on /mnt/var/log type ffs (rw, asynchronous, local, nodev, nosuid)
/dev/wd0g on /mnt/var/tmp type ffs (rw, asynchronous, local, nodev, nosuid)
The experienced user will notice that this actually is the output of the regular 'mount' command. The next step will be locating and installing the file sets.

Code:
Let's install the sets!
But as we have seen what needs to be done, we stop here.
__________________
You don't need to be a genius to debug a pf.conf firewall ruleset, you just need the guts to run tcpdump
Reply With Quote
  #3   (View Single Post)  
Old 17th February 2010
J65nko J65nko is offline
Administrator
 
Join Date: May 2008
Location: Budel - the Netherlands
Posts: 4,125
Default 1.4 Summary

1.4 Summary

The procedure to preserve your own hand crafted disklabel lay-out in OpenBSD 4.6 :
  1. After having shown you the suggested auto-allocated lay-out, choose "c" for a custom lay-out.

    Code:
    The auto-allocated layout for wd0 is:
    
    #                size           offset  fstype [fsize bsize  cpg]
      a:          1024.0M               63  4.2BSD   2048 16384    1 # /
      b:           767.5M          2097215    swap
      c:        152627.8M                0  unused
      d:          2621.6M          3669111  4.2BSD   2048 16384    1 # /tmp
      e:          4145.1M          9038175  4.2BSD   2048 16384    1 # /var
      f:          2048.0M         17527384  4.2BSD   2048 16384    1 # /usr
      g:          1024.0M         21721688  4.2BSD   2048 16384    1 # /usr/X11R6
      h:          3611.5M         23818840  4.2BSD   2048 16384    1 # /usr/local
      i:         38154.4M         78156225 unknown
      j:         19085.0M        156296385 unknown
      k:          1962.1M         31215209  4.2BSD   2048 16384    1 # /usr/src
      l:          1962.1M         35233600  4.2BSD   2048 16384    1 # /usr/obj
      m:         18996.2M         39251991  4.2BSD   2048 16384    1 # /home
    
    Use (A)uto layout, (E)dit auto layout, or create (C)ustom layout? [a] c Enter
  2. Just for reference, use the p to print the original, preserved lay-out.

    Code:
    > p
    OpenBSD area: 63-78156225; size: 78156162; free: 0
    #                size           offset  fstype [fsize bsize  cpg]
      a:           128000           128063  4.2BSD   2048 16384    1
      b:           128000               63    swap
      c:        312581808                0  unused
      d:          1049297           256063  4.2BSD   2048 16384    1
      e:         41943888          1305360  4.2BSD   2048 16384    1
      f:          2097648         43249248  4.2BSD   2048 16384    1
      g:          1049328         45346896  4.2BSD   2048 16384    1
      h:          1049328         46396224  4.2BSD   2048 16384    1
      k:          8389584         47445552  4.2BSD   2048 16384    1
      l:          8389584         55835136  4.2BSD   2048 16384    1
      m:         13931505         64224720  4.2BSD   2048 16384    1
  3. Use the n command to specify the mount points.

    Code:
    > n a Enter
    mount point: [none] / Enter
    > n d Enter
    mount point: [none] /tmp Enter
    > n e  Enter
    mount point: [none] /home/xxx Enter
    > n f Enter
    mount point: [none] /var Enter
    > n g Enter
    mount point: [none] /var/tmp Enter
    > n h Enter
    mount point: [none] /var/log Enter
    > n k Enter
    mount point: [none] /usr Enter
    > n l Enter
    mount point: [none] /usr/local Enter
    > n m Enter
    mount point: [none] /home Enter
  4. Check the mount points with the p command. Use q to save and quit.

    Code:
    > p
    OpenBSD area: 63-78156225; size: 78156162; free: 0
    #                size           offset  fstype [fsize bsize  cpg]
      a:           128000           128063  4.2BSD   2048 16384    1 # /
      b:           128000               63    swap
      c:        312581808                0  unused
      d:          1049297           256063  4.2BSD   2048 16384    1 # /tmp
      e:         41943888          1305360  4.2BSD   2048 16384    1 # /home/xxx
      f:          2097648         43249248  4.2BSD   2048 16384    1 # /var
      g:          1049328         45346896  4.2BSD   2048 16384    1 # /var/tmp
      h:          1049328         46396224  4.2BSD   2048 16384    1 # /var/log
      k:          8389584         47445552  4.2BSD   2048 16384    1 # /usr
      l:          8389584         55835136  4.2BSD   2048 16384    1 # /usr/local
      m:         13931505         64224720  4.2BSD   2048 16384    1 # /home
    > q Enter
    No label changes.
    That's all.

$Id: PreservingDisklabelLayout.xml,v 1.4 2010/02/17 03:38:55 j65nko Exp $
$Id: vbul-html.xsl,v 1.15 2010/01/16 00:58:03 j65nko Exp $
__________________
You don't need to be a genius to debug a pf.conf firewall ruleset, you just need the guts to run tcpdump
Reply With Quote
  #4   (View Single Post)  
Old 17th February 2010
BSDfan666 BSDfan666 is offline
Real Name: N/A, this is the interweb.
Banned
 
Join Date: Apr 2008
Location: Ontario, Canada
Posts: 2,223
Default

Quote:
Originally Posted by J65nko View Post
While previously the installer asked for the mount points after the disklabel step, now it is required to to specify these during the partitioning with 'disklabel'.
Technically, specifying the mount points from within disklabel(8) has always been possible and preferred.. in versions prior to 4.6 the installer would confirm them, this was considered redundant by the developers.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Recommended Partition Layout MetalHead OpenBSD Installation and Upgrading 12 30th November 2008 10:08 AM
install FileZilla in OpenBSD 4.2 mfaridi OpenBSD Packages and Ports 3 4th November 2008 08:13 AM
install ssh openbsd darken OpenBSD Packages and Ports 22 26th September 2008 02:58 AM
disklabel don't see OpenBSD partition piotrk OpenBSD General 4 25th September 2008 06:14 PM
Keyboard Layout mfaridi FreeBSD General 6 26th June 2008 07:13 PM


All times are GMT. The time now is 04:17 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Content copyright © 2007-2010, the authors
Daemon image copyright ©1988, Marshall Kirk McKusick