3. File System



File System: It is an option in which we can format a disk space, according to the user requirement.
  • The default file system in Solaris is - UFS (Unix File System)
Types of File System:
1. Disk Based File System (ex: UFS)
2. Network Based File System (NFS)
3. Memory Based File System (ex: CACHEFS, TEMPFS, Auto FS)

Flag Status:
1. Write Mount: ex: Disk based FS
2. Write Unmount: ex: Memory based FS
3. Read Mount
4. Read Unmount

Types of Devices:
1. Logical Devices (/dev): This logical device names are for administrative reference and these are symbolically linked with physical devices. All the logical devices are under /dev directory.
2. Physical Devices (/devices): These are for kernel reference and All the physical device names stored under /device directory.

Formates of a disk:
1. rdsk (raw disk): The disk before formatting will be under raw format, identified as "rdsk".
2. dsk (block disk): The disk after formatting, is known as block device, it is identified as "dsk".

commands used to create file system:
1. #format: is command line utility which shows all the available disks in a system.
2. #newfs: is a command line utility which is used to format a disk under "ufs". when you format a disk by using a "newfs" by default on directory will create called "Lost+Found". which contain un saved data, which is used to recover data in next reboot.
3. #mount: mount in the FS means, attaching the file system to a directory under root.
4. #mountall: It is used to mount all the permanent FS. 
5.#umount: unmount the FS
6.#umountall: It is used to umount all the FS except root & root user.
7. /etc/mnttab:  when you create a file system & mount, by default one file get updated automatically, that is /etc/mnttab, the entries in mnttab are temporary.
8. /etc/vfstab: If you want to make it permanent, we have to update a file called /etc/vfstab.
to view the content of the file system "cat /etc/mnttab" use
9. #fsck: (File system check): used to check inconsistency file system (unmounted FS). 
     i. serial checking
     ii. parallel checking

Steps for File System creation:

Solaris1# Format
specify disk (enter its number): 0
Format> p                   // partition
Partition> p                 // print
Partition> 4                 // Select the slice
partition id tag [unassigned]:                        //leave it blank it defaultly take unassigned
partition permission flags [wm]:                   //leave it blank it defaultly take wm
enter starting cylinder number cy[0]: 514
enter partition size: 500m                           //500 MB                               
// The entered information about partition ID, permission flags and partition size will be on the RAM, in order to update to the kernel we need to "label" it.
partition> l                                                // l- label
ready to the label disk, continue? Y           // now it is into the kernal, before it was in RAM
partition> q                    // quit from partition  
format> q                    // quit from format & back to the Solaris1
Solaris1# newfs /dev/rdsk/c0t0d0s4          // to construct new file system
construct new filesystem (y/n)? Y
 Solaris1# df -h (or) df -k                         // to view file system, no slice(s4) visible, bcoz not yet mounted
Solaris1# mkdir /sunny
Solaris1#mount /dev/dsk/c0t0d0s4 /sunny
Solaris1# df -h                                         // to view file system, now slice(s4) visible, bcoz mounted to sunny
Solaris1# cd /sunny
Solaris1# ls                                             //no files created yet
Solaris1#touch 1 2 3                               // create files 1 2 3

note: /etc/mnttab:  when you create a file system & mount, by default one file get updated automatically, that is /etc/mnttab, the entries in mnttab are temporary.
If you want to make it permanent, we have to update a file called /etc/vfstab.
//to view the content of the file system "cat /etc/mnttab" use

Solaris1#cat /etc/mnttab
/dev/dsk/c0t0d0s4          /sunny
Solaris1# umount /sunny                          // to unmount the file system
Solaris1# df -h
now there is no s4 slice mounted
Solaris1# vi /etc/vfsstab                           //vfstab :  virtual file system table
   device                       device to              mount     FS     fsck     mount      mount
  tomount                         fsck                  point      type    pass    at boot     options
------------------------------------------------------------------------------------
/dev/dsk/c0t0d0s4   /dev/rdsk/c0t0d0s4   /sunny    UFS    1       Yes           -

1. device to mount:  It refers to block device
2. device to fsck: file system checking is always done on unmounted FS.
3. mount point: refers to the directory on which the FS is mounted.
4. FS type: default is UFS
5. fsck pass: it is done in two modes i. serial check ii. parallel check
6. mount at boot: it is used to specify whether you want to mount the file system at next reboot or not
7. mount options: '-' it refers to default options. i.e FS permission RW, support the large file.