DaemonForums  

Go Back   DaemonForums > OpenBSD > OpenBSD General

OpenBSD General Other questions regarding OpenBSD which do not fit in any of the categories below.

Reply
 
Thread Tools Display Modes
  #1   (View Single Post)  
Old 26th January 2021
niks007 niks007 is offline
Port Guard
 
Join Date: Oct 2020
Location: Germany and India
Posts: 21
Lightbulb create and mount partition on image file

Hi,

I am trying to create raw image for my cloud environment , I can create image with single / partition but I want to create almost 6 GB image with /, /usr and /home partition ..
Since , I want to have default layout so I used (disklabel -A) to create automatic layout and it shows / , /usr and /home by default. (Step 4)
Now I can mount whole disk (Step 6) but how can I access/mount other partitions (/usr/, /home) in order to install some packages in /usr and set mount parameters (wxallow) in image.
my ultimate goal is to create image with multiple partition layout (/, /usr,/home , /tmp etc). and /usr has wxallowe mount flag in image.



Steps :

1) #dd if=/dev/null of=/tmp/img.raw bs=1M seek=6*1024
2) # vnconfig vnd0 /tmp/img.raw
3) #fdisk -iy /dev/rvnd0c
Writing MBR at offset 0.
4) # disklabel -A vnd0c
# /dev/rvnd0c:
type: vnd
disk: vnd device
label: fictitious
duid: 0000000000000000
flags:
bytes/sector: 512
sectors/track: 100
tracks/cylinder: 1
sectors/cylinder: 100
cylinders: 125829
total sectors: 12582912
boundstart: 128
boundend: 12582900
drivedata: 0

16 partitions:
# size offset fstype [fsize bsize cpg]
a: 2018080 128 4.2BSD 2048 16384 1 # /
b: 524288 2018208 swap
c: 12582912 0 unused
d: 6291456 2542496 4.2BSD 2048 16384 1 # /usr
e: 3748928 8833952 4.2BSD 2048 16384 1 # /home

#

5) # newfs vnd0c
/dev/rvnd0c: 6144.0MB in 12582912 sectors of 512 bytes
31 cylinder groups of 202.50MB, 12960 blocks, 25920 inodes each
super-block backups (for fsck -b #) at:
160, 414880, 829600, 1244320, 1659040, 2073760, 2488480, 2903200, 3317920, 3732640, 4147360, 4562080, 4976800, 5391520, 5806240, 6220960, 6635680, 7050400,
7465120, 7879840, 8294560, 8709280, 9124000, 9538720, 9953440, 10368160, 10782880, 11197600, 11612320, 12027040, 12441760,

6) # mount -o async,noatime /dev/vnd0c /tmp/k

7) # mount | grep /tmp
/dev/vnd0c on /tmp/k type ffs (asynchronous, local, noatime)

Thank you in advance for reading the thread.


PS : I posted similar question in past but this question is little bit different from previous question so posting new thread.


Thanks,
NK
Reply With Quote
  #2   (View Single Post)  
Old 26th January 2021
IdOp's Avatar
IdOp IdOp is offline
Too dumb for a smartphone
 
Join Date: May 2008
Location: twisting on the daemon's fork(2)
Posts: 956
Default

Quote:
5) # newfs vnd0c
In OpenBSD the 'c' partition refers to the "whole disk" or in this case the whole image file. So this step puts a single filesystem on the whole file, 6 BG worth. I think what you want to do instead is run a newfs on each of the /, /usr and /home partitions, that is suffixes 'a', 'd' and 'e' instead of 'c'. Then there will be smaller filesystems starting in the places where fdisk says they should, and you should be able to mount them.
Reply With Quote
  #3   (View Single Post)  
Old 27th January 2021
niks007 niks007 is offline
Port Guard
 
Join Date: Oct 2020
Location: Germany and India
Posts: 21
Default

Thanks for your response.

I tried to create FS but unable to create it on / , /usr/ and /home. (a , d, and e)

# newfs /dev/rvnd0a
newfs: /dev/rvnd0a: Device not configured
# newfs /dev/rvnd0d
newfs: /dev/rvnd0d: Device not configured
# newfs /dev/rvnd0e
newfs: /dev/rvnd0e: Device not configured
#

# vnconfig -l
vnd0: covering /tmp/img.raw on sd0a, inode 105372
vnd1: not in use
vnd2: not in use
vnd3: not in use
#

Last edited by niks007; 27th January 2021 at 12:31 PM. Reason: tested with rvnd0 device
Reply With Quote
  #4   (View Single Post)  
Old 27th January 2021
jggimi's Avatar
jggimi jggimi is online now
More noise than signal
 
Join Date: May 2008
Location: USA
Posts: 7,209
Default

My guess is your formatting of vnd0c has destroyed your disklabel. First, check to see if you still have an MBR and MBR partition in place with # fdisk vnd0. Then, check your disklabel with # disklabel vnd0. Each disk may have 15 partitions for data: a,b, and d-p. Partition c is special: it is the whole drive.
Reply With Quote
  #5   (View Single Post)  
Old 27th January 2021
IdOp's Avatar
IdOp IdOp is offline
Too dumb for a smartphone
 
Join Date: May 2008
Location: twisting on the daemon's fork(2)
Posts: 956
Default

My first thought was along the line of jggimi's. But I then tried to do it without the newfs on 'c' which was the suspected culprit. Yet it didnt' work.

I've been playing with it some more and after some tinkering the following seems to work:

Use the -w flag with disklabel

# disklabel -Aw vnd0c

Then a subsequent run of disklabel will show all the partitions, not just 'c'. And more importantly, newfs on the 'a' partition then works too! Hopefully it will work for niks007 .

Last edited by IdOp; 27th January 2021 at 09:49 PM.
Reply With Quote
  #6   (View Single Post)  
Old 27th January 2021
IdOp's Avatar
IdOp IdOp is offline
Too dumb for a smartphone
 
Join Date: May 2008
Location: twisting on the daemon's fork(2)
Posts: 956
Default

One additional note relevant to the topic. At the bottom of the vnconfig(8) man page, there's a CAVEAT which says "The 'c' partition of a vnd image should not be used". This is a bit unclear. For the disklabel step, the 'c' partition must be used. It's for the newfs formatting step where it should not be used. This is good to have in mind when reading the rest of the caveat.

EDIT: It seems the Caveat is gone from recent man pages. I was reading it in the version 6.1 vnconfig(8) man page.

Last edited by IdOp; 28th January 2021 at 07:16 PM.
Reply With Quote
  #7   (View Single Post)  
Old 28th January 2021
niks007 niks007 is offline
Port Guard
 
Join Date: Oct 2020
Location: Germany and India
Posts: 21
Default

Thanks IdOP,

-Aw options works well and I am able to mount separately.

/dev/vnd0a 1952796 4 1855156 0% /tmp/a
/dev/vnd0d 6082908 4 5778760 0% /tmp/d
/dev/vnd0e 3618524 4 3437596 0% /tmp/e
Reply With Quote
  #8   (View Single Post)  
Old 28th January 2021
niks007 niks007 is offline
Port Guard
 
Join Date: Oct 2020
Location: Germany and India
Posts: 21
Default

Quote:
Originally Posted by IdOp View Post
One additional note relevant to the topic. At the bottom of the vnconfig(9) man page, there's a CAVEAT which says "The 'c' partition of a vnd image should not be used". This is a bit unclear. For the disklabel step, the 'c' partition must be used. It's for the newfs formatting step where it should not be used. This is good to have in mind when reading the rest of the caveat.

EDIT: It seems the Caveat is gone from recent man pages. I was reading it in the version 6.1 vnconfig(8) man page.
I also surprised after reading man page because mostly 'c' partition used with vnconfig in latest version..
Reply With Quote
  #9   (View Single Post)  
Old 28th January 2021
IdOp's Avatar
IdOp IdOp is offline
Too dumb for a smartphone
 
Join Date: May 2008
Location: twisting on the daemon's fork(2)
Posts: 956
Default

Quote:
Originally Posted by niks007 View Post
-Aw options works well and I am able to mount separately.
Glad to hear that.
Reply With Quote
Old 28th January 2021
jggimi's Avatar
jggimi jggimi is online now
More noise than signal
 
Join Date: May 2008
Location: USA
Posts: 7,209
Default

For clarity:
  • MBR or GPT blocks and tables are only required on a disk drive if the drive will be booted on an an architecture that boots using either MBR (e.g.: BIOS) or GPT (e.g.: UEFI).
  • If using MBR/GPT, an OpenBSD MBR partition or OpenBSD GPT partition is used to reserve the entire contiguous storage that will be used by OpenBSD. Separately, OpenBSD's internal partitions are recorded in the OpenBSD disklabel.
  • The OpenBSD disklabel -- with or without MBR/GPT -- defines the partitions to be used by OpenBSD. There are 15 definable partitions: a, b, and d-p.
  • OpenBSD partition c is always the entire physical disk, from the first sector at LBA 0 all the way to the final addressable sector on the drive. This is regardless of the contents of MBR, GPT, or disklabel.
  • Some utilities that act on the entire drive, such as fdisk(8) and disklabel(8), allow the admin to use a short-form disk description, such as "sd0." These utilities consider "sd0", "sd0c", and "/dev/rsd0c" to be equivalent options to the command.
And, regarding scanning the MBR/GPT partition table:
  • When a disk is first examined by the kernel -- during boot, or at USB attachment -- the kernel looks for an OpenBSD disklabel on the drive. If it finds one, it uses it, and ignores the contents of MBR or GPT partition tables.
  • If the kernel does not find an OpenBSD disklabel on the drive, it will scan the MBR/GPT partition table looking for any recognized "foreign" filesystems that it knows about, such as FAT and NTFS partitions. It will assign those to "virtual" disklabel partitions starting with partition i.
  • When writing a virtual partition table to disk, any foreign filesystems added above will be recorded in the disklabel.
  • If any of the "foreign" MBR/GPT partitions are later changed in size or location, the OpenBSD disklabel will be out-of-sync and should be manually edited to match, if the filesystems are to be mounted successfully.
Reply With Quote
Reply

Tags
cloud, disklabel, images openstack, partitioning

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
Install image to which USB partition? sacerdos_daemonis OpenBSD Installation and Upgrading 3 27th October 2019 11:11 PM
Create a partition for OpenBSD in a multi-boot OS environment cravuhaw2C OpenBSD Installation and Upgrading 9 14th July 2014 09:16 AM
cant mount 16th partition because of disklabel limitation thereisopenbsd OpenBSD General 2 3rd June 2011 09:10 AM
create a FAT32 partition and format it. wesley OpenBSD General 2 6th November 2010 08:31 AM
Tried to create new partition using sysinstall but change is not permanent disappearedng FreeBSD General 7 6th July 2008 10:00 PM


All times are GMT. The time now is 01:28 AM.


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