BigAdmin System Administration Portal
Community-Submitted Tech Tip
Print-friendly VersionPrint-friendly Version
This content is submitted by a BigAdmin user. It has not been reviewed for technical accuracy by Sun Microsystems, though it may have been lightly edited to improve readability. If you find an error or would like to comment on the article, please contact the submitter or use the comment field at the bottom of the article. Community submissions may not follow Sun trademark guidelines. For information on Sun trademarks, please see http://www.sun.com/suntrademarks/.
 
 

Expanding a File System Without Mounting It As a Meta Device

Joseph Gan, August, 2004

What can you do if a file system needs to grow, but it cannot be mounted as a metadevice on the fly? What if the file system is not suitable to be mounted as a metadevice? What can you do when file systems like these run out the space?

Usually you have to copy the data to a larger partition, which means you have to dismount the file system or bring the machine down, and then copy the data over. Otherwise, you can restore the data from backup media. Here is a simple way to do all this using Solaris Volume Manager software: With this method, you can expand a UFS file system on the fly.

(Note: If you are able to mount the file system as a meta device instead, you can refer to my other Tech Tip, Expanding a File System on the Fly.)

In this case, I use the /test file system as an example.

The /test file system is 96 percent full, as indicated in the output by the df command:

  # df -k
  ......
  /dev/dsk/c7t5d7s0    8662733 8307768 268338    96%    /test
  ......

First, make a new partition, in this case device c9t1d3 on a Sun StorEdge T3 array, and make it 60 Gbyte in size:

# format
Searching for disks...done

AVAILABLE DISK SELECTIONS:
    ......
        1. c9t1d3             
          /sbus@3,0/SUNW,socal@0,0/sf@0,0/ssd@w50020f230000666e,3
Specify disk (enter its number): 1
selecting c9t1d3
[disk formatted]
Warning: Current Disk has mounted partitions.

partition> p
Current partition table (original):
Total disk cylinders available: 34901 + 2 (reserved cylinders)

Part      Tag    Flag     Cylinders         Size            Blocks
  0       home    wm       1 - 10240       60.00GB    (10240/0/0) 125829120
  1 unassigned    wm       0                0         (0/0/0)             0
  2     backup    wu       0 - 34900      204.50GB    (34901/0/0) 428863488
  3       home    wm   21000 - 22749       10.25GB    (1750/0/0)   21504000
  4       home    wm   26293 - 28172       11.02GB    (1880/0/0)   23101440
  5       home    wm   28173 - 33467       31.03GB    (5295/0/0)   65064960
  6 unassigned    wm       0                0         (0/0/0)             0
  7 unassigned    wm       0                0         (0/0/0)             0

partition> 1
Part      Tag    Flag     Cylinders         Size            Blocks
  1 unassigned    wm   0           0                (0/0/0)    0

Enter partition id tag[unassigned]:
Enter partition permission flags[wm]:
Enter new starting cyl[10241]: 10241
Enter partition size[132194304b, 10758c, 64548.00mb, 63.04gb]: 60g
partition> p
Current partition table (unnamed):
Total disk cylinders available: 34901 + 2 (reserved cylinders)

Part      Tag    Flag     Cylinders         Size            Blocks
  0       home    wm       1 - 10240       60.00GB    (10240/0/0) 125829120
  1 unassigned    wm   10241 - 20480       60.00GB    (10240/0/0) 125829120
  2     backup    wu       0 - 34900      204.50GB    (34901/0/0) 428863488
  3       home    wm   21000 - 22749       10.25GB    (1750/0/0)   21504000
  4       home    wm   26293 - 28172       11.02GB    (1880/0/0)   23101440
  5       home    wm   28173 - 33467       31.03GB    (5295/0/0)   65064960
  6 unassigned    wm       0                0         (0/0/0)             0
  7 unassigned    wm       0                0         (0/0/0)             0

partition> l
Ready to label disk, continue? y

partition> q

Second, use Solaris Volume Manager software as a "bridge" to create a one-way mirror named d124 on the original file system by using the -f (force) option:

# metainit -f d125 1 1 c7t5d7s0
d125: Concat/Stripe is setup

# metainit d124 -m d125
d124: Mirror is setup

Third, create a new sub-mirror named d126 on the new partition as formatted earlier:

# metainit d126 1 1 c9t1d3s1
d126: Concat/Stripe is setup

Now, attach d126 to d124, using the metattach command. Resynchronization will automatically take place:

# metattach d124 d126
d124: submirror d126 is attached

When this has been done, we have successfully "moved" the data over, and the best thing is that the data is always synchronized.

# metastat d124
d124: Mirror
    Submirror 0: d125
      State: Okay
    Submirror 1: d126
      State: Okay
    Resync in progress: 100 % done
    Pass: 1
    Read option: roundrobin (default)
    Write option: parallel (default)
    Size: 17596416 blocks

d125: Submirror of d124
    State: Okay
    Size: 17596416 blocks
    Stripe 0:
        Device              Start Block  Dbase State        Hot Spare
        c7t5d7s0                   0     No    Okay

d126: Submirror of d124
    State: Resyncing
    Size: 125829120 blocks
    Stripe 0:
        Device              Start Block  Dbase State        Hot Spare
        c9t1d3s1                   0     No    Okay

What you have to do now is dismount the file system from the old partition, detach the sub-mirror, and clear all the metadevices you have created for this case. Then remount the file system to the new partition:

# umount /test
# metadetach d124 d126
d124: submirror d126 is detached

# metaclear d124
d124: Mirror is cleared

# metaclear d125
d125: Concat/Stripe is cleared

# mount /dev/dsk/c9t1d3s1 /oracle

# df -k
......
/dev/dsk/c9t1d3s1    8662733  8316368 259738      96%    /test

At this point, the new file system is still the same size as the previous one, because it is a sub-mirror.

Finally, you'll need to record the new size in blocks (from the output of metastat d126), as well as use some special arguments and the second hidden mkfs command, so you can expand the new file system on the fly:

# /usr/lib/fs/ufs/mkfs -G -M /test /dev/rdsk/c9t1d3s1 125829120

/dev/rdsk/c9t1d3s1:     125829120 sectors in 30720 cylinders of 64 tracks, 64
sectors
        61440.0MB in 1182 cyl groups (26 c/g, 52.00MB/g, 6400 i/g)
super-block backups (for fsck -F ufs -o b=#) at:
32, 106592, 213152, 319712, 426272, 532832, 639392, 745952, 852512, 959072,
......

125240864, 125347424, 125453984, 125560544, 125667104, 125773664,

You can check that the file system (/test) has been successfully expanded on the new partition:

# df -k
Filesystem            kbytes    used   avail capacity  Mounted on
......
/dev/dsk/c9t1d3s1    61950013  8316368 53633645      13%    /test
.....

Please note: This procedure must be done during a quiet period, or the file system must be locked, in order to avoid possible changes to the file system during the sync. You can use the fuser -u command to check that no one is using the file system. If users are logged on overnight in their logging directory, the system admin could write-lock the file system if it is possible. In that case, users can still read files in the directory. As long as no one creates files during the sync, everything will be fine.

 


The information and links on this page have been provided by a BigAdmin user. The submitter is solely responsible for such information and links. Sun is not responsible for the availability of external sites or resources, and does not endorse and is not responsible or liable for any content, advertising, products, or other materials on or available from such sites or resources. Sun will not be responsible or liable, directly or indirectly, for any actual or alleged damage or loss caused by or in connection with use of or reliance on the information posted here, or goods or services available on or through any external site or resource.


Rate and Review
Tell us what you think of the content of this page.
Excellent   Good   Fair   Poor  
Comments:
Your email address (no reply is possible without an address):
Sun Privacy Policy

Note: We are not able to respond to all submitted comments.
BigAdmin
  
 
 
 
Would you recommend this Sun site to a friend or colleague?
Contact About Sun News & Events Employment Site Map Privacy Terms of Use Trademarks Copyright Sun Microsystems, Inc.