| Reorganizing a file system |
|
|
|
| Written by gerryh |
|
Back up the file system by file name. If you back up the file system by i-node instead of by name, the restore command puts the files back in their original places, which would not solve the problem. Run the following commands: # cd /home/op # find . -print | backup -ivf/tmp/op.backup This command creates a backup file (in a different file system), containing all of the files in the file system that is to be reorganized. If disk space on the system is limited, you can use tape to back up the file system. Run the following commands: # cd / # unmount /home/op If any processes are using /home/op or any of its subdirectories, you must terminate those processes before the unmount command can complete successfully. Re-create the file system on the /home/op logical volume, as follows: # mkfs /dev/hd11 You are prompted for confirmation before the old file system is destroyed. The name of the file system does not change. To restore the original situation (except that /home/op is empty), run the following: # mount /dev/hd11 /home/op # cd /home/op Restore the data, as follows: # restore -xvf/tmp/op.backup >/dev/null Standard output is redirected to /dev/null to avoid displaying the name of each of the files that were restored, which is time-consuming. Review the large file inspected earlier # fileplace -piv big1 We see that it is now (nearly) contiguous: File: big1 Size: 3554273 bytes Vol: /dev/hd11 Blk Size: 4096 Frag Size: 4096 Nfrags: 868 Compress: no Inode: 8290 Mode: -rwxr-xr-x Owner: hoetzel Group: system INDIRECT BLOCK: 60307 Physical Addresses (mirror copy 1) Logical Fragment ---------------------------------- ---------------- 0060299-0060306 hdisk1 8 frags 32768 Bytes, 0.9% 0008555-0008562 0060308-0061167 hdisk1 860 frags 3522560 Bytes, 99.1% 0008564-0009423 868 frags over space of 869 frags: space efficiency = 99.9% 2 fragments out of 868 possible: sequentiality = 99.9% The -i option that we added to the fileplace command indicates that the one-block gap between the first eight blocks of the file and the remainder contains the indirect block, which is required to supplement the i-node information when the length of the file exceeds eight blocks. Some file systems or logical volumes should not be reorganized because the data is either transitory (for example, /tmp) or not in a file system format (log). The root file system is normally not very volatile and seldom needs reorganizing. It can only be done in install/maintenance mode. The same is true for /usr because many of these files are required for normal system operation. |
| Last Updated on Monday, 14 July 2008 17:25 |



You can reduce file system fragmentation as follows: