Contained Within
Find More Documentation
Featured Support Resources
| PDF로 이 문서 다운로드
Creating File Systems
33
- This chapter describes how to create and preserve UFS, temporary, and loopback file systems on hard disks. This is a list of the step-by-step instructions in this chapter.
-
Creating a UFS File System
- You need to create UFS file systems only occasionally, because the system software automatically creates file systems as part of the installation process. You need to create (or re-create) a UFS file system when you:
-
- Add or replace disks
- Change the existing partitioning structure
- Do a full restoration on a file system
- The following procedure uses the newfs command to create UFS file systems. The newfs command is a convenient front-end to the mkfs command, which creates the new file system. On Solaris 2.x systems, newfs parameter defaults,
- such as tracks per cylinder and sectors per track, are read from the disk label that will contain the new file system, and the options you choose are passed to the mkfs command to build the file system.
File System Parameters
- To make a new file system on a disk slice, you almost always use the newfs command. Table 33-1 shows the default parameters the newfs command uses.
-
Table 33-1 newfs
| Parameter | Default Value |
| Block size | 8 Kbytes |
| Fragment size | 1 Kbyte |
| Minimum free space | 10% |
| Rotational delay | Device-dependent |
| Optimization type | Space |
| Number of inodes | 1 for each 2 Kbytes of disk space |
Prerequisites
-
- The disk must be formatted and divided into slices before you can create UFS file systems on it.
- You need to know the raw device file name of the slice that will contain the file system. See Chapter 28, "Administering Disks," for information on finding disks and disk slice numbers.
- If you are re-creating an existing UFS file system, unmount it.
- You must be root.
· How to Create a UFS File System
-
-
Make sure you have met the prerequisites listed on page 548.
-
Create the file system.
-
# newfs [-N] [-b size] [-i bytes] /dev/rdsk/device-name
|
- In this command,
-
| -N | Displays all of the parameters newfs would pass to mkfs. No file system is created. |
| -b size | Sets the file system block size. Default is 8192 blocks. |
| -i bytes | Sets the number of bytes per inode. Default is 2048 bytes. |
| device-name | Is the device that will contain the new file system. |
-
Caution - Be sure you have specified the correct device name for the slice before performing the next step. If you specify the wrong slice, you will erase its contents when the new file system is created.
- The system asks for confirmation.
Verification--Creating a UFS File System
- Check the new file systems with the fsck command.
-
# fsck /dev/rdsk/device-name
|
- In this command,
-
device-name.....Is the name of the device containing the new file system.
- This utility checks the consistency of the new file system, reports problems it finds, and prompts you before repairing the problems. See Chapter 39, "Checking File System Integrity," for more information on fsck.
Example--Creating a UFS File System
- This example creates a file system on /dev/rdsk/c0t3d0s7.
-
# newfs /dev/rdsk/c0t3d0s7
newfs: construct a new file system /dev/rdsk/c0t3d0s7 (y/n)? y
/dev/rdsk/c0t3d0s7: 163944 sectors in 506 cylinders of 9 tracks, 36 sectors
83.9MB in 32 cyl groups (16 c/g, 2.65MB/g, 1216 i/g)
super-block backups (for fsck -b #) at:
32, 5264, 10496, 15728, 20960, 26192, 31424, 36656, 41888,
47120, 52352, 57584, 62816, 68048, 73280, 78512, 82976, 88208,
93440, 98672, 103904, 109136, 114368, 119600, 124832, 130064, 135296,
140528, 145760, 150992, 156224, 161456,
|
Where to Go From Here
-
Creating a Temporary File System (TMPFS)
- The most common use for a TMPFS is the /tmp directory. By default, the /tmp directory for the SunOS system software is a TMPFS, and an entry is provided for it in the default /etc/vfstab file.
- By default, files in TMPFS directories do not survive across reboots or unmounts, including file systems under /var/tmp. Note that the vi -r command expects to find preserved files in the /var/tmp directory after a system is rebooted. You can preserve a TMPFS across reboots or unmounts by adding an entry to the /etc/vfstab file.
- If you create multiple temporary file systems, be aware that they all use the same system resources. Files created under one TMPFS directory use up the space available for any other TMPFS, unless you limit TMPFS sizes using the -o option of the mount command.
· How to Create a Temporary File System
-
-
Become root.
-
If necessary, create the directory where you want to mount the TMPFS and set permissions and ownership as necessary.
-
Create a temporary file system.
-
# mount -F tmpfs swap mount-point
|
- In this command,
-
-
-F tmpfs swap Is a TMPFS file system.
-
mount-point.....Is the directory where the TMPFS file system is mounted.
Verification--Creating a Temporary File System
- To verify that a temporary file system called /visitors has been created and mounted in /usr/tmp, use the mount and ls commands.
-
$ mount
/ on /dev/md/dsk/d0 read/write/setuid on Mon Oct 10 08:36:49 1994
/usr on /dev/md/dsk/d1 read/write/setuid on Mon Oct 10 08:36:49 1994
/proc on /proc read/write/setuid on Mon Oct 10 08:36:49 1994
/dev/fd/ on fd read/write/setuid on Mon Oct 10 08:36:49 1994
/var on /dev/md/dsk/d2 read/write/setuid on Mon Oct 10 08:36:49 1994
/tmp on swap read/write/setuid on Mon Oct 10 08:36:49 1994
/opt on /dev/md/dsk/d3
/scratch on /dev/rdsk/c0t3d0s7 read/write/setuid on Mon Oct 10 08:36:49 1994
/var/spool/news on /dev/dsk/c2t1d0s2 read/write/setuid on Mon Oct 10 08:36:49 1994
/home/ganymede on site:/export/home/ganymede read/write/remote on Mon Oct 10 08:36:49 1994
/visitors on /usr/tmp on Mon Oct 10 08:36:49 1994
$ ls /usr/tmp
NTa0006h ps_data visitors
|
Example--Creating a Temporary File System
- This example creates a new directory, /export/reports, and mounts a temporary file system at that point.
-
# mkdir /export/reports
# chmod 777 /export/reports
# mount -F tmpfs swap /export/reports
|
- See the tmpfs(7FS)manual page for more information.
· How to Preserve a Temporary File System
- You can preserve a TMPFS across reboots or unmounts by adding an entry to the /etc/vfstab file. Edit the file to add an entry like this, separating each field with a Tab:
-
swap - mount-point tmpfs - yes -
|
- In this command,
-
mount-point.....Is the default mount point directory.
- For more information about editing the /etc/vfstab file, see Chapter 34, "Mounting and Unmounting File Systems.
Creating a Loopback File System (LOFS)
- A LOFS is a virtual file system which provides an alternate path to an existing file system. When other file systems are mounted onto a loopback file system, the original file system does not change.
- You can preserve a LOFS across reboots or unmounts by adding an entry to the /etc/vfstab file.
-
Caution - Be careful when creating loopback mounts. Because these are virtual file systems, the potential for confusing both users and applications is enormous.
· How to Create a Loopback File System
-
-
Become root.
-
Create the directory where you want to mount the loopback file system and give it the appropriate permissions and ownership.
-
-
Create a loopback file system.
-
# mount -F lofs lo-directory mount-point
|
- In this command,
-
| lo-directory | Is the file system to be mounted at the loopback mount point. |
| mount-point | Is the directory where the LOFS is mounted. |
Example--Creating a Loopback File System
- This example shows how to use a new loopback file system with the chroot command to provide a complete virtual file system view to a process or family of processes:
-
# mount -F lofs / /tmp/newroot
# chroot /tmp/newroot command
|
- See lofs(7FS) or mount(1M) for more information.
· How to Preserve a Loopback File System
- You can preserve a loopback file system across reboots or unmounts by adding an entry to the /etc/vfstab file. Edit the file to add an entry like this at the end of the file, separating each field with a tab.
-
/ - mount-point lofs - yes -
|
- In this command,
-
mount-point.....Is the default mount point directory (for example, /tmp/newroot).
-
Caution - Make sure the loopback entry is the last entry in the /etc/vfstab file. Otherwise, if the /etc/vfstab entry for the loopback file system precedes the file systems to be included in it, the loopback file system cannot be created.
- For more information about the /etc/vfstab file, refer to Chapter 34, "Mounting and Unmounting File Systems."
|
|