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 October 2015
tab tab is offline
Port Guard
 
Join Date: Oct 2015
Posts: 15
Default How to resize /usr/local partition?

Hi,
I installed OpenBSD 5.7 on a VMware machine with an hdd of 10GB.
Now, i cannot install any prackage because /dev/wd0h (/user/local) is full.
I try to find a solution but without success
I resize my virtual hdd (from VMware) from 10GB to 15GB, but if I try to resize /dev/wd0h partition the system tell me it is busy.
The attached file is the output of my partitions (where C I think is the space I added):
Attached Images
File Type: jpg Capture.JPG (46.3 KB, 298 views)
Reply With Quote
  #2   (View Single Post)  
Old 26th October 2015
jggimi's Avatar
jggimi jggimi is offline
More noise than signal
 
Join Date: May 2008
Location: USA
Posts: 7,977
Default

Hello, and welcome!

Your /usr/local partition is currently surrounded by two other partitions: /usr/X11R6 and /usr/src. So you will not be able to use growfs(8) to increase its size without eliminating or moving /usr/src. However, you could move and resize the /usr/local partition into unused space. Here, then, is a completely untested "How to" -- written from memory (and having done similar tasks in the past myself). As with any guidance you get from an unofficial source, please use with caution.

1. Either boot into single-user mode (use "-s" at the boot> prompt) or drop from multi-user to single-user mode (# kill 1).

2. If you booted into single-user mode, mount all file systems (# mount -a). If you dropped into single-user mode, filesystems are already mounted.

3. Use disklabel(8) to create a new filesystem "l". Use the -E option to use the built-in disklabel editor. You will need to use the "b" command to reset the size of the OpenBSD-usable area, because the MBR on this larger drive has not been altered and the A6 MBR partition is still the old size of the drive. Read the disklabel(8) man page. Then, read it again.

4. Mount the new filesystem (# mount -o async,noatime /dev/wd0l /mnt)

5. Replicate the /usr/local filesystem. This example uses dump(8) and restore(8). Review their man pages.

# cd /mnt
# dump -0af - /usr/local | restore -rf -
# rm restoresymtable

6. Edit /etc/fstab, replacing your "h" partition with your "l" partition.

7. reboot.

Once you confirm everything is working properly, you may delete the "h" partition with disklabel(8).

Last edited by jggimi; 26th October 2015 at 11:27 AM. Reason: typos
Reply With Quote
  #3   (View Single Post)  
Old 26th October 2015
tab tab is offline
Port Guard
 
Join Date: Oct 2015
Posts: 15
Default

Quote:
Originally Posted by jggimi View Post
3. Use disklabel(8) to create a new filesystem "l". Use the -E option to use the built-in disklabel editor. You will need to use the "b" command to reset the size of the OpenBSD-usable area, because the MBR on this larger drive has not been altered and the A6 MBR partition is still the old size of the drive. Read the disklabel(8) man page. Then, read it again.
Can you well explain this step, please?
I have "h" partition with 2.2GB and I want to resize it without copy it on another partition.
So, in the 3rd step I type disklabel -E and then?

Thanks
Reply With Quote
  #4   (View Single Post)  
Old 26th October 2015
jggimi's Avatar
jggimi jggimi is offline
More noise than signal
 
Join Date: May 2008
Location: USA
Posts: 7,977
Default

You cannot grow a partition's size unless there is unallocated storage immediately following the partition. Immediately following your /usr/local partition is your /usr/src partition, and then your /usr/obj partition. If you are not using them, you could delete them, then use growfs(8).

The steps I described above assumed you want to keep them.

---

Option 1: Keeping /usr/src (and /usr/obj) partitions

Per step 5 above, use # disklabel -E wd0 to enter the disklabel editor.

You would use "b 64 *" to set the OpenBSD range from sector 64 to the end of the drive.

You would use "a" to add a new partition. It will prompt you for a partition letter, starting sector, and size. The default start point will be the first free sector, which is located between the end of your "b" partition and the start of your "d" partition, and isn't what you want. Set your starting sector to a location beyond the end of home (from sector 21065640 or beyond) and then pick the new size you want, the default will be the end of the free space, and you may choose less using "g" or "m" to pick GB or MB, if you wish.

Use "q" to quit. You'll be prompted to confirm an update to the disklabel.

Then, format the new partition -- I'd left this out of my simple "How To" above.

# newfs wd0l

After this, mount it and copy the contents, as shown in the "How To".

---

Option 2: Eliminating (or moving) /usr/src and /usr/obj partitions

1. When in single-user mode, dismount the partitions you will revise and remove.

# umount /usr/local
# umount /usr/src
# umount /usr/obj

2. Use your disklabel editor to delete the "i" and "j" partitions.

# disklabel -E wd0
d i
d j

3. While in the editor, increase the size of the "h" partition into the newly created free space.

m h
(when you reach the size, change it)

q

4. Run growfs(8) to increase the size of the filesystem in the resized "h" partition.

# growfs wd0h

5. Run fsck(8) to check the disk. The disk is always marked "dirty" by growfs and requires an fsck().

# fsck /usr/local

6. Optionally, recreate the "i" /usr/src and "j" /usr/obj partitions with disklabel(8) and format them with newfs(8).

7. If you did not recreate the partitions, edit your /etc/fstab to remove them.

Last edited by jggimi; 26th October 2015 at 02:24 PM. Reason: typos, again
Reply With Quote
  #5   (View Single Post)  
Old 27th October 2015
tab tab is offline
Port Guard
 
Join Date: Oct 2015
Posts: 15
Default

Thank you very much!
Reply With Quote
  #6   (View Single Post)  
Old 4th December 2022
lattimro lattimro is offline
Port Guard
 
Join Date: Jun 2021
Posts: 15
Default

Quote:
Originally Posted by jggimi View Post
Hello, and welcome!

Your /usr/local partition is currently surrounded by two other partitions: /usr/X11R6 and /usr/src. So you will not be able to use growfs(8) to increase its size without eliminating or moving /usr/src. However, you could move and resize the /usr/local partition into unused space. Here, then, is a completely untested "How to" -- written from memory (and having done similar tasks in the past myself). As with any guidance you get from an unofficial source, please use with caution.

1. Either boot into single-user mode (use "-s" at the boot> prompt) or drop from multi-user to single-user mode (# kill 1).

2. If you booted into single-user mode, mount all file systems (# mount -a). If you dropped into single-user mode, filesystems are already mounted.

3. Use disklabel(8) to create a new filesystem "l". Use the -E option to use the built-in disklabel editor. You will need to use the "b" command to reset the size of the OpenBSD-usable area, because the MBR on this larger drive has not been altered and the A6 MBR partition is still the old size of the drive. Read the disklabel(8) man page. Then, read it again.

4. Mount the new filesystem (# mount -o async,noatime /dev/wd0l /mnt)

5. Replicate the /usr/local filesystem. This example uses dump(8) and restore(8). Review their man pages.

# cd /mnt
# dump -0af - /usr/local | restore -rf -
# rm restoresymtable

6. Edit /etc/fstab, replacing your "h" partition with your "l" partition.

7. reboot.

Once you confirm everything is working properly, you may delete the "h" partition with disklabel(8).
jggimi is not clear: where wd0i is mounted? After step 8 /usr/local is now on /mnt right? Is there another step? 5b?
Reply With Quote
  #7   (View Single Post)  
Old 4th December 2022
jggimi's Avatar
jggimi jggimi is offline
More noise than signal
 
Join Date: May 2008
Location: USA
Posts: 7,977
Default

Disclaimer: you are asking me about a post I wrote more than seven years ago.
Quote:
Originally Posted by lattimro
...where wd0i is mounted?
In the top post, there is link to an image of a disklabel partition map. From that image, I can see that partition "i" is /usr/src. I can also see that it begins at sector 11216992 and is 2222816 sectors in length. With a little arithmetic, I can determine that the partition's last sector number is 13439807, and I can confirm there are no unused sectors which follow partition "i" as partition "j" begins at sector 13439808.
Quote:
After step 8 /usr/local is now on /mnt right?
There was no step 8. The last step number was 7.

The original /usr/local partition was "h". The new /usr/local partition will be "l". Step 3 creates the new partition, Step 4 mounts the new partition as /mnt (temporarily), Step 5 copies the data from the old to the new partition, and Step 6 replaces it in the list of partitions to mount during boot.
Reply With Quote
  #8   (View Single Post)  
Old 4th December 2022
lattimro lattimro is offline
Port Guard
 
Join Date: Jun 2021
Posts: 15
Default

Quote:
Originally Posted by jggimi View Post
Disclaimer: you are asking me about a post I wrote more than seven years ago. In the top post, there is link to an image of a disklabel partition map. From that image, I can see that partition "i" is /usr/src. I can also see that it begins at sector 11216992 and is 2222816 sectors in length. With a little arithmetic, I can determine that the partition's last sector number is 13439807, and I can confirm there are no unused sectors which follow partition "i" as partition "j" begins at sector 13439808.There was no step 8. The last step number was 7.

The original /usr/local partition was "h". The new /usr/local partition will be "l". Step 3 creates the new partition, Step 4 mounts the new partition as /mnt (temporarily), Step 5 copies the data from the old to the new partition, and Step 6 replaces it in the list of partitions to mount during boot.
Sorry jggimi, my typo. After Step 5 I meant.
Step 6: was not clear enough if the mount point in fstab was /usr/local or /mnt as long as the /usr/local (old h was erased (or is going to be erased in Step 6. For me /usr/local has no data (newly created 'i:' partition) and old /usr/local data is still mounted on /mnt. Sure I am missing something.
Thanks!
Reply With Quote
  #9   (View Single Post)  
Old 4th December 2022
lattimro lattimro is offline
Port Guard
 
Join Date: Jun 2021
Posts: 15
Default

Quote:
Originally Posted by tab View Post
Hi,
I installed OpenBSD 5.7 on a VMware machine with an hdd of 10GB.
Now, i cannot install any prackage because /dev/wd0h (/user/local) is full.
I try to find a solution but without success
I resize my virtual hdd (from VMware) from 10GB to 15GB, but if I try to resize /dev/wd0h partition the system tell me it is busy.
The attached file is the output of my partitions (where C I think is the space I added):
If the last sector of k is 20 964 760 and the "c:" size is 31 457 280 sectors then can the difference of 10 492 519 sectors is the extra 5,123.3M (5G) that was extended in VM (from 10 to 15G). Where 205 free sectors come from? Should not be 10 492 519? Or maybe they are recalculated after resetting (b) the usable area (which parts of the disk it is allowed to modify)? However I still can't get how 205 sectors were calculated.
Reply With Quote
Old 4th December 2022
jggimi's Avatar
jggimi jggimi is offline
More noise than signal
 
Join Date: May 2008
Location: USA
Posts: 7,977
Default

Quote:
Originally Posted by lattimro View Post
Step 6: was not clear enough if the mount point in fstab was /usr/local or /mnt ...
The edit to the fstab(5) provisioning was intended to change the filesystem to be mounted at /usr/local to the newly created and restored "l" partition.
Quote:
Originally Posted by lattimro View Post
If the last sector of k is 20 964 760...
You're going to have to show the disklabel output. I do not see a a sector-level report either in this old thread or in your "main" thread. Perhaps I missed it.
Reply With Quote
Old 4th December 2022
lattimro lattimro is offline
Port Guard
 
Join Date: Jun 2021
Posts: 15
Default

Quote:
Originally Posted by jggimi View Post
The edit to the fstab(5) provisioning was intended to change the filesystem to be mounted at /usr/local to the newly created and restored "l" partition.You're going to have to show the disklabel output. I do not see a a sector-level report either in this old thread or in your "main" thread. Perhaps I missed it.
I do not understand when the /mnt was copied to newly "l" partition? It is not empty. I mean /usr/local?

It is about this old thread, if you open the attachment (Capture.JPG (46.3 KB, 266 views)) on OP you will see the numbers.

Thanks for taking the time to read this

Last edited by lattimro; 4th December 2022 at 11:39 PM.
Reply With Quote
Old 5th December 2022
jggimi's Avatar
jggimi jggimi is offline
More noise than signal
 
Join Date: May 2008
Location: USA
Posts: 7,977
Default

There are 185 sectors free at 20964640, as you noted. There are also 20 sectors free at 1270412, which is hard to find without either doing manual arithmetic or recreating this disklabel in a vnode(9) and letting disklabel show where the free sectors were hiding. Which is what I did to find them.

The original /usr/local filesystem was copied to the new filesystem at the temporary mount point /mnt using dump(8) and restore(8). A mount point is nothing more than a directory. The edit of the fstab would be to revise the partition mounted at /usr/local from the "h" partition to the new "l" partition.
Reply With Quote
Old 5th December 2022
lattimro lattimro is offline
Port Guard
 
Join Date: Jun 2021
Posts: 15
Default

Quote:
Originally Posted by jggimi View Post
There are 185 sectors free at 20964640, as you noted. There are also 20 sectors free at 1270412, which is hard to find without either doing manual arithmetic or recreating this disklabel in a vnode(9) and letting disklabel show where the free sectors were hiding. Which is what I did to find them.
I said "If the last sector of k is 20 964 760". You said 20 964 640.

Yes, you got 205. I do know now how you got these numbers!

Last edited by lattimro; 8th December 2022 at 11:00 AM.
Reply With Quote
Reply

Tags
partitioning, resize /usr/local

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
resize root partition of my server Tzzzzzzzz OpenBSD Installation and Upgrading 15 2nd June 2014 10:23 PM
mysql won't run via rc.local benben159 OpenBSD Packages and Ports 3 8th August 2010 02:41 PM
log from rc.conf.local and rc.local sdesilet OpenBSD General 1 21st January 2010 02:37 AM
tmux disable automatic resize Carpetsmoker General software and network 7 25th June 2009 10:54 PM
local dns (dnsmasq) bsdperson FreeBSD Ports and Packages 3 3rd September 2008 06:48 AM


All times are GMT. The time now is 06:11 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