Growfs

From Hackepedia
Revision as of 01:57, 29 October 2005 by Pbug (talk | contribs)
Jump to navigationJump to search

Here is a breakdown on how to grow an ffs filesystem.

Let's make a big file which will represent our disk, 32MB in size:

# dd if=/dev/zero of=disk bs=32m count=1
1+0 records in
1+0 records out
33554432 bytes transferred in 0.164 secs (204133427 bytes/sec)
# vnconfig -cv svnd0 disk
svnd0: 33554432 bytes on disk

/dev/svnd0c is now our disk. Create a partition on it, this time we'll make it too small so that there is space left on the disk:

# disklabel -E svnd0
disklabel: Can't get bios geometry: Device not configured 
Initial label editor (enter '?' for help at any prompt)
> a
partition: [a]
offset: [0]
size: [65536] 32768
FS type: [4.2BSD]
> p
device: /dev/rsvnd0c
type: SCSI
disk: vnd device
label: fictitious
bytes/sector: 512
sectors/track: 100
tracks/cylinder: 1
sectors/cylinder: 100
cylinders: 655
total sectors: 65536
free sectors: 32768
rpm: 3600
16 partitions:
#             size        offset  fstype [fsize bsize  cpg]
  a:         32768             0  4.2BSD   2048 16384   16 # Cyl     0 -   327*
  c:         65536             0  unused      0     0      # Cyl     0 -   655*
> q
Write new label?: [y] y

Write the filesystem on it:

# newfs /dev/rsvnd0a
Warning: cylinder groups must have a multiple of 8 cylinders
Warning: 32 sector(s) in last cylinder unallocated
/dev/rsvnd0a:   32768 sectors in 328 cylinders of 1 tracks, 100 sectors
        16.0MB in 1 cyl groups (328 c/g, 16.02MB/g, 2048 i/g)
super-block backups (for fsck -b #) at:
 32,


Mount the filesystem and populate it with files:

# mount /dev/svnd0a /mnt
# cd /mnt
# cp /bin/* .
# cp /sbin/* .
/mnt: write failed, file system is full
...
# df .
Filesystem  512-blocks      Used     Avail Capacity  Mounted on
/dev/svnd0a      32156     31992     -1440   105%    /mnt
...
# df -i .
Filesystem  512-blocks      Used     Avail Capacity iused   ifree  %iused  Mounted on
/dev/svnd0a      32156     31740     -1188   104%     134    1912     7%   /mnt
# cd /tmp
# umount /mnt

Now we grow the partition:

# disklabel -e svnd0
# growfs /dev/rsvnd0a
We strongly recommend you make a backup before growing the Filesystem
Did you backup your data (Yes/No) ? Yes
new file system size is: 16384 frags
growfs: 65536 sectors in 656 cylinders of 1 tracks, 100 sectors
       32.0MB in 2 cyl groups (328 c/g, 16.02MB/g, 2048 i/g)
superblock backups (for fsck -b #) at:
 32832

Mount it and check it:

# mount /dev/svnd0a /mnt
# cd /mnt
# df .
Filesystem  512-blocks      Used     Avail Capacity  Mounted on
/dev/svnd0a      64348     31740     29392    52%    /mnt
# df -i .
Filesystem  512-blocks      Used     Avail Capacity iused   ifree  %iused  Mounted on
/dev/svnd0a      64348     31740     29392    52%     134    3960     3%   /mnt

Conclusions:

growfs not only increased the data space on the filesystem but also the index (inodes), this means that it had to relocate some data at the top of the dataspace to free data locations in order to increase the index past the previous inode-data gap.