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 4 Weeks Ago
gustaf gustaf is offline
Port Guard
 
Join Date: Dec 2016
Posts: 39
Default Add partition to disk ?

Hello everyone,

I'm trying to partition the unallocated space on a disk.

I have created a bootable USB stick which contains two partitions and a vast amount of unallocated space:

Code:
$ dmesg

sd1 at scsibus4 targ 1 lun 0: <Lexar, USB Flash Drive, 1100> SCSI2 0/direct removable serial.05dca81d3020YVD48SBQ
sd1: 7646MB, 512 bytes/sector, 15659008 sectors
Code:
$ fdisk sd1

Disk: sd1       geometry: 974/255/63 [15659008 Sectors]
Offset: 0       Signature: 0xAA55
            Starting         Ending         LBA Info:
 #: id      C   H   S -      C   H   S [       start:        size ]
-------------------------------------------------------------------------------
 0: EF      0   1   2 -      0  16  16 [          64:         960 ] EFI Sys     
 1: 00      0   0   0 -      0   0   0 [           0:           0 ] unused      
 2: 00      0   0   0 -      0   0   0 [           0:           0 ] unused      
*3: A6      0  16  17 -     45 227  54 [        1024:      736256 ] OpenBSD
Code:
$ disklabel sd1

# /dev/rsd1c:
type: vnd
disk: vnd device
label: fictitious
duid: 9e5b01f8dc3ea3f3
flags:
bytes/sector: 512
sectors/track: 100
tracks/cylinder: 1
sectors/cylinder: 100
cylinders: 7382
total sectors: 15659008
boundstart: 1024
boundend: 737280
drivedata: 0 

16 partitions:
#                size           offset  fstype [fsize bsize   cpg]
  a:           736256             1024  4.2BSD   2048 16384 16142 
  c:         15659008                0  unused                    
  i:              960               64   MSDOS
I would like to create an additional 4.2BSD formatted partition so I can use this space for storing other files. This new partition should use the entire unallocated space.

I think I need to do something like the following:
Code:
$ doas disklabel -E sd1

Label editor (enter '?' for help at any prompt)
>p
OpenBSD area: 1024-737280; size: 736256; free: 0
#                size           offset  fstype [fsize bsize   cpg]
  a:           736256             1024  4.2BSD   2048 16384 16142 
  c:         15659008                0  unused                    
  i:              960               64   MSDOS                    
> r
Total free sectors: 0.
> a j
No space left, you need to shrink a partition
> x
Which partition do I shrink and how do I shrink it? The only one to shrink is 'c' -- the entire disk??

Or is this the wrong approach?

Many thanks to anyone who can help.
Reply With Quote
  #2   (View Single Post)  
Old 4 Weeks Ago
jggimi's Avatar
jggimi jggimi is offline
More noise than signal
 
Join Date: May 2008
Location: USA
Posts: 5,934
Default

There are TWO levels of partitioning for MBR or GPT architectures. On these architectures, the disklabel(8) tool will use the first OpenBSD MBR/GPT partition it finds for its boundaries, unless you intentionally override. This is not recommended if you plan to use the drive with other systems, as the sectors beyond the MBR/GPT partition boundaries will not be reserved for OpenBSD.

  • Your GPT partition for OpenBSD is only 360 MB.
  • You should change this if you want OpenBSD to use a larger area.
Man pages which should help: fdisk(8), and disklabel(8).


---


Edited to add: the "c" disklabel partition is reserved for the entire physical device, regardless of any and all partitioning.

Last edited by jggimi; 4 Weeks Ago at 10:01 PM. Reason: edited for clarity
Reply With Quote
  #3   (View Single Post)  
Old 3 Weeks Ago
Oko's Avatar
Oko Oko is offline
Rc.conf Instructor
 
Join Date: May 2008
Location: Kosovo, Serbia
Posts: 1,101
Default

Learning the difference between the slices (MBR or GPT) and BSD partitions (disklabel) would be helpful.

https://www.dragonflybsd.org/docs/ha...sics/#index7h2

BSD partitions can't be shrink to my knowledge. They can be grown if you have empty space next to them
Code:
man growfs
.
Reply With Quote
  #4   (View Single Post)  
Old 3 Weeks Ago
gustaf gustaf is offline
Port Guard
 
Join Date: Dec 2016
Posts: 39
Default

Hi jggimi and Oko,

Thanks for your quick replies.

There is clearly something I'm missing about how disks work. I'm going to try finding and reading (or re-reading) all the disk-related man pages, cross-references, and the OpenBSD Disk Setup FAQ.

In the meantime, I think this means that I cannot simply partition the unallocated space on a disk, then build a new file system on the added partition, and leave the existing partitions and boot sector untouched.
Reply With Quote
  #5   (View Single Post)  
Old 3 Weeks Ago
jggimi's Avatar
jggimi jggimi is offline
More noise than signal
 
Join Date: May 2008
Location: USA
Posts: 5,934
Default

Another way to look at it:
  • There should be a single OpenBSD MBR/GPT partition on a disk drive
  • The disklabel partitions you assign are expected to reside within the MBR/GPT partition range.
Your fdisk(8) reports that the MBR/GPT partition is 736,256 512-byte sectors. That's 376,963,072 bytes, which is approximately 360MB.

fdisk() and disklabel(8) both report that there are 15,659,008 512-byte sectors on the drive. That's 8,017,412,096 bytes. The vendor will call that "8 GB" but computer users prefer using 1,024 bytes for byte counts in KB, MB, GB, TB .. .and using 1,024 instead of 1,000 we get a value slightly smaller than 7.5 GB.

---

Yes, you could override the GPT partition from within the disklabel() program - it's the internal editor's "b" command, described in the man page. But .. the purpose of an MBR or GPT partition table, beyond booting, is to ensure that different operating systems don't scribble over each other's data. You risk this if you decide to override the range defined by the GPT partition.

What's better than overriding a mistake in the GPT partition table? Correcting it, with fdisk(). A more useful value will expand the range of available OpenBSD space. You can even have fdisk expand the size automatically to the end of the disk, with "*". See the fdisk() man page.

After editing the GPT partition, you can either add new disklabel partitions as needed, or you could grow the existing partition as Oko suggested.

Or, you could backup, reformat, and reload data.
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
Install OpenBSD in more than one disk partition? betweendayandnight OpenBSD Installation and Upgrading 6 17th July 2015 05:51 PM
add another partition? amandus FreeBSD General 2 11th June 2013 02:51 PM
disk partition layout advise Fred974 FreeBSD Installation and Upgrading 14 8th November 2011 12:10 PM
Partition help needed. ros2468 OpenBSD Installation and Upgrading 9 22nd March 2010 01:25 PM
Disk geometry for Seagate disk phreud FreeBSD Installation and Upgrading 5 8th November 2008 10:51 PM


All times are GMT. The time now is 11:40 PM.


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