version=pmwiki-2.2.130 ordered=1 urlencoded=1 agent=w3m/0.5.3+git20210102 author=jrmu charset=UTF-8 csum= ctime=1611458508 host=38.87.162.8 name=Openbsd.Growfs rev=15 targets=Openbsd.Backup,Openbsd.Announce,Openbsd.Fsck text=(:title Growing a partition:)%0a%0a'''WARNING''': '''BE CAREFUL!''' Some commands in this tutorial can cause permanent data loss. We recommend you [[openbsd/backup|backup]] your files before attempting to run these commands. You should also double check every command to make sure you have made no typos or mistakes. A single typo could destroy your data forever!%0a%0a'''NOTE''': This guide is '''no''' substitute for reading the [[https://www.openbsd.org/faq/|OpenBSD FAQ]]. In particular, you should read the section on [[https://www.openbsd.org/faq/faq14.html|Disk Setup]] and [[https://www.openbsd.org/faq/faq14.html#GrowPartition|Growing a Partition]].%0a%0a'''NOTE''': Before performing the upgrades, you will want to [[openbsd/announce|announce]] the changes to your users and teammates.%0a%0aOn OpenBSD, there are two disk drivers: [[https://man.openbsd.org/wd|wd]] and [[https://man.openbsd.org/sd|sd]]. wd is an IDE-like disk, and sd is a SCSI-like disk (including USB disks). To list all your available disks:%0a%0a[@%0a# dmesg | grep -E '(sd[0-9]|wd[0-9])'%0asd0 at scsibus1 targ 0 lun 0: %3cATA, WDC WD10EZEX-21M, 01.0> naa.50014ee25f5d927d%0asd0: 953869MB, 512 bytes/sector, 1953525168 sectors%0a@]%0a%0aWe see here there is one hard disk with over 900GB of disk space. Let's see how much we are using:%0a%0a[@%0a# df -h%0aFilesystem Size Used Avail Capacity Mounted on%0a/dev/sd0a 986M 103M 833M 11%25 /%0a/dev/sd0k 295G 151G 130G 54%25 /home%0a/dev/sd0d 3.9G 16.0K 3.7G 0%25 /tmp%0a/dev/sd0f 5.8G 1.6G 3.9G 29%25 /usr%0a/dev/sd0g 986M 234M 702M 25%25 /usr/X11R6%0a/dev/sd0h 19.4G 5.3G 13.1G 29%25 /usr/local%0a/dev/sd0j 5.8G 2.0K 5.5G 0%25 /usr/obj%0a/dev/sd0i 1.9G 2.0K 1.8G 0%25 /usr/src%0a/dev/sd0e 11.3G 30.9M 10.7G 0%25 /var%0a@]%0a%0aOnly around 300G of the total 900GB is actually formatted and available for use. If you check disklabel, you will see that 500GB of disk space is free:%0a%0a[@%0a# disklabel -E sd0%0aLabel editor (enter '?' for help at any prompt)%0asd0> p G%0aOpenBSD area: 64-1953520065; size: 931.5G; free: 575.7G%0a# size offset fstype [fsize bsize cpg]%0a a: 1.0G 64 4.2BSD 2048 16384 12960 # /%0a b: 4.1G 2097216 swap # none%0a c: 931.5G 0 unused %0a d: 4.0G 10690752 4.2BSD 2048 16384 12960 # /tmp%0a e: 11.7G 19079328 4.2BSD 2048 16384 12960 # /var%0a f: 6.0G 43606400 4.2BSD 2048 16384 12960 # /usr%0a g: 1.0G 56189312 4.2BSD 2048 16384 12960 # /usr/X11R6%0a h: 20.0G 58286464 4.2BSD 2048 16384 12960 # /usr/local%0a i: 2.0G 100229504 4.2BSD 2048 16384 12960 # /usr/src%0a j: 6.0G 104423808 4.2BSD 2048 16384 12960 # /usr/obj%0a k: 300.0G 117006720 4.2BSD 4096 32768 26062 # /home%0a@]%0a%0a@@p G@@ means to print in Gigabytes, to make it more human readable.%0a%0aThe disk partition labeled c represents the entire disk; the total disk size is 931.5G. We can also see that 575.7G disk space is free, which means we can use it to grow the last partition on our disk (partition k).%0a%0a'''NOTE''': The free space must follow the partition you want to grow. Otherwise, you will be unable to grow the partition.%0a%0a'''WARNING''': The partition you want to grow must be unmounted before you grow it. Otherwise, your partition may become corrupt and you will lose all your data.%0a%0aFirst, we need to unmount the partition:%0a%0a[@%0a# umount /dev/sd0k%0a@]%0a%0a'''NOTE''': In order to unmount the /home partition like we did above, you may need to log out of all users except the root user, then log in as root. If any user is in their /home folder, the filesystem will be busy and you will be unable to unmount.%0a%0aAfterwards, we will edit the disklabel and enlarge the size of sd0k:%0a%0a[@%0a# disklabel -E sd0 %0aLabel editor (enter '?' for help at any prompt)%0asd0> ? %0aAvailable commands:%0a ? | h - show help n [part] - set mount point%0a A - auto partition all space p [unit] - print partitions%0a a [part] - add partition q - quit & save changes%0a b - set OpenBSD boundaries R [part] - resize auto allocated partition%0a c [part] - change partition size r - display free space%0a D - reset label to default s [path] - save label to file%0a d [part] - delete partition U - undo all changes%0a e - edit drive parameters u - undo last change%0a g [d|u] - [d]isk or [u]ser geometry w - write label to disk%0a i - modify disklabel UID X - toggle expert mode%0a l [unit] - print disk label header x - exit & lose changes%0a M - disklabel(8) man page z - delete all partitions%0a m [part] - modify partition%0a@]%0a%0aIf disklabel is not showing all the free space available, you may first need to run%0ab to set the OpenBSD boundary. This can occur if your disk is greater than 2TB or%0aif you are in a virtual machine and enlarged the size of your disk space after%0ainstallation.%0a%0a[@%0asd0> b%0aStarting sector: [64] %0aSize ('*' for entire disk): [1953520065] *%0asd0> %0a@]%0a%0aWe want to @@c k@@ change the size of partition k:%0a%0a[@%0asd0> c k%0aPartition k is currently 629145600 sectors in size, and can have a maximum%0asize of 1836513345 sectors.%0asize: [629145600] *%0asd0*> p G%0aOpenBSD area: 64-1953520065; size: 931.5G; free: 0.0G%0a# size offset fstype [fsize bsize cpg]%0a a: 1.0G 64 4.2BSD 2048 16384 12960 # /%0a b: 4.1G 2097216 swap # none%0a c: 931.5G 0 unused %0a d: 4.0G 10690752 4.2BSD 2048 16384 12960 # /tmp%0a e: 11.7G 19079328 4.2BSD 2048 16384 12960 # /var%0a f: 6.0G 43606400 4.2BSD 2048 16384 12960 # /usr%0a g: 1.0G 56189312 4.2BSD 2048 16384 12960 # /usr/X11R6%0a h: 20.0G 58286464 4.2BSD 2048 16384 12960 # /usr/local%0a i: 2.0G 100229504 4.2BSD 2048 16384 12960 # /usr/src%0a j: 6.0G 104423808 4.2BSD 2048 16384 12960 # /usr/obj%0a k: 875.7G 117006720 4.2BSD 4096 32768 26062 # /home%0asd0*> w%0asd0> q%0a@]%0a%0aFinally, we grow the disk:%0a%0a[@%0a# growfs /dev/sd0k%0aWe strongly recommend you to make a backup before growing the Filesystem%0a%0a Did you backup your data (Yes/No) ? yes%0anew filesystem size is: 229564168 frags%0aWarning: 80576 sector(s) cannot be allocated.%0agrowfs: 896695.7MB (1836432768 sectors) block size 32768, fragment size 4096%0a using 1101 cylinder groups of 814.44MB, 26062 blks, 52224 inodes.%0asuper-block backups (for fsck -b #) at:%0a 630492096, 632160064, 633828032, 635496000, 637163968, 638831936, 640499904,%0a 642167872, 643835840, 645503808, 647171776, 648839744, 650507712, 652175680,%0a 653843648, 655511616, 657179584, 658847552, 660515520, 662183488, 663851456,%0a@]%0a%0aWe perform a [[openbsd/fsck|fsck]] to ensure consistency:%0a%0a[@%0a# fsck /dev/sd0k%0a** /dev/rsd0k%0a** Last Mounted on /home%0a** Phase 1 - Check Blocks and Sizes%0a** Phase 2 - Check Pathnames%0a** Phase 3 - Check Connectivity%0a** Phase 4 - Check Reference Counts%0a** Phase 5 - Check Cyl groups%0a1929 files, 39512255 used, 186430532 free (28 frags, 23303813 blocks, 0.0%25 fragmentation)%0a%0aMARK FILE SYSTEM CLEAN? [Fyn?] F%0a%0a***** FILE SYSTEM WAS MODIFIED *****%0a@]%0a%0aTo finish up, we mount the partition again, then check the files to ensure that everything is there:%0a%0a[@%0a# mount /dev/sd0k /home%0a# ls /home/%0a...%0a# df -h%0aFilesystem Size Used Avail Capacity Mounted on%0a...%0a/dev/sd0k 862G 155M 819G 0%25 /home%0a...%0a@]%0a%0aSee Also:%0a time=1654043666 title=Growing a partition author:1654043666=jrmu diff:1654043666:1628815451:=65c65%0a%3c # umount /dev/sd0k%0a---%0a> # unmount /dev/sd0k%0a host:1654043666=38.87.162.8 author:1628815451=jrmu diff:1628815451:1628814646:=96,102d95%0a%3c %0a%3c [@%0a%3c sd0> b%0a%3c Starting sector: [64] %0a%3c Size ('*' for entire disk): [1953520065] *%0a%3c sd0> %0a%3c @]%0a host:1628815451=38.87.162.8 author:1628814646=jrmu diff:1628814646:1611461706:=92,96d91%0a%3c If disklabel is not showing all the free space available, you may first need to run%0a%3c b to set the OpenBSD boundary. This can occur if your disk is greater than 2TB or%0a%3c if you are in a virtual machine and enlarged the size of your disk space after%0a%3c installation.%0a%3c %0a170c165%0a%3c See Also:%0a---%0a> See Also:%0a\ No newline at end of file%0a host:1628814646=38.87.162.8 author:1611461706=jrmu diff:1611461706:1611461244:=157,162d156%0a%3c ...%0a%3c # df -h%0a%3c Filesystem Size Used Avail Capacity Mounted on%0a%3c ...%0a%3c /dev/sd0k 862G 155M 819G 0%25 /home%0a%3c ...%0a host:1611461706=125.231.20.163 author:1611461244=jrmu diff:1611461244:1611460892:=134,135c134,135%0a%3c We perform a [[openbsd/fsck|fsck]] to ensure consistency:%0a%3c %0a---%0a> Finally we perform a [[openbsd/fsck|fsck]] to ensure consistency:%0a> %0a150,159c150%0a%3c @]%0a%3c %0a%3c To finish up, we mount the partition again, then check the files to ensure that everything is there:%0a%3c %0a%3c [@%0a%3c # mount /dev/sd0k /home%0a%3c # ls /home/%0a%3c @]%0a%3c %0a%3c See Also:%0a\ No newline at end of file%0a---%0a> @]%0a\ No newline at end of file%0a host:1611461244=125.231.20.163 author:1611460892=jrmu diff:1611460892:1611460844:=138,149d137%0a%3c ** /dev/rsd0k%0a%3c ** Last Mounted on /home%0a%3c ** Phase 1 - Check Blocks and Sizes%0a%3c ** Phase 2 - Check Pathnames%0a%3c ** Phase 3 - Check Connectivity%0a%3c ** Phase 4 - Check Reference Counts%0a%3c ** Phase 5 - Check Cyl groups%0a%3c 1929 files, 39512255 used, 186430532 free (28 frags, 23303813 blocks, 0.0%25 fragmentation)%0a%3c %0a%3c MARK FILE SYSTEM CLEAN? [Fyn?] F%0a%3c %0a%3c ***** FILE SYSTEM WAS MODIFIED *****%0a host:1611460892=125.231.20.163 author:1611460844=jrmu diff:1611460844:1611460786:=120c120%0a%3c # growfs /dev/sd0k%0a---%0a> # growfs sd0k%0a132,137d131%0a%3c @]%0a%3c %0a%3c Finally we perform a [[openbsd/fsck|fsck]] to ensure consistency:%0a%3c %0a%3c [@%0a%3c # fsck /dev/sd0k%0a host:1611460844=125.231.20.163 author:1611460786=jrmu diff:1611460786:1611460728:=120,131c120%0a%3c # growfs sd0k%0a%3c We strongly recommend you to make a backup before growing the Filesystem%0a%3c %0a%3c Did you backup your data (Yes/No) ? yes%0a%3c new filesystem size is: 229564168 frags%0a%3c Warning: 80576 sector(s) cannot be allocated.%0a%3c growfs: 896695.7MB (1836432768 sectors) block size 32768, fragment size 4096%0a%3c using 1101 cylinder groups of 814.44MB, 26062 blks, 52224 inodes.%0a%3c super-block backups (for fsck -b #) at:%0a%3c 630492096, 632160064, 633828032, 635496000, 637163968, 638831936, 640499904,%0a%3c 642167872, 643835840, 645503808, 647171776, 648839744, 650507712, 652175680,%0a%3c 653843648, 655511616, 657179584, 658847552, 660515520, 662183488, 663851456,%0a---%0a> # growfs /dev/sd0k%0a host:1611460786=125.231.20.163 author:1611460728=jrmu diff:1611460728:1611460517:=12c12%0a%3c # dmesg | grep -E '(sd[0-9]|wd[0-9])'%0a---%0a> $ dmesg | grep -E '(sd[0-9]|wd[0-9])'%0a20c20%0a%3c # df -h%0a---%0a> $ df -h%0a36c36%0a%3c # disklabel -E sd0%0a---%0a> $ doas disklabel -E sd0%0a65c65%0a%3c # unmount /dev/sd0k%0a---%0a> $ doas unmount /dev/sd0k%0a68,69d67%0a%3c '''NOTE''': In order to unmount the /home partition like we did above, you may need to log out of all users except the root user, then log in as root. If any user is in their /home folder, the filesystem will be busy and you will be unable to unmount.%0a%3c %0a115,120d112%0a%3c @]%0a%3c %0a%3c Finally, we grow the disk:%0a%3c %0a%3c [@%0a%3c # growfs /dev/sd0k%0a host:1611460728=125.231.20.163 author:1611460517=jrmu diff:1611460517:1611460271:=73,92d72%0a%3c sd0> ? %0a%3c Available commands:%0a%3c ? | h - show help n [part] - set mount point%0a%3c A - auto partition all space p [unit] - print partitions%0a%3c a [part] - add partition q - quit & save changes%0a%3c b - set OpenBSD boundaries R [part] - resize auto allocated partition%0a%3c c [part] - change partition size r - display free space%0a%3c D - reset label to default s [path] - save label to file%0a%3c d [part] - delete partition U - undo all changes%0a%3c e - edit drive parameters u - undo last change%0a%3c g [d|u] - [d]isk or [u]ser geometry w - write label to disk%0a%3c i - modify disklabel UID X - toggle expert mode%0a%3c l [unit] - print disk label header x - exit & lose changes%0a%3c M - disklabel(8) man page z - delete all partitions%0a%3c m [part] - modify partition%0a%3c @]%0a%3c %0a%3c We want to @@c k@@ change the size of partition k:%0a%3c %0a%3c [@%0a111,112d90%0a%3c sd0*> w%0a%3c sd0> q%0a host:1611460517=125.231.20.163 author:1611460271=jrmu diff:1611460271:1611459238:=71,90c71%0a%3c # disklabel -E sd0 %0a%3c Label editor (enter '?' for help at any prompt)%0a%3c sd0> c k%0a%3c Partition k is currently 629145600 sectors in size, and can have a maximum%0a%3c size of 1836513345 sectors.%0a%3c size: [629145600] *%0a%3c sd0*> p G%0a%3c OpenBSD area: 64-1953520065; size: 931.5G; free: 0.0G%0a%3c # size offset fstype [fsize bsize cpg]%0a%3c a: 1.0G 64 4.2BSD 2048 16384 12960 # /%0a%3c b: 4.1G 2097216 swap # none%0a%3c c: 931.5G 0 unused %0a%3c d: 4.0G 10690752 4.2BSD 2048 16384 12960 # /tmp%0a%3c e: 11.7G 19079328 4.2BSD 2048 16384 12960 # /var%0a%3c f: 6.0G 43606400 4.2BSD 2048 16384 12960 # /usr%0a%3c g: 1.0G 56189312 4.2BSD 2048 16384 12960 # /usr/X11R6%0a%3c h: 20.0G 58286464 4.2BSD 2048 16384 12960 # /usr/local%0a%3c i: 2.0G 100229504 4.2BSD 2048 16384 12960 # /usr/src%0a%3c j: 6.0G 104423808 4.2BSD 2048 16384 12960 # /usr/obj%0a%3c k: 875.7G 117006720 4.2BSD 4096 32768 26062 # /home%0a---%0a> %0a host:1611460271=125.231.20.163 author:1611459238=jrmu diff:1611459238:1611459055:=68,72d67%0a%3c Afterwards, we will edit the disklabel and enlarge the size of sd0k:%0a%3c %0a%3c [@%0a%3c %0a%3c @]%0a\ No newline at end of file%0a host:1611459238=125.231.20.163 author:1611459055=jrmu diff:1611459055:1611458650:=56,67c56%0a%3c The disk partition labeled c represents the entire disk; the total disk size is 931.5G. We can also see that 575.7G disk space is free, which means we can use it to grow the last partition on our disk (partition k).%0a%3c %0a%3c '''NOTE''': The free space must follow the partition you want to grow. Otherwise, you will be unable to grow the partition.%0a%3c %0a%3c '''WARNING''': The partition you want to grow must be unmounted before you grow it. Otherwise, your partition may become corrupt and you will lose all your data.%0a%3c %0a%3c First, we need to unmount the partition:%0a%3c %0a%3c [@%0a%3c $ doas unmount /dev/sd0k%0a%3c @]%0a%3c %0a---%0a> The disk partition labeled c represents the entire disk; the total disk size is 931.5G. We can also see that 575.7G disk space is free, which means we can use it to grow the last partition on our disk (partition k).%0a\ No newline at end of file%0a host:1611459055=125.231.20.163 author:1611458650=jrmu diff:1611458650:1611458508:=5c5%0a%3c '''NOTE''': This guide is '''no''' substitute for reading the [[https://www.openbsd.org/faq/|OpenBSD FAQ]]. In particular, you should read the section on [[https://www.openbsd.org/faq/faq14.html|Disk Setup]] and [[https://www.openbsd.org/faq/faq14.html#GrowPartition|Growing a Partition]].%0a---%0a> '''NOTE''': This guide is '''no''' substitute for reading the [[https://www.openbsd.org/faq/|OpenBSD FAQ]]. In particular, you should read the section on [[https://www.openbsd.org/faq/faq14.html|Disk Setup]].%0a host:1611458650=125.231.20.163 author:1611458508=jrmu diff:1611458508:1611458508:=1,56d0%0a%3c (:title Growing a partition:)%0a%3c %0a%3c '''WARNING''': '''BE CAREFUL!''' Some commands in this tutorial can cause permanent data loss. We recommend you [[openbsd/backup|backup]] your files before attempting to run these commands. You should also double check every command to make sure you have made no typos or mistakes. A single typo could destroy your data forever!%0a%3c %0a%3c '''NOTE''': This guide is '''no''' substitute for reading the [[https://www.openbsd.org/faq/|OpenBSD FAQ]]. In particular, you should read the section on [[https://www.openbsd.org/faq/faq14.html|Disk Setup]].%0a%3c %0a%3c '''NOTE''': Before performing the upgrades, you will want to [[openbsd/announce|announce]] the changes to your users and teammates.%0a%3c %0a%3c On OpenBSD, there are two disk drivers: [[https://man.openbsd.org/wd|wd]] and [[https://man.openbsd.org/sd|sd]]. wd is an IDE-like disk, and sd is a SCSI-like disk (including USB disks). To list all your available disks:%0a%3c %0a%3c [@%0a%3c $ dmesg | grep -E '(sd[0-9]|wd[0-9])'%0a%3c sd0 at scsibus1 targ 0 lun 0: %3cATA, WDC WD10EZEX-21M, 01.0> naa.50014ee25f5d927d%0a%3c sd0: 953869MB, 512 bytes/sector, 1953525168 sectors%0a%3c @]%0a%3c %0a%3c We see here there is one hard disk with over 900GB of disk space. Let's see how much we are using:%0a%3c %0a%3c [@%0a%3c $ df -h%0a%3c Filesystem Size Used Avail Capacity Mounted on%0a%3c /dev/sd0a 986M 103M 833M 11%25 /%0a%3c /dev/sd0k 295G 151G 130G 54%25 /home%0a%3c /dev/sd0d 3.9G 16.0K 3.7G 0%25 /tmp%0a%3c /dev/sd0f 5.8G 1.6G 3.9G 29%25 /usr%0a%3c /dev/sd0g 986M 234M 702M 25%25 /usr/X11R6%0a%3c /dev/sd0h 19.4G 5.3G 13.1G 29%25 /usr/local%0a%3c /dev/sd0j 5.8G 2.0K 5.5G 0%25 /usr/obj%0a%3c /dev/sd0i 1.9G 2.0K 1.8G 0%25 /usr/src%0a%3c /dev/sd0e 11.3G 30.9M 10.7G 0%25 /var%0a%3c @]%0a%3c %0a%3c Only around 300G of the total 900GB is actually formatted and available for use. If you check disklabel, you will see that 500GB of disk space is free:%0a%3c %0a%3c [@%0a%3c $ doas disklabel -E sd0%0a%3c Label editor (enter '?' for help at any prompt)%0a%3c sd0> p G%0a%3c OpenBSD area: 64-1953520065; size: 931.5G; free: 575.7G%0a%3c # size offset fstype [fsize bsize cpg]%0a%3c a: 1.0G 64 4.2BSD 2048 16384 12960 # /%0a%3c b: 4.1G 2097216 swap # none%0a%3c c: 931.5G 0 unused %0a%3c d: 4.0G 10690752 4.2BSD 2048 16384 12960 # /tmp%0a%3c e: 11.7G 19079328 4.2BSD 2048 16384 12960 # /var%0a%3c f: 6.0G 43606400 4.2BSD 2048 16384 12960 # /usr%0a%3c g: 1.0G 56189312 4.2BSD 2048 16384 12960 # /usr/X11R6%0a%3c h: 20.0G 58286464 4.2BSD 2048 16384 12960 # /usr/local%0a%3c i: 2.0G 100229504 4.2BSD 2048 16384 12960 # /usr/src%0a%3c j: 6.0G 104423808 4.2BSD 2048 16384 12960 # /usr/obj%0a%3c k: 300.0G 117006720 4.2BSD 4096 32768 26062 # /home%0a%3c @]%0a%3c %0a%3c @@p G@@ means to print in Gigabytes, to make it more human readable.%0a%3c %0a%3c The disk partition labeled c represents the entire disk; the total disk size is 931.5G. We can also see that 575.7G disk space is free, which means we can use it to grow the last partition on our disk (partition k).%0a\ No newline at end of file%0a host:1611458508=125.231.20.163