Growing FreeBSD's filesystems with growfs(8)

2009-05-13 11:46:18来源:未知 阅读 ()

新老客户大回馈,云服务器低至5折

Introduction
During installation it is important to size filesystems so that we won'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.
Preparing the fight
Before detailing the operations through one example, there are many things to know:


  • Playing with filesystems is always a dangerous operation: do it only if it is mandatory and be sure to backup your data.

  • growfs(8) can only grow - not shrink - filesystems. You would not be able to shrink the filesystem once it has been expanded.

  • growfs(8) cannot enlarge a filesystem that does not have any free space around it.

  • 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't read manual pages.

  • To modify filesystems, we'll have to calculate sizes and sector numbers, so if you're bad at mental arithmetic use a calculator.

I did my experiments on a machine running 4.4-PRERELEASE with a 6.4G hard drive.
Here is the partition table of this hard drive:
# fdisk -s
/dev/ad0: 784 cyl 255 hd 63 sec
Part        Start        Size Type Flags
   1:          63     2088387 0x06 0x00
   2:     2088450     2859570 0xa5 0x80
   3:     4948020     7646940 0xa5 0x00
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's an old 3.5-STABLE system. I don't need the latter, so I will remove it and use the free space to enlarge the second slice.
If I call fdisk(8) with no arguments, it prints the following:
******* Working on device /dev/ad0 *******
parameters extracted from in-core disklabel are:
cylinders=784 heads=255 sectors/track=63 (16065 blks/cyl)
parameters to be used for BIOS calculations are:
cylinders=784 heads=255 sectors/track=63 (16065 blks/cyl)
Media sector size is 512
Warning: BIOS sector numbering starts with sector 1
Information from DOS bootblock is:
The data for partition 1 is:
sysid 6,(Primary 'big' DOS (> 32MB))
    start 63, size 2088387 (1019 Meg), flag 0
beg: cyl 0/ head 1/ sector 1;
end: cyl 129/ head 254/ sector 63
The data for partition 2 is:
sysid 165,(FreeBSD/NetBSD/386BSD)
    start 2088450, size 2859570 (1396 Meg), flag 80 (active)

标签:

版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有

上一篇:portupgrade命令参数

下一篇:OpenBSD 3.8与Cisco6509配合实现跨vlan动态分配ip