On Thu, Feb 21, 2019 at 12:36:01PM +0100, Otto Moerbeek wrote:
> On Thu, Feb 21, 2019 at 11:49:51AM +0200, Artturi Alm wrote:
> 
> > Hi,
> > 
> > using R to resize auto allocated partition truncates fsize and bsize
> > to 0 of the last partition, like shown below with arm64 snapshot.
> > this may be just visual, i haven't tried proceeding w/o resizing the
> > last partition to gain those back.
> > 
> > -Artturi
> > 
> > 
> > Available disks are: sd0.
> > Which disk is the root disk? ('?' for details) [sd0] 
> > MBR has invalid signature; not showing it.
> > Use (W)hole disk or (E)dit the MBR? [whole] 
> > Creating a msdos partition and an OpenBSD partition for rest of sd0...done.
> > /dev/rsd0i: 32668 sectors in 8167 FAT16 clusters (2048 bytes/cluster)
> > bps=512 spc=4 res=1 nft=2 rde=512 sec=32768 mid=0xf8 spf=32 spt=63 hds=255 
> > hid=8192
> > The auto-allocated layout for sd0 is:
> > #                size           offset  fstype [fsize bsize   cpg]
> >   a:          1024.0M            40960  4.2BSD   2048 16384     1 # /
> >   b:          1170.0M          2138112    swap                    
> >   c:         60240.0M                0  unused                    
> >   d:          4096.0M          4534304  4.2BSD   2048 16384     1 # /tmp
> >   e:          5924.0M         12922880  4.2BSD   2048 16384     1 # /var
> >   f:          2048.0M         25055264  4.2BSD   2048 16384     1 # /usr
> >   g:          1024.0M         29249568  4.2BSD   2048 16384     1 # 
> > /usr/X11R6
> >   h:          8529.7M         31346720  4.2BSD   2048 16384     1 # 
> > /usr/local
> >   i:            16.0M             8192   MSDOS                    
> >   j:          2048.0M         48815520  4.2BSD   2048 16384     1 # /usr/src
> >   k:          6144.0M         53009824  4.2BSD   2048 16384     1 # /usr/obj
> >   l:         28212.3M         65592736  4.2BSD   2048 16384     1 # /home
> > Use (A)uto layout, (E)dit auto layout, or create (C)ustom layout? [a] e
> > Label editor (enter '?' for help at any prompt)
> > > p g
> > OpenBSD area: 40960-123371520; size: 58.8G; free: 0.0G
> > #                size           offset  fstype [fsize bsize   cpg]
> >   a:             1.0G            40960  4.2BSD   2048 16384     1 # /
> >   b:             1.1G          2138112    swap                    
> >   c:            58.8G                0  unused                    
> >   d:             4.0G          4534304  4.2BSD   2048 16384     1 # /tmp
> >   e:             5.8G         12922880  4.2BSD   2048 16384     1 # /var
> >   f:             2.0G         25055264  4.2BSD   2048 16384     1 # /usr
> >   g:             1.0G         29249568  4.2BSD   2048 16384     1 # 
> > /usr/X11R6
> >   h:             8.3G         31346720  4.2BSD   2048 16384     1 # 
> > /usr/local
> >   i:             0.0G             8192   MSDOS                    
> >   j:             2.0G         48815520  4.2BSD   2048 16384     1 # /usr/src
> >   k:             6.0G         53009824  4.2BSD   2048 16384     1 # /usr/obj
> >   l:            27.6G         65592736  4.2BSD   2048 16384     1 # /home
> > > R b
> > [+|-]new size (with unit): [2396176] 4g
> > Partition l shrunk to 51786368 sectors to make room
> > > p g
> > OpenBSD area: 40960-123371520; size: 58.8G; free: 0.0G
> > #                size           offset  fstype [fsize bsize   cpg]
> >   a:             1.0G            40960  4.2BSD   2048 16384     1 # /
> >   b:             4.0G          2138112    swap                    
> >   c:            58.8G                0  unused                    
> >   d:             4.0G         10526720  4.2BSD   2048 16384     1 # /tmp
> >   e:             5.8G         18915296  4.2BSD   2048 16384     1 # /var
> >   f:             2.0G         31047680  4.2BSD   2048 16384     1 # /usr
> >   g:             1.0G         35241984  4.2BSD   2048 16384     1 # 
> > /usr/X11R6
> >   h:             8.3G         37339136  4.2BSD   2048 16384     1 # 
> > /usr/local
> >   i:             0.0G             8192   MSDOS                    
> >   j:             2.0G         54807936  4.2BSD   2048 16384     1 # /usr/src
> >   k:             6.0G         59002240  4.2BSD   2048 16384     1 # /usr/obj
> >   l:            24.7G         71585152  4.2BSD      0     0     1 # /home
> > > R l
> > [+|-]new size (with unit): [51786368] 
> > > p g
> > OpenBSD area: 40960-123371520; size: 58.8G; free: 0.0G
> > #                size           offset  fstype [fsize bsize   cpg]
> >   a:             1.0G            40960  4.2BSD   2048 16384     1 # /
> >   b:             4.0G          2138112    swap                    
> >   c:            58.8G                0  unused                    
> >   d:             4.0G         10526720  4.2BSD   2048 16384     1 # /tmp
> >   e:             5.8G         18915296  4.2BSD   2048 16384     1 # /var
> >   f:             2.0G         31047680  4.2BSD   2048 16384     1 # /usr
> >   g:             1.0G         35241984  4.2BSD   2048 16384     1 # 
> > /usr/X11R6
> >   h:             8.3G         37339136  4.2BSD   2048 16384     1 # 
> > /usr/local
> >   i:             0.0G             8192   MSDOS                    
> >   j:             2.0G         54807936  4.2BSD   2048 16384     1 # /usr/src
> >   k:             6.0G         59002240  4.2BSD   2048 16384     1 # /usr/obj
> >   l:            24.7G         71585152  4.2BSD   2048 16384     1 # /home
> > > R j
> > [+|-]new size (with unit): [4194304] 3g
> > Partition l shrunk to 49689216 sectors to make room
> > > p g
> > OpenBSD area: 40960-123371520; size: 58.8G; free: 0.0G
> > #                size           offset  fstype [fsize bsize   cpg]
> >   a:             1.0G            40960  4.2BSD   2048 16384     1 # /
> >   b:             4.0G          2138112    swap                    
> >   c:            58.8G                0  unused                    
> >   d:             4.0G         10526720  4.2BSD   2048 16384     1 # /tmp
> >   e:             5.8G         18915296  4.2BSD   2048 16384     1 # /var
> >   f:             2.0G         31047680  4.2BSD   2048 16384     1 # /usr
> >   g:             1.0G         35241984  4.2BSD   2048 16384     1 # 
> > /usr/X11R6
> >   h:             8.3G         37339136  4.2BSD   2048 16384     1 # 
> > /usr/local
> >   i:             0.0G             8192   MSDOS                    
> >   j:             3.0G         54807936  4.2BSD   2048 16384     1 # /usr/src
> >   k:             6.0G         61099392  4.2BSD   2048 16384     1 # /usr/obj
> >   l:            23.7G         73682304  4.2BSD      0     0     1 # /home
> > > w
> > > p g
> > OpenBSD area: 40960-123371520; size: 58.8G; free: 0.0G
> > #                size           offset  fstype [fsize bsize   cpg]
> >   a:             1.0G            40960  4.2BSD   2048 16384     1 # /
> >   b:             4.0G          2138112    swap                    
> >   c:            58.8G                0  unused                    
> >   d:             4.0G         10526720  4.2BSD   2048 16384     1 # /tmp
> >   e:             5.8G         18915296  4.2BSD   2048 16384     1 # /var
> >   f:             2.0G         31047680  4.2BSD   2048 16384     1 # /usr
> >   g:             1.0G         35241984  4.2BSD   2048 16384     1 # 
> > /usr/X11R6
> >   h:             8.3G         37339136  4.2BSD   2048 16384     1 # 
> > /usr/local
> >   i:             0.0G             8192   MSDOS                    
> >   j:             3.0G         54807936  4.2BSD   2048 16384     1 # /usr/src
> >   k:             6.0G         61099392  4.2BSD   2048 16384     1 # /usr/obj
> >   l:            23.7G         73682304  4.2BSD      0     0     1 # /home
> > > R l
> > Resize only implemented for auto allocated labels
> > > ?
> > Available commands:
> >  ? | h    - 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    R [part] - resize auto allocated 
> > partition
> >  c [part] - change partition size     r        - display free space
> >  D        - reset label to default    s [path] - save label to file
> >  d [part] - delete partition          U        - undo all changes
> >  e        - edit drive parameters     u        - undo last change
> >  g [d|u]  - [d]isk or [u]ser geometry w        - write label to disk
> >  i        - modify disklabel UID      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) 't' 
> > (terabytes)
> >  'c' (cylinders), '%' (% of total disk), '&' (% of free space).
> > Values in non-sector units are truncated to the nearest cylinder boundary.
> > > m l
> > offset: [73682304] 
> > size: [49689216] 
> > FS type: [4.2BSD] 
> > mount point: [/home] 
> > > p g
> > OpenBSD area: 40960-123371520; size: 58.8G; free: 0.0G
> > #                size           offset  fstype [fsize bsize   cpg]
> >   a:             1.0G            40960  4.2BSD   2048 16384     1 # /
> >   b:             4.0G          2138112    swap                    
> >   c:            58.8G                0  unused                    
> >   d:             4.0G         10526720  4.2BSD   2048 16384     1 # /tmp
> >   e:             5.8G         18915296  4.2BSD   2048 16384     1 # /var
> >   f:             2.0G         31047680  4.2BSD   2048 16384     1 # /usr
> >   g:             1.0G         35241984  4.2BSD   2048 16384     1 # 
> > /usr/X11R6
> >   h:             8.3G         37339136  4.2BSD   2048 16384     1 # 
> > /usr/local
> >   i:             0.0G             8192   MSDOS                    
> >   j:             3.0G         54807936  4.2BSD   2048 16384     1 # /usr/src
> >   k:             6.0G         61099392  4.2BSD   2048 16384     1 # /usr/obj
> >   l:            23.7G         73682304  4.2BSD   2048 16384     1 # /home
> > > w
> > > q
> > No label changes.
> > 
> 
> Thanks for the report. This should fix it,
> 
>       -Otto
> 
> Index: editor.c
> ===================================================================
> RCS file: /cvs/src/sbin/disklabel/editor.c,v
> retrieving revision 1.353
> diff -u -p -r1.353 editor.c
> --- editor.c  25 Jan 2019 00:19:26 -0000      1.353
> +++ editor.c  21 Feb 2019 11:35:07 -0000
> @@ -795,10 +795,10 @@ editor_resize(struct disklabel *lp, char
>                       DL_SETPOFFSET(pp, off);
>                       if (off + DL_GETPSIZE(pp) > ending_sector) {
>                               DL_SETPSIZE(pp, ending_sector - off);
> -                             pp->p_fragblock = 0;
> -                             if (get_fsize(&label, partno) == 1 ||
> -                                 get_bsize(&label, partno) == 1 ||
> -                                 get_cpg(&label, partno) == 1)
> +                             pp->p_fragblock = DISKLABELV1_FFS_FRAGBLOCK(0, 
> 0);
> +                             if (get_fsize(&label, i) == 1 ||
> +                                 get_bsize(&label, i) == 1 ||
> +                                 get_cpg(&label, i) == 1)
>                                       return;
>                               shrunk = i;
>                       }
> 

Oops, my bad. That diff looks good to me. ok krw@

.... Ken

Reply via email to