{"id":1182,"date":"2008-03-28T23:39:36","date_gmt":"2008-03-28T23:39:36","guid":{"rendered":"http:\/\/www.icocean.com\/blog\/?p=1182"},"modified":"2008-03-28T23:49:29","modified_gmt":"2008-03-28T23:49:29","slug":"freebsd%E5%8A%A8%E6%80%81%E8%B0%83%E6%95%B4%E5%88%86%E5%8C%BA%E5%A4%A7%E5%B0%8F","status":"publish","type":"post","link":"https:\/\/www.icocean.com\/blog\/?p=1182","title":{"rendered":"freebsd\u52a8\u6001\u8c03\u6574\u5206\u533a\u5927\u5c0f"},"content":{"rendered":"<p>FreeBSD \u63d0\u4f9b\u4e86 growfs( \u547d\u4ee4\u3002\u8fd9\u4f7f\u5f97\u80fd\u591f\u5b9e\u65f6\u5730\u8c03\u6574\u6587\u4ef6\u7cfb\u7edf\u7684\u5927\u5c0f\uff0c \u56e0\u800c\u4e0d\u518d\u53d7\u5176\u9650\u5236\u3002<br \/>http:\/\/www.freebsd.org\/doc\/zh_CN.GB2312\/books\/handbook\/disk-organization.html<\/p>\n<p>growfs \u7684\u4f7f\u7528\u8fd8\u662f\u53d7\u5f88\u591a\u9650\u5236\u5427\u3002\u4ed4\u7ec6\u89c4\u5212\u5206\u533a\u7684\u5927\u5c0f\uff0c\u4e0d\u8981\u628a\u5e0c\u671b\u5bc4\u6258\u5728 growfs \u4e0a\u9762\u3002<\/p>\n<p><b>Growing FreeBSD&#39;s filesystems with growfs(8)<\/b><\/p>\n<p><b>Introduction<\/b><\/p>\n<p>During installation it is important to size filesystems so that we won&#39;t be forced to resize them later. However, it often appears with time that one of the partitions is too small. Until today it was impossible to expand the size of a filesystem. FreeBSD 4.4-RELEASE comes with a new utility: growfs(8). This program permits us to enlarge, in certains conditions, the size of an existing ufs filesystem.<!--more--><\/p>\n<p><b>Preparing the fight<\/b><\/p>\n<p>Before detailing the operations through one example, there are many things to know:<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Playing with filesystems is always a dangerous operation: do it only if it is mandatory and be sure to backup your data.<br \/>&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;growfs(8) can only grow &#8211; not shrink &#8211; filesystems. You would not be able to shrink the filesystem once it has been expanded.<br \/>&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;growfs(8) cannot enlarge a filesystem that does not have any free space around it.<br \/>&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;We will need to use growfs(8), disklabel(8), fdisk(8) and fsck(8). So print these manual pages and read them. Having a printed version under hand during the process is useful. Remember, in single user mode you can&#39;t read manual pages.<br \/>&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;To modify filesystems, we&#39;ll have to calculate sizes and sector numbers, so if you&#39;re bad at mental arithmetic use a calculator.<\/p>\n<p>I did my experiments on a machine running 4.4-PRERELEASE with a 6.4G hard drive.<\/p>\n<p>Here is the partition table of this hard drive:<\/p>\n<p># fdisk -s<\/p>\n<p>\/dev\/ad0: 784 cyl 255 hd 63 sec<\/p>\n<p>Part&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Start&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Size Type Flags<\/p>\n<p>&nbsp;&nbsp; 1:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;63&nbsp;&nbsp;&nbsp;&nbsp; 2088387 0x06 0x00<\/p>\n<p>&nbsp;&nbsp; 2:&nbsp;&nbsp;&nbsp;&nbsp; 2088450&nbsp;&nbsp;&nbsp;&nbsp; 2859570 0xa5 0x80<\/p>\n<p>&nbsp;&nbsp; 3:&nbsp;&nbsp;&nbsp;&nbsp; 4948020&nbsp;&nbsp;&nbsp;&nbsp; 7646940 0xa5 0x00<\/p>\n<p>As we can see, first slice is a msdos filesystem (type 0x06) and the others are FreeBSD filesystem (type 0xa5). The 4.4-PRERELEASE is on the second one; on the last, there&#39;s an old 3.5-STABLE system. I don&#39;t need the latter, so I will remove it and use the free space to enlarge the second slice.<\/p>\n<p>If I call fdisk(8) with no arguments, it prints the following:<\/p>\n<p>******* Working on device \/dev\/ad0 *******<\/p>\n<p>parameters extracted from in-core disklabel are:<\/p>\n<p>cylinders=784 heads=255 sectors\/track=63 (16065 blks\/cyl)<\/p>\n<p>parameters to be used for BIOS calculations are:<\/p>\n<p>cylinders=784 heads=255 sectors\/track=63 (16065 blks\/cyl)<\/p>\n<p>Media sector size is 512<\/p>\n<p>Warning: BIOS sector numbering starts with sector 1<\/p>\n<p>Information from DOS bootblock is:<\/p>\n<p>The data for partition 1 is:<\/p>\n<p>sysid 6,(Primary &#39;big&#39; DOS (> 32MB))<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;start 63, size 2088387 (1019 Meg), flag 0<\/p>\n<p> beg: cyl 0\/ head 1\/ sector 1;<\/p>\n<p> end: cyl 129\/ head 254\/ sector 63<\/p>\n<p>The data for partition 2 is:<\/p>\n<p>sysid 165,(FreeBSD\/NetBSD\/386BSD)<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;start 2088450, size 2859570 (1396 Meg), flag 80 (active)<\/p>\n<p> beg: cyl 130\/ head 0\/ sector 1;<\/p>\n<p> end: cyl 307\/ head 254\/ sector 63<\/p>\n<p>The data for partition 3 is:<\/p>\n<p>sysid 165,(FreeBSD\/NetBSD\/386BSD)<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;start 4948020, size 7646940 (3733 Meg), flag 0<\/p>\n<p> beg: cyl 308\/ head 0\/ sector 1;<\/p>\n<p> end: cyl 783\/ head 254\/ sector 63<\/p>\n<p>The data for partition 4 is:<\/p>\n<p><UNUSED><\/p>\n<p>The first thing to do is remove that third slice. I booted on the 4.4-PRERELEASE system and here&#39;s how it went:<\/p>\n<p># fdisk -u<\/p>\n<p>******* Working on device \/dev\/ad0 *******<\/p>\n<p>parameters extracted from in-core disklabel are:<\/p>\n<p>cylinders=784 heads=255 sectors\/track=63 (16065 blks\/cyl)<\/p>\n<p>parameters to be used for BIOS calculations are:<\/p>\n<p>cylinders=784 heads=255 sectors\/track=63 (16065 blks\/cyl)<\/p>\n<p>Do you want to change our idea of what BIOS thinks ? [n] n<\/p>\n<p>Media sector size is 512<\/p>\n<p>Warning: BIOS sector numbering starts with sector 1<\/p>\n<p>Information from DOS bootblock is:<\/p>\n<p>The data for partition 1 is:<\/p>\n<p>sysid 6,(Primary &#39;big&#39; DOS (> 32MB))<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;start 63, size 2088387 (1019 Meg), flag 0<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;beg: cyl 0\/ head 1\/ sector 1;<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end: cyl 129\/ head 254\/ sector 63<\/p>\n<p>Do you want to change it? [n] n<\/p>\n<p>The data for partition 2 is:<\/p>\n<p>sysid 165,(FreeBSD\/NetBSD\/386BSD)<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;start 2088450, size 2859570 (1396 Meg), flag 80 (active)<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;beg: cyl 130\/ head 0\/ sector 1;<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end: cyl 307\/ head 254\/ sector 63<\/p>\n<p>Do you want to change it? [n] n<\/p>\n<p>The data for partition 3 is:<\/p>\n<p>sysid 165,(FreeBSD\/NetBSD\/386BSD)<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;start 4948020, size 7646940 (3733 Meg), flag 0<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;beg: cyl 308\/ head 0\/ sector 1;<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end: cyl 783\/ head 254\/ sector 63<\/p>\n<p>Do you want to change it? [n] y<\/p>\n<p>Supply a decimal value for &#8220;sysid (165=FreeBSD)&#8221; [165] 0<\/p>\n<p>Supply a decimal value for &#8220;start&#8221; [4948020] 0<\/p>\n<p>Supply a decimal value for &#8220;size&#8221; [7646940] 0<\/p>\n<p>Explicitly specify beg\/end address ? [n] y<\/p>\n<p>Supply a decimal value for &#8220;beginning cylinder&#8221; [0] 0<\/p>\n<p>Supply a decimal value for &#8220;beginning head&#8221; [0] 0<\/p>\n<p>Supply a decimal value for &#8220;beginning sector&#8221; [0] 0<\/p>\n<p>Supply a decimal value for &#8220;ending cylinder&#8221; [0] 0<\/p>\n<p>Supply a decimal value for &#8220;ending head&#8221; [0] 0<\/p>\n<p>Supply a decimal value for &#8220;ending sector&#8221; [0] 0<\/p>\n<p><UNUSED><\/p>\n<p>Are we happy with this entry? [n] y<\/p>\n<p>The data for partition 4 is:<\/p>\n<p><UNUSED><\/p>\n<p>Do you want to change it? [n] n<\/p>\n<p>Do you want to change the active partition? [n] n<\/p>\n<p>We haven&#39;t changed the partition table yet.&nbsp;&nbsp;This is your last chance.<\/p>\n<p>parameters extracted from in-core disklabel are:<\/p>\n<p>cylinders=784 heads=255 sectors\/track=63 (16065 blks\/cyl)<\/p>\n<p>parameters to be used for BIOS calculations are:<\/p>\n<p>cylinders=784 heads=255 sectors\/track=63 (16065 blks\/cyl)<\/p>\n<p>Information from DOS bootblock is:<\/p>\n<p>1: sysid 6,(Primary &#39;big&#39; DOS (> 32MB))<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;start 63, size 2088387 (1019 Meg), flag 0<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;beg: cyl 0\/ head 1\/ sector 1;<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end: cyl 129\/ head 254\/ sector 63<\/p>\n<p>2: sysid 165,(FreeBSD\/NetBSD\/386BSD)<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;start 2088450, size 2859570 (1396 Meg), flag 80 (active)<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;beg: cyl 130\/ head 0\/ sector 1;<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end: cyl 307\/ head 254\/ sector 63<\/p>\n<p>3: <UNUSED><\/p>\n<p>4: <UNUSED><\/p>\n<p>Should we write new partition table? [n] y<\/p>\n<p>#<\/p>\n<p>Specifying a partition type of zero is equal to clear the partition and mark it as unused, but we must specify 0 values for all parameters concerning that partition (start, size&#8230;). Don&#39;t forget that what is called &#8220;partition&#8221; in fdisk, is known as &#8220;slice&#8221; in FreeBSD.<\/p>\n<p>Now fdisk -s prints:<\/p>\n<p># fdisk -s<\/p>\n<p>\/dev\/ad0: 784 cyl 255 hd 63 sec<\/p>\n<p>Part&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Start&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Size Type Flags<\/p>\n<p>&nbsp;&nbsp; 1:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;63&nbsp;&nbsp;&nbsp;&nbsp; 2088387 0x06 0x00<\/p>\n<p>&nbsp;&nbsp; 2:&nbsp;&nbsp;&nbsp;&nbsp; 2088450&nbsp;&nbsp;&nbsp;&nbsp; 2859570 0xa5 0x80<\/p>\n<p>After that, I performed the command fsck to check the filesystem.<\/p>\n<p><b>Expanding the \/usr partition<\/b><\/p>\n<p>Here is the current size of partitions:<\/p>\n<p># df -h<\/p>\n<p>Filesystem&nbsp;&nbsp;&nbsp;&nbsp;Size&nbsp;&nbsp; Used&nbsp;&nbsp;Avail Capacity&nbsp;&nbsp;Mounted on<\/p>\n<p>\/dev\/ad0s2a&nbsp;&nbsp;&nbsp;&nbsp;39M&nbsp;&nbsp;&nbsp;&nbsp;31M&nbsp;&nbsp; 4.4M&nbsp;&nbsp;&nbsp;&nbsp;88%&nbsp;&nbsp;&nbsp;&nbsp;\/<\/p>\n<p>\/dev\/ad0s2f&nbsp;&nbsp; 1.1G&nbsp;&nbsp; 810M&nbsp;&nbsp; 208M&nbsp;&nbsp;&nbsp;&nbsp;80%&nbsp;&nbsp;&nbsp;&nbsp;\/usr<\/p>\n<p>\/dev\/ad0s2e&nbsp;&nbsp; 145M&nbsp;&nbsp; 308K&nbsp;&nbsp; 133M&nbsp;&nbsp;&nbsp;&nbsp; 0%&nbsp;&nbsp;&nbsp;&nbsp;\/var<\/p>\n<p>procfs&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;4.0K&nbsp;&nbsp; 4.0K&nbsp;&nbsp;&nbsp;&nbsp; 0B&nbsp;&nbsp; 100%&nbsp;&nbsp;&nbsp;&nbsp;\/proc<\/p>\n<p>The \/usr is too small for me; I need something like 2.5G<\/p>\n<p>Before using growfs(8), the slice must be labeled as a bigger size with disklabel(8) and fdisk(8).<\/p>\n<p>Have a look at the current label of \/dev\/ad0s2:<\/p>\n<p># \/dev\/ad0s2c:<\/p>\n<p>type: ESDI<\/p>\n<p>disk: ad0s2<\/p>\n<p>label: <\/p>\n<p>flags:<\/p>\n<p>bytes\/sector: 512<\/p>\n<p>sectors\/track: 63<\/p>\n<p>tracks\/cylinder: 255<\/p>\n<p>sectors\/cylinder: 16065<\/p>\n<p>cylinders: 178<\/p>\n<p>sectors\/unit: 2859570<\/p>\n<p>rpm: 3600<\/p>\n<p>interleave: 1<\/p>\n<p>trackskew: 0<\/p>\n<p>cylinderskew: 0<\/p>\n<p>headswitch: 0&nbsp;&nbsp;# milliseconds<\/p>\n<p>track-to-track seek: 0 # milliseconds<\/p>\n<p>drivedata: 0 <\/p>\n<p>8 partitions:<\/p>\n<p>#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;size&nbsp;&nbsp; offset&nbsp;&nbsp;&nbsp;&nbsp;fstype&nbsp;&nbsp; [fsize bsize bps\/cpg]<\/p>\n<p>&nbsp;&nbsp;a:&nbsp;&nbsp;&nbsp;&nbsp;81920&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0&nbsp;&nbsp;&nbsp;&nbsp;4.2BSD&nbsp;&nbsp;&nbsp;&nbsp; 1024&nbsp;&nbsp;8192&nbsp;&nbsp;&nbsp;&nbsp;16&nbsp;&nbsp;# (Cyl.&nbsp;&nbsp;&nbsp;&nbsp;0 &#8211; 5*)<\/p>\n<p>&nbsp;&nbsp;b:&nbsp;&nbsp; 131072&nbsp;&nbsp;&nbsp;&nbsp;81920&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;swap&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # (Cyl.&nbsp;&nbsp;&nbsp;&nbsp;5*- 13*)<\/p>\n<p>&nbsp;&nbsp;c:&nbsp;&nbsp;2859570&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0&nbsp;&nbsp;&nbsp;&nbsp;unused&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0&nbsp;&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;# (Cyl.&nbsp;&nbsp;&nbsp;&nbsp;0 &#8211; 177)<\/p>\n<p>&nbsp;&nbsp;e:&nbsp;&nbsp; 307200&nbsp;&nbsp; 212992&nbsp;&nbsp;&nbsp;&nbsp;4.2BSD&nbsp;&nbsp;&nbsp;&nbsp; 1024&nbsp;&nbsp;8192&nbsp;&nbsp;&nbsp;&nbsp;16&nbsp;&nbsp;# (Cyl.&nbsp;&nbsp; 13*- 32*)<\/p>\n<p>&nbsp;&nbsp;f:&nbsp;&nbsp;2339378&nbsp;&nbsp; 520192&nbsp;&nbsp;&nbsp;&nbsp;4.2BSD&nbsp;&nbsp;&nbsp;&nbsp; 1024&nbsp;&nbsp;8192&nbsp;&nbsp;&nbsp;&nbsp;16&nbsp;&nbsp;# (Cyl.&nbsp;&nbsp; 32*- 177*)<\/p>\n<p>\/usr is 2339378 sectors large. We have a 512-byte sector (look at bytes\/sector parameter), and \/usr in (human-readable) size is: (2339378\/2)\/1024 Megabytes, or 1142.27MB (same as given by the df -h command above, 1.1G).<\/p>\n<p>I had said that I wanted a 2.5G large partition for \/usr. Let&#39;s do some calculations:<\/p>\n<p>2.5G is 2.5*1024*1024K<\/p>\n<p>with 512-bytes sector it gives<\/p>\n<p>2.5*1024*1024*2= 5242880 sectors<\/p>\n<p>We already use 2339378 sectors for \/usr, we have to add<\/p>\n<p>5242880-2339378= 2903502 sectors to \/usr and so to the whole slice.<\/p>\n<p>The whole slice size will be: 2859570+2903502= 5763072 sectors<\/p>\n<p>There are 16065 sectors\/cylinder, so 5763072 sectors require about 359<\/p>\n<p>cylinders.<\/p>\n<p>As summary, we will have to change these parameters in the label:<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;*<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cylinders: 178 to 359<br \/>&nbsp;&nbsp;&nbsp;&nbsp;*<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sectors\/unit: 2859570 to 5763072<br \/>&nbsp;&nbsp;&nbsp;&nbsp;*<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;c: 2859570 to 5763072<br \/>&nbsp;&nbsp;&nbsp;&nbsp;*<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;f: 2339378 to 5242880<\/p>\n<p>If I try to edit the label, disklabel(8) refuses these values; the slice is already full. I have to use fdisk(8) to enlarge the slice before labeling it.<\/p>\n<p>The delicate work begins here, so to avoid problems I log in as single user then launch fdisk(8):<\/p>\n<p># fdisk -u<\/p>\n<p>******* Working on device \/dev\/ad0 *******<\/p>\n<p>parameters extracted from in-core disklabel are:<\/p>\n<p>cylinders=784 heads=255 sectors\/track=63 (16065 blks\/cyl)<\/p>\n<p>parameters to be used for BIOS calculations are:<\/p>\n<p>cylinders=784 heads=255 sectors\/track=63 (16065 blks\/cyl)<\/p>\n<p>Do you want to change our idea of what BIOS thinks ? [n] n<\/p>\n<p>Media sector size is 512<\/p>\n<p>Warning: BIOS sector numbering starts with sector 1<\/p>\n<p>Information from DOS bootblock is:<\/p>\n<p>The data for partition 1 is:<\/p>\n<p>sysid 6,(Primary &#39;big&#39; DOS (> 32MB))<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;start 63, size 2088387 (1019 Meg), flag 0<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;beg: cyl 0\/ head 1\/ sector 1;<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end: cyl 129\/ head 254\/ sector 63<\/p>\n<p>Do you want to change it? [n] n<\/p>\n<p>The data for partition 2 is:<\/p>\n<p>sysid 165,(FreeBSD\/NetBSD\/386BSD)<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;start 2088450, size 2859570 (1396 Meg), flag 80 (active)<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;beg: cyl 130\/ head 0\/ sector 1;<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end: cyl 307\/ head 254\/ sector 63<\/p>\n<p>Do you want to change it? [n] y<\/p>\n<p>Supply a decimal value for &#8220;sysid (165=FreeBSD)&#8221; [165] 165<\/p>\n<p>Supply a decimal value for &#8220;start&#8221; [2088450] 2088450<\/p>\n<p>Supply a decimal value for &#8220;size&#8221; [2859570] 5763072<\/p>\n<p>Explicitly specify beg\/end address ? [n] y<\/p>\n<p>Supply a decimal value for &#8220;beginning cylinder&#8221; [130] 130<\/p>\n<p>Supply a decimal value for &#8220;beginning head&#8221; [0] 0<\/p>\n<p>Supply a decimal value for &#8220;beginning sector&#8221; [1] 1<\/p>\n<p>Supply a decimal value for &#8220;ending cylinder&#8221; [307] 489<\/p>\n<p>Supply a decimal value for &#8220;ending head&#8221; [254] 254<\/p>\n<p>Supply a decimal value for &#8220;ending sector&#8221; [63] 63<\/p>\n<p>Are we happy with this entry? [n] y<\/p>\n<p>The data for partition 3 is:<\/p>\n<p><UNUSED><\/p>\n<p>Do you want to change it? [n] n<\/p>\n<p>The data for partition 4 is:<\/p>\n<p><UNUSED><\/p>\n<p>Do you want to change it? [n] n<\/p>\n<p>Do you want to change the active partition? [n] n<\/p>\n<p>We haven&#39;t changed the partition table yet.&nbsp;&nbsp;This is your last chance.<\/p>\n<p>parameters extracted from in-core disklabel are:<\/p>\n<p>cylinders=784 heads=255 sectors\/track=63 (16065 blks\/cyl)<\/p>\n<p>parameters to be used for BIOS calculations are:<\/p>\n<p>cylinders=784 heads=255 sectors\/track=63 (16065 blks\/cyl)<\/p>\n<p>Information from DOS bootblock is:<\/p>\n<p>1: sysid 6,(Primary &#39;big&#39; DOS (> 32MB))<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;start 63, size 2088387 (1019 Meg), flag 0<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;beg: cyl 0\/ head 1\/ sector 1;<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end: cyl 129\/ head 254\/ sector 63<\/p>\n<p>2: sysid 165,(FreeBSD\/NetBSD\/386BSD)<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;start 2088450, size 5763072 (2814 Meg), flag 80 (active)<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;beg: cyl 130\/ head 0\/ sector 1;<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end: cyl 489\/ head 254\/ sector 63<\/p>\n<p>3: <UNUSED><\/p>\n<p>4: <UNUSED><\/p>\n<p>Should we write new partition table? [n] y<\/p>\n<p>#<\/p>\n<p>As you can see, I used the value calculated earlier; the end cylinder is given by 130+359. After that I decided to reboot:<\/p>\n<p>Then always in single user:<\/p>\n<p># fdisk -s<\/p>\n<p>\/dev\/ad0: 784 cyl 255 hd 63 sec<\/p>\n<p>Part&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Start&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Size Type Flags<\/p>\n<p>&nbsp;&nbsp; 1:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;63&nbsp;&nbsp;&nbsp;&nbsp; 2088387 0x06 0x00<\/p>\n<p>&nbsp;&nbsp; 2:&nbsp;&nbsp;&nbsp;&nbsp; 2088450&nbsp;&nbsp;&nbsp;&nbsp; 5763072 0xa5 0x80<\/p>\n<p>I edit the disklabel:<\/p>\n<p># disklabel -e -r \/dev\/ad0s2<\/p>\n<p>as the following:<\/p>\n<p># \/dev\/ad0s2c:<\/p>\n<p>type: ESDI<\/p>\n<p>disk: ad0s2<\/p>\n<p>label: <\/p>\n<p>flags:<\/p>\n<p>bytes\/sector: 512<\/p>\n<p>sectors\/track: 63<\/p>\n<p>tracks\/cylinder: 255<\/p>\n<p>sectors\/cylinder: 16065<\/p>\n<p>cylinders: 358<\/p>\n<p>sectors\/unit: 5763072<\/p>\n<p>rpm: 3600<\/p>\n<p>interleave: 1<\/p>\n<p>trackskew: 0<\/p>\n<p>cylinderskew: 0<\/p>\n<p>headswitch: 0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # milliseconds<\/p>\n<p>track-to-track seek: 0&nbsp;&nbsp;# milliseconds<\/p>\n<p>drivedata: 0<\/p>\n<p>8 partitions:<\/p>\n<p>#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;size&nbsp;&nbsp; offset&nbsp;&nbsp;&nbsp;&nbsp;fstype&nbsp;&nbsp; [fsize bsize bps\/cpg]<\/p>\n<p>&nbsp;&nbsp;a:&nbsp;&nbsp;&nbsp;&nbsp;81920&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0&nbsp;&nbsp;&nbsp;&nbsp;4.2BSD&nbsp;&nbsp;&nbsp;&nbsp; 1024&nbsp;&nbsp;8192&nbsp;&nbsp;&nbsp;&nbsp;16&nbsp;&nbsp; # (Cyl.&nbsp;&nbsp;&nbsp;&nbsp;0 &#8211; 5*)<\/p>\n<p>&nbsp;&nbsp;b:&nbsp;&nbsp; 131072&nbsp;&nbsp;&nbsp;&nbsp;81920&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;swap&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;# (Cyl.&nbsp;&nbsp;&nbsp;&nbsp;5*- 13*)<\/p>\n<p>&nbsp;&nbsp;c:&nbsp;&nbsp;5763072&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0&nbsp;&nbsp;&nbsp;&nbsp;unused&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0&nbsp;&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # (Cyl.&nbsp;&nbsp;&nbsp;&nbsp;0 &#8211; 177)<\/p>\n<p>&nbsp;&nbsp;e:&nbsp;&nbsp; 307200&nbsp;&nbsp; 212992&nbsp;&nbsp;&nbsp;&nbsp;4.2BSD&nbsp;&nbsp;&nbsp;&nbsp; 1024&nbsp;&nbsp;8192&nbsp;&nbsp;&nbsp;&nbsp;16&nbsp;&nbsp; # (Cyl.&nbsp;&nbsp; 13*- 32*)<\/p>\n<p>&nbsp;&nbsp;f:&nbsp;&nbsp;5242880&nbsp;&nbsp; 520192&nbsp;&nbsp;&nbsp;&nbsp;4.2BSD&nbsp;&nbsp;&nbsp;&nbsp; 1024&nbsp;&nbsp;8192&nbsp;&nbsp;&nbsp;&nbsp;16&nbsp;&nbsp; # (Cyl.&nbsp;&nbsp; 32*- 177*)<\/p>\n<p>#<\/p>\n<p>In my case, cylinders and sectors\/unit were automatically changed to the new values; only c and f sizes have to be modified. My comments follow the hash marks (#).<\/p>\n<p>Now we are ready to use growfs(8). We must umount the \/usr partition before:<\/p>\n<p># umount \/usr<\/p>\n<p># growfs -s 52422880 \/dev\/ad0s2f<\/p>\n<p>growfs(8) will ask you if you did a backup of your data; answer &#39;Yes&#39;, and you will see the process begin. When it is over, we can check the new size of \/usr:<\/p>\n<p># mount \/usr<\/p>\n<p># df -h<\/p>\n<p>Filesystem&nbsp;&nbsp;&nbsp;&nbsp;Size&nbsp;&nbsp; Used&nbsp;&nbsp;Avail Capacity&nbsp;&nbsp;Mounted on<\/p>\n<p>\/dev\/ad0s2a&nbsp;&nbsp;&nbsp;&nbsp;39M&nbsp;&nbsp;&nbsp;&nbsp;31M&nbsp;&nbsp; 4.4M&nbsp;&nbsp;&nbsp;&nbsp;88%&nbsp;&nbsp;&nbsp;&nbsp;\/<\/p>\n<p>\/dev\/ad0s2f&nbsp;&nbsp; 2.4G&nbsp;&nbsp; 810M&nbsp;&nbsp; 1.4G&nbsp;&nbsp;&nbsp;&nbsp;35%&nbsp;&nbsp;&nbsp;&nbsp;\/usr<\/p>\n<p>\/dev\/ad0s2e&nbsp;&nbsp; 145M&nbsp;&nbsp;&nbsp;&nbsp;79M&nbsp;&nbsp;&nbsp;&nbsp;55M&nbsp;&nbsp;&nbsp;&nbsp;59%&nbsp;&nbsp;&nbsp;&nbsp;\/var<\/p>\n<p>procfs&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;4.0K&nbsp;&nbsp; 4.0K&nbsp;&nbsp;&nbsp;&nbsp; 0B&nbsp;&nbsp; 100%&nbsp;&nbsp;&nbsp;&nbsp;\/proc<\/p>\n<p>Now the \/usr is 2.4G large, but I allocated 2.5G. The missing size is the percentage of space held back from normal users, which is 8% of the whole filesystem by default. For more information see the tunefs(8) manual page.<\/p>\n<p>To check the new filesystem, I used fsck(8):<\/p>\n<p># fsck<\/p>\n<p>** \/dev\/ad0s2a (NO WRITE)<\/p>\n<p>** Last Mounted on \/<\/p>\n<p>** Root file system<\/p>\n<p>** Phase 1 &#8211; Check Blocks and Sizes<\/p>\n<p>** Phase 2 &#8211; Check Pathnames<\/p>\n<p>** Phase 3 &#8211; Check Connectivity<\/p>\n<p>** Phase 4 &#8211; Check Reference Counts<\/p>\n<p>** Phase 5 &#8211; Check Cyl groups<\/p>\n<p>1145 files, 31975 used, 7672 free (136 frags, 942 blocks, 0.3% fragmentation)<\/p>\n<p>** \/dev\/ad0s2f (NO WRITE)<\/p>\n<p>** Last Mounted on \/usr<\/p>\n<p>** Phase 1 &#8211; Check Blocks and Sizes<\/p>\n<p>** Phase 2 &#8211; Check Pathnames<\/p>\n<p>** Phase 3 &#8211; Check Connectivity<\/p>\n<p>** Phase 4 &#8211; Check Reference Counts<\/p>\n<p>** Phase 5 &#8211; Check Cyl groups<\/p>\n<p>SUMMARY INFORMATION BAD<\/p>\n<p>SALVAGE? no<\/p>\n<p>BLK(S) MISSING IN BIT MAPS<\/p>\n<p>SALVAGE? no<\/p>\n<p>123343 files, 829946 used, 1711476 free (7748 frags, 212966 blocks, 0.3% fragmentation)<\/p>\n<p>** \/dev\/ad0s2e (NO WRITE)<\/p>\n<p>** Last Mounted on \/var<\/p>\n<p>** Phase 1 &#8211; Check Blocks and Sizes<\/p>\n<p>** Phase 2 &#8211; Check Pathnames<\/p>\n<p>** Phase 3 &#8211; Check Connectivity<\/p>\n<p>** Phase 4 &#8211; Check Reference Counts<\/p>\n<p>** Phase 5 &#8211; Check Cyl groups<\/p>\n<p>104 files, 80898 used, 67925 free (29 frags, 8487 blocks, 0.0% fragmentation)<\/p>\n<p>We can ignore both SALVAGE messages. If we relaunch fsck(8), all is well.<\/p>\n<p><b>Conclusion<\/b><\/p>\n<p>For me, growfs(8) did the job well, but remember that modifying your filesystem isn&#39;t a simple operation, so be careful and double-check everything.<\/p>\n<p>I have not tried to enlarge a vinum filesystem, but the process must be the same.<\/p>\n<p>Once again FreeBSD developers give us a superb tool. I hope a shrinkfs tool will be also developed in the future.<br \/>Marc Fonvieille<br \/>fonvi@easynet.fr<\/p>\n","protected":false},"excerpt":{"rendered":"<p>FreeBSD \u63d0\u4f9b\u4e86 growfs( \u547d\u4ee4\u3002\u8fd9\u4f7f\u5f97\u80fd\u591f\u5b9e\u65f6\u5730\u8c03\u6574\u6587\u4ef6\u7cfb\u7edf\u7684\u5927\u5c0f\uff0c \u56e0\u800c\u4e0d\u518d\u53d7\u5176\u9650\u5236\u3002http <a href='https:\/\/www.icocean.com\/blog\/?p=1182' class='excerpt-more'>[&#8230;]<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[601,1312,233,691,692],"class_list":["post-1182","post","type-post","status-publish","format-standard","hentry","category-linuxunix","tag-freebsd","tag-growfs","tag-233","tag-691","tag-692","category-16-id","post-seq-1","post-parity-odd","meta-position-corners","fix"],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.icocean.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1182","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.icocean.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.icocean.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.icocean.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.icocean.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1182"}],"version-history":[{"count":0,"href":"https:\/\/www.icocean.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1182\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.icocean.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1182"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.icocean.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1182"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.icocean.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1182"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}