Szukaj na tym blogu

poniedziałek, 20 czerwca 2011

In this post I will to demonstrate file system administration on RHEL5 and SOLARIS10.
Post will cover the following topics :
- EXT2/EXT3 file system attributes
- ACL in RHEL and SOLARIS
- SUDO
- SU
- UFS file system in SOLARIS10


EXT2/EXT3 file system attributes

Filesystem attributes can help you control what anyone can do with different files. The key commands in this area are lsattr and chattr. The use I'm most familiar with protects a file from deletion, even by the root user. For example, you could protect /etc/inittab from tinkering by other administrators with the following command:
# chattr +i /etc/inittab

Then when I try to delete the file, I get the following result:
# rm /etc/inittab
rm: remove write-protected regular file '/etc/inittab'? y
rm: cannot remove '/etc/inittab': Operation not permitted


This adds the immutable attribute to /etc/inittab:
# lsattr /etc/inittab
----i-------- /etc/inittab

Attribute
Description
append only (a)
Prevents deletion, but allows appending to a file-for example, if you've run chatter +a tester, cat /etc/fstab >> tester would add the contents of /etc/fstab to the end of the tester file.
no dump (d)
Does not allow backups of the configured file with the dump command.
immutable (i)
Prevents deletion or any other kind of change to a file.


ACL in RHEL and SOLARIS

ACL (Access Control List) is in a context of file systems a mechanism to control access to files and directories. This mechanism appears in SOL10 as well as in RHEL5 but there is a slight difference in implementation. In SOL10 it is available by default, sys admin doesn't have to do any additional tasks in order to enable this feature but in RHEL5, file system with ACL capability must be mounted with that feature so it is not available by default after clean oes installation.


RHEL5
In RHEL5 a ext3/4 file system allows you to use this feature when you mount it with acl option e.g. :
# mount -t ext4 -o acl,defaults /dev/sda3 /mnt
If you're just testing a system for ACL, you can remount an existing partition appropriately :
# mount -o remount -o acl /dev/sda3 /home

1. Read ACL :
# getfacl /home/donna/abc
# file: home/donna/abc
# owner: donna
# group: donna
user::rw-
group::rw-
other::r--

2. Set ACL :
# setfacl -m user:michael:r-x /home/donna
# setfacl -m mask:r-x /home/donna



SOL10
Commands are the same for RHEl and SOL :
- getfacl
- setfacl

We have here trivial and non-trivial ACL. Trivial is the standard permission set and can be read with ls command but non-trivial can only be read with getfacl cmd and when is also described + sign when you perform ls -la.
1. Read trivial ACL for all files and dirs:
$ ls -la
drwxr-xr-x  4 jakubn   other        512 cz 20 14:52 .
drwxr-xr-x  5 root     root         512 cz 20 14:45 ..
-rw-r--r--  1 jakubn   other         20 cz  9 22:11 .exrc
-rwxr--r--  1 jakubn   other        648 cz 18 21:59 .kshrc
-rw-r--r--  1 jakubn   other         51 cz  9 22:15 .profile
-rw-------  1 jakubn   other       5654 cz 20 16:20 .sh_history
-------r--  1 jakubn   other          0 cz 20 14:52 file1.txt
drwxr-xr-x+  2 jakubn   other        512 cz 18 21:32 lilo
drwx------  2 root     root         512 lut 10 01:22 lost+found

2. Read trivial ACL for a particular file/dir:
jakubn@solaris10 /export/home/jakubn $getfacl -a file1.txt
# file: file1.txt
# owner: jakubn
# group: other
user::---
group::---              #effective:---
mask:---
other:r--

3. Read non-trivial ACL :
$ ls -la lilo
drwxr-xr-x+  2 jakubn other 512 cz 18 21:32 lilo

Please observe additional + sign in output from ls cmd, this means that this file posses non-trivial ACL.

jakubn@solaris10 /export/home/jakubn $getfacl lilo
# file: lilo
# owner: jakubn
# group: other
user::rwx
user:wawer:rwx          #effective:r-x
group::r-x              #effective:r-x
mask:r-x
other:r-x

4. Set non-trivial ACL for user "pioko"
$ setfacl -m user:pioko:rw- file2.txt

5. Substitute ACL for file2.txt
setfacl -s u::rwx,g::rw-,o::r--,m::rw-,u:usera:rwx file2.txt

6. Change effective mask for all users in ACL :
$ getfacl file2
# file: file2
# owner: userc
# group: sysadmin
user::rw-
user:usera:rwx          #effective:r--
user:userb:rwx          #effective:r--
group::r--              #effective:r--
mask:r--
other:r--

$setfacl -m m:rwx file2
$getfacl file2

# file: file2
# owner: userc
# group: sysadmin
user::rw-
user:usera:rwx          #effective:rwx
user:userb:rwx          #effective:rwx
group::r--              #effective:rwx
mask:rwx
other:r--

7. Recalculating ACL mask :

$ getfacl file1

# file: file1
# owner: userc
# group: sysadmin
user::rwx
user:usera:rwx          #effective:rw-
group::rw-              #effective:rw-
mask:rw-
other:r--
$ setfacl -r -m u:usera:7 file1
$ getfacl file1

# file: file1
# owner: userc
# group: sysadmin
user::rwx
user:usera:rwx          #effective:rwx
group::rw-              #effective:rw-
mask:rwx
other:r--
The file owner and other permissions are not considered when recalculating the ACL mask.

8. Using chmod cmd on a file that already has ACL to recalculate mask :
$ getfacl testfile
# file: testfile
# owner: user1
# group: staff
user::rw-
user:user2:rw-           #effective:r--
group::r--              #effective:r--
mask:r--
other:r--
$ chmod 664 testfile
$ getfacl testfile

# file: testfile
# owner: user1
# group: staff
user::rw-
user:user2:rw-          #effective:rw-
group::rw-              #effective:rw-
mask:rw-


SUDO

SUDO (superuser do) is a mechanism to give permissions for certain users, groups to allow them access to files and dirs.
In Solaris we use ACL and RBAC mechanism instead of sudo but on Linux it is widely used.

Whole configuration is in /etc/sudoers file and can be done by using :
- # visudo
- # vi /etc/sudoers
It is highly recommended to use visudo cmd instead of standard vi.

SYNTAX
user1 host=(user2) program

user1 can execute on host computer, application named program with rights of user2.

Usage Scenarios :
root ALL=(ALL) ALL
Allows root user to execute by using sudo all programs on the machine

user2 ALL = ALL, !/usr/bin/passwd root
Allows user2 to execute all programs on the machine by using sudo without changing password for root user.

user3 ALL = NOPASSWD: /usr/bin/crontab, PASSWD: /usr/bin/procmail, /usr/bin/lpr
Allows user3 to to run crontab without password and procmail and lpr with typing password.

%users ALL = NOPASSWD: /usr/bin/passwd, !/usr/bin/passwd root
Allows members of users group to use passwd cmd by using sudo utility without password and not using passwd cmd to change password for the root user.

user7 localhost=(root) /sbin/ifconfig
Allows user7 to run ifconfig cmd with root permissions.

sudo -l
Displays how sudo is configured for user who executes this command.


SU

SU (switch user OR superuser) allows you to change user identity on unix system whether on different user or rootuser.

SYNTAX
su [OPTION]... [-] [USER [ARG]...]

Usage scenarios
su -
Switch to root user with environment vars.

su -c 'fdisk -l'
Run command fdisk -l with root user rghts.

su - jakubn
Switch to user jakubn with env vars. When you are logged in as root and want to change identity to any other user with this command, you don't have to type this user's password otherwise you have to.

su
Switch to root account without env vars.

id
Displays current identity of user you are using now.

who am i
Displays first identity user had when first logged in.

IMPORTANT !!!
Newer do the following sequence of identity changes steps:
1. logs in as normal user
2. change identity to root su -
3. change identity to some other user
4. leave terminal for some user to use
When you do this sequence and some user from step 4, types exit it gets access to root account.



UFS file system in SOLARIS10

- Adding new disk
- Displaying devices
- Create new file system
- Check file system
- Mount fs
- Unmounts fs
- VOLD Volume Management Daemon


Adding new disk into SOLARIS10
There are 3 ways you can add new disk (any hardware) in SOLARIS10 :
1. reconfiguration boot
2. manual reconfiguration boot from ok> prompt
3. devfsadm command

reconfiguration boot
- # touch /reconfigure
- # init 5

- install peripheral device
- turn on the power
- verify peripheral device have been added with prtconf cmd.

manual reconfiguration boot from ok> prompt
- ok> boot -r

devfsadm command
- devfsadm -c disk

SYNTAX :
----------
devfsadm -c class ---> configure devices of class
devfsadm -i driver name ---> configure only devices for a named driver

Usage scenario :
------------------
devfsadm -c disk
devfsadm -c tape
devfsadm -c audio
devfsadm -i dad
devfsadm -i sd
devfsadm -v ---> displays verbose output of changes
devfsadm -C ---> cleans up unreferenced symbolic links for devices


Displaying devices in SOLARIS10
There are 3 ways to display actually available devices in SOLARIS10 :
- /etc/path_to_inst
- prtconf command
- format command

/etc/path_to_inst
For each device system records its physical name and instance name in this file. There names are used by the kernel to identify every possible device. This file is used at boot time.
It is maintained by the kernel and is not advisable to edit is manually by system admin.
# cat /etc/path_to_inst
#
#       Caution! This file contains critical kernel state
#
"/iscsi" 0 "iscsi"
"/pseudo" 0 "pseudo"
"/options" 0 "options"
"/xsvc" 0 "xsvc"
"/objmgr" 0 "objmgr"
"/scsi_vhci" 0 "scsi_vhci"
"/isa" 0 "isa"
"/isa/i8042@1,60" 0 "i8042"
"/isa/i8042@1,60/keyboard@0" 0 "kb8042"
"/isa/i8042@1,60/mouse@1" 0 "mouse8042"
"/isa/lp@1,378" 0 "ecpp"
"/ramdisk" 0 "ramdisk"
"/cpus" 0 "cpunex"
"/cpus/cpu@0" 0 "cpudrv"
"/pci@0,0" 0 "pci"
"/pci@0,0/display@2" 0 "vgatext"
"/pci@0,0/pci106b,3f@6" 0 "ohci"
"/pci@0,0/pci106b,3f@6/input@1" 0 "hid"
"/pci@0,0/pci8086,1e@3" 0 "e1000g"
"/pci@0,0/pci8086,2829@d" 0 "ahci"
"/pci@0,0/pci8086,2829@d/disk@0,0" 0 "sd"
"/pci@0,0/pci8086,2829@d/cdrom@1,0" 1 "sd"
"/pci@0,0/pci8086,1e@8" 1 "e1000g"
"/agpgart" 0 "agpgart"

prtconf command
Displays current memory installed and peripherals.
# prtconf | grep -v not
System Configuration: Sun Microsystems i86pc
Memory size: 1024 Megabytes
System Peripherals (Software Nodes):

i86pc
scsi_vhci, instance #0
isa, instance #0
i8042, instance #0
keyboard, instance #0
mouse, instance #0
lp, instance #0
pci, instance #0
display, instance #0
pci8086,1e, instance #0
pci106b,3f, instance #0
input, instance #0
pci8086,1e, instance #1
pci8086,2829, instance #0
disk, instance #0
cdrom, instance #1
iscsi, instance #0
pseudo, instance #0
agpgart, instance #0
options, instance #0
objmgr, instance #0
xsvc, instance #0
cpus, instance #0


format command
Displays current disk installed and allows to initialize disk with VTOC table.
WARNING !!!
There are two ways to partition an entire disk. The first is to calculate by hand the cylinder offsets of each partition. This can lead to overlapping filesystems which will corrupt data. The "All Free Hog" option enables partitioning of a disk by size (b, kb, mb, gb) and the utility calculates the required cylinder offsets.
# format
Searching for disks...done

AVAILABLE DISK SELECTIONS:
0. c0t0d0
/pci@0,0/pci8086,2829@d/disk@0,0
Specify disk (enter its number): 0
selecting c0t0d0
[disk formatted]
Warning: Current Disk has mounted partitions.
/dev/dsk/c0t0d0s0 is currently mounted on /. Please see umount(1M).
/dev/dsk/c0t0d0s1 is currently used by swap. Please see swap(1M).
/dev/dsk/c0t0d0s7 is currently mounted on /export/home. Please see umount(1M).


FORMAT MENU:
disk - select a disk
type - select (define) a disk type
partition - select (define) a partition table
current - describe the current disk
format - format and analyze the disk
fdisk - run the fdisk program
repair - repair a defective sector
label - write label to the disk
analyze - surface analysis
defect - defect list management
backup - search for backup labels
verify - read and display labels
save - save new disk/partition definitions
inquiry - show vendor, product and revision
volname - set 8-character volume name
! - execute , then return
quit
format>

Run fdisk command within format utility to label VTOC table.
fdisk

Create new UFS file system

1. Write defualt VTOC to label the disk.
format> fdisk
No fdisk table exists. The default partition for the disk is:

  a 100% "SOLARIS System" partition

Type "y" to accept the default partition,  otherwise type "n" to edit the
 partition table.
y

2. Divide disk into slices
# format
Searching for disks...done


AVAILABLE DISK SELECTIONS:
       0. c0t0d0 
          /pci@0,0/pci8086,2829@d/disk@0,0
       1. c0t2d0 
          /pci@0,0/pci8086,2829@d/disk@2,0
Specify disk (enter its number): 1
selecting c0t2d0
[disk formatted]


FORMAT MENU:
        disk       - select a disk
        type       - select (define) a disk type
        partition  - select (define) a partition table
        current    - describe the current disk
        format     - format and analyze the disk
        fdisk      - run the fdisk program
        repair     - repair a defective sector
        label      - write label to the disk
        analyze    - surface analysis
        defect     - defect list management
        backup     - search for backup labels
        verify     - read and display labels
        save       - save new disk/partition definitions
        inquiry    - show vendor, product and revision
        volname    - set 8-character volume name
        !     - execute , then return
        quit
format> partition


PARTITION MENU:
        0      - change `0' partition
        1      - change `1' partition
        2      - change `2' partition
        3      - change `3' partition
        4      - change `4' partition
        5      - change `5' partition
        6      - change `6' partition
        7      - change `7' partition
        select - select a predefined table
        modify - modify a predefined partition table
        name   - name the current table
        print  - display the current table
        label  - write partition map and label to the disk
        ! - execute , then return
        quit
partition> modify
Select partitioning base:
        0. Current partition table (original)
        1. All Free Hog
Choose base (enter number) [0]? 0

Part      Tag    Flag     Cylinders        Size            Blocks
  0 unassigned    wm       0               0         (0/0/0)          0
  1 unassigned    wm       0               0         (0/0/0)          0
  2     backup    wu       0 - 1019        1.99GB    (1020/0/0) 4177920
  3 unassigned    wm       0               0         (0/0/0)          0
  4 unassigned    wm       0               0         (0/0/0)          0
  5 unassigned    wm       0               0         (0/0/0)          0
  6 unassigned    wm       0               0         (0/0/0)          0
  7 unassigned    wm       0               0         (0/0/0)          0
  8       boot    wu       0 -    0        2.00MB    (1/0/0)       4096
  9 unassigned    wm       0               0         (0/0/0)          0

Do you wish to continue creating a new partition
table based on above table[yes]?
Free Hog partition[6]? ^C
partition>
partition> modify
Select partitioning base:
        0. Current partition table (original)
        1. All Free Hog
Choose base (enter number) [0]? 1

Part      Tag    Flag     Cylinders        Size            Blocks
  0       root    wm       0               0         (0/0/0)          0
  1       swap    wu       0               0         (0/0/0)          0
  2     backup    wu       0 - 1019        1.99GB    (1020/0/0) 4177920
  3 unassigned    wm       0               0         (0/0/0)          0
  4 unassigned    wm       0               0         (0/0/0)          0
  5 unassigned    wm       0               0         (0/0/0)          0
  6        usr    wm       0               0         (0/0/0)          0
  7 unassigned    wm       0               0         (0/0/0)          0
  8       boot    wu       0 -    0        2.00MB    (1/0/0)       4096
  9 alternates    wm       0               0         (0/0/0)          0

Do you wish to continue creating a new partition
table based on above table[yes]?
Free Hog partition[6]?
Enter size of partition '0' [0b, 0c, 0.00mb, 0.00gb]: ?
Expecting up to 4173824 blocks, 1019 cylinders,  2038.00 megabytes, or 1.99 gigabytes
Enter size of partition '0' [0b, 0c, 0.00mb, 0.00gb]: 1.99gb
Warning: no space available for '1' from Free Hog partition
Warning: no space available for '3' from Free Hog partition
Warning: no space available for '4' from Free Hog partition
Warning: no space available for '5' from Free Hog partition
Warning: no space available for '7' from Free Hog partition

Part      Tag    Flag     Cylinders        Size            Blocks
  0       root    wm       1 - 1019        1.99GB    (1019/0/0) 4173824
  1       swap    wu       0               0         (0/0/0)          0
  2     backup    wu       0 - 1019        1.99GB    (1020/0/0) 4177920
  3 unassigned    wm       0               0         (0/0/0)          0
  4 unassigned    wm       0               0         (0/0/0)          0
  5 unassigned    wm       0               0         (0/0/0)          0
  6        usr    wm       0               0         (0/0/0)          0
  7 unassigned    wm       0               0         (0/0/0)          0
  8       boot    wu       0 -    0        2.00MB    (1/0/0)       4096
  9 alternates    wm       0               0         (0/0/0)          0

Okay to make this the current partition table[yes]?
Enter table name (remember quotes): var file system

Ready to label disk, continue?
Ready to label disk, continue? yes
partition> ?
Expecting one of the following: (abbreviations ok):
        0      - change `0' partition
        1      - change `1' partition
        2      - change `2' partition
        3      - change `3' partition
        4      - change `4' partition
        5      - change `5' partition
        6      - change `6' partition
        7      - change `7' partition
        select - select a predefined table
        modify - modify a predefined partition table
        name   - name the current table
        print  - display the current table
        label  - write partition map and label to the disk
        ! - execute , then return
        quit

partition> print
Current partition table (var):
Total disk cylinders available: 1020 + 2 (reserved cylinders)

Part      Tag    Flag     Cylinders        Size            Blocks
  0 unassigned    wm       1 - 1019        1.99GB    (1019/0/0) 4173824
  1 unassigned    wm       0               0         (0/0/0)          0
  2     backup    wu       0 - 1019        1.99GB    (1020/0/0) 4177920
  3 unassigned    wm       0               0         (0/0/0)          0
  4 unassigned    wm       0               0         (0/0/0)          0
  5 unassigned    wm       0               0         (0/0/0)          0
  6 unassigned    wm       0               0         (0/0/0)          0
  7 unassigned    wm       0               0         (0/0/0)          0
  8       boot    wu       0 -    0        2.00MB    (1/0/0)       4096
  9 unassigned    wm       0               0         (0/0/0)          0

partition> 0
Part      Tag    Flag     Cylinders        Size            Blocks
  0 unassigned    wm       1 - 1019        1.99GB    (1019/0/0) 4173824

Enter partition id tag[unassigned]: ?
Expecting one of the following: (abbreviations ok):
        unassigned    boot          root          swap
        usr           backup        stand         var
        home          alternates    reserved

Enter partition id tag[unassigned]: var
Enter partition permission flags[wm]: wm
Enter new starting cyl[1]: ?
Expecting an integer from 0 to 1019
Enter new starting cyl[1]:
Enter partition size[4173824b, 1019c, 1019e, 2038.00mb, 1.99gb]: 1.99gb
partition> print
Current partition table (unnamed):
Total disk cylinders available: 1020 + 2 (reserved cylinders)

Part      Tag    Flag     Cylinders        Size            Blocks
  0        var    wm       1 - 1019        1.99GB    (1019/0/0) 4173824
  1 unassigned    wm       0               0         (0/0/0)          0
  2     backup    wu       0 - 1019        1.99GB    (1020/0/0) 4177920
  3 unassigned    wm       0               0         (0/0/0)          0
  4 unassigned    wm       0               0         (0/0/0)          0
  5 unassigned    wm       0               0         (0/0/0)          0
  6 unassigned    wm       0               0         (0/0/0)          0
  7 unassigned    wm       0               0         (0/0/0)          0
  8       boot    wu       0 -    0        2.00MB    (1/0/0)       4096
  9 unassigned    wm       0               0         (0/0/0)          0

partition>label
Ready to label disk, continue? yes

partition> quit


FORMAT MENU:
        disk       - select a disk
        type       - select (define) a disk type
        partition  - select (define) a partition table
        current    - describe the current disk
        format     - format and analyze the disk
        fdisk      - run the fdisk program
        repair     - repair a defective sector
        label      - write label to the disk
        analyze    - surface analysis
        defect     - defect list management
        backup     - search for backup labels
        verify     - read and display labels
        save       - save new disk/partition definitions
        inquiry    - show vendor, product and revision
        volname    - set 8-character volume name
        !     - execute , then return
        quit
format> quit


3. Create file system on device
# newfs /dev/rdsk/c0t2d0s0
newfs: construct a new file system /dev/rdsk/c0t2d0s0: (y/n)? y
/dev/rdsk/c0t2d0s0:     4173824 sectors in 1019 cylinders of 128 tracks, 32 sectors
        2038,0MB in 45 cyl groups (23 c/g, 46,00MB/g, 11264 i/g)
super-block backups (for fsck -F ufs -o b=#) at:
 32, 94272, 188512, 282752, 376992, 471232, 565472, 659712, 753952, 848192,
 3298432, 3392672, 3486912, 3581152, 3675392, 3769632, 3863872, 3958112,
 4052352, 4146592
The first line describes basic disk geometry, the second ufs fs created on the slice. The third and remaining lines is the beginning sector location of the backup superblock.


The newfs cmd reserves between 1-10% of disk space for maintenance. It is called minfree.
# fstyp -v  /dev/rdsk/c0t2d0s0 | f^[^[[3~
f^[^[[3~: not found
#
# Broken Pipe
Unknown_fstyp (no matches)

# fstyp -v  /dev/rdsk/c0t2d0s0 | head
ufs
magic   11954   format  dynamic time    Wed Jun 29 15:35:52 2011
sblkno  16      cblkno  24      iblkno  32      dblkno  1440
sbsize  2048    cgsize  8192    cgoffset 16     cgmask  0xffffff80
ncg     45      size    2086912 blocks  2022815
bsize   8192    shift   13      mask    0xffffe000
fsize   1024    shift   10      mask    0xfffffc00
frag    8       shift   3       fsbtodb 1
minfree 3%      maxbpg  2048    optim   time
maxcontig 128   rotdelay 0ms    rps     546
# Broken Pipe
Unknown_fstyp (no matches)

This minfree value can be changed in 2 ways :
- recreating fs type
- redefining minfree on already created fs

recreating fs type
# newfs -m 1 /dev/rdsk/c0t2d0s0
newfs: construct a new file system /dev/rdsk/c0t2d0s0: (y/n)? y
/dev/rdsk/c0t2d0s0:     4173824 sectors in 1019 cylinders of 128 tracks, 32 sectors
        2038,0MB in 45 cyl groups (23 c/g, 46,00MB/g, 11264 i/g)
super-block backups (for fsck -F ufs -o b=#) at:
 32, 94272, 188512, 282752, 376992, 471232, 565472, 659712, 753952, 848192,
 3298432, 3392672, 3486912, 3581152, 3675392, 3769632, 3863872, 3958112,
 4052352, 4146592
#
#
# fstyp -v  /dev/rdsk/c0t2d0s0 | head
ufs
magic   11954   format  dynamic time    Wed Jun 29 16:03:38 2011
sblkno  16      cblkno  24      iblkno  32      dblkno  1440
sbsize  2048    cgsize  8192    cgoffset 16     cgmask  0xffffff80
ncg     45      size    2086912 blocks  2022815
bsize   8192    shift   13      mask    0xffffe000
fsize   1024    shift   10      mask    0xfffffc00
frag    8       shift   3       fsbtodb 1
minfree 1%      maxbpg  2048    optim   time
maxcontig 128   rotdelay 0ms    rps     546
# Broken Pipe
Unknown_fstyp (no matches)

redefining minfree on already created fs
tunefs -m 1 /dev/rdsk/c0t2d0s0


Check the file system
File system check program fsck check fs for data consistency and attempt to correct or repair any inconsistencies or damaged found. Every time systems boot up, it determines which fs should fsck check. The fsck comd checks and repairs any problems encountered in fs before they are mounted.
IMPORTANT !!!
Newver run fsck on mounted file system. The /, /usr, /var fs should have run fsck while in single-user mode.

Any unreferenced inode with a non zero link count is linked to the file system's lost+found directory.

The fsck program has 2 modes of operation :
- noninteractive
- intercative

fsck noninteractive mode
- Operates this mode only during boot of SOL10.
- addresses only minor inconsistency problems
- if more serious problem is found and decision has to be made, fsck terminates and request root passwd to enter single-user mode

fsck noninteractive mode
- lists each problem it encounters followed by a suggetsion what to do

SYNTAX :
--------
fsck

Usage scenario
----------------
fsck /dev/rdsk/c0t0d0s0
To check single unmounted fs.

fsck /export/home
To check fs typing mount point (from /etc/vfstab)

# fsck -o f,p /dev/rdsk/c0t0d0s7
/dev/rdsk/c0t0d0s7: 77 files, 9621 used, 46089 free
/dev/rdsk/c0t0d0s7: (4 frags, 57 blocks, 0.0% fragmentation)
The f option of the fsck command forces a file system check, regardless of the state of the file system's superblock state flag.

The p option checks and fixes the file system noninteractively (preen). The program exits immediately if a problem requiring intervention is found.

# newfs -N /dev/rdsk/c0t2d0s0
/dev/rdsk/c0t2d0s0:     4173824 sectors in 1019 cylinders of 128 tracks, 32 sectors
        2038,0MB in 45 cyl groups (23 c/g, 46,00MB/g, 11264 i/g)
super-block backups (for fsck -F ufs -o b=#) at:
 32, 94272, 188512, 282752, 376992, 471232, 565472, 659712, 753952, 848192,
 3298432, 3392672, 3486912, 3581152, 3675392, 3769632, 3863872, 3958112,
 4052352, 4146592
List alternative backup superblock locations in file system

# fsck -o b=32 /dev/rdsk/c0t2d0s0
Alternate super block location: 32.
** /dev/rdsk/c0t2d0s0
** Last Mounted on
** Phase 1 - Check Blocks and Sizes
** Phase 2 - Check Pathnames
** Phase 3a - Check Connectivity
** Phase 3b - Verify Shadows/ACLs
** Phase 4 - Check Reference Counts
** Phase 5 - Check Cylinder Groups

UPDATE STANDARD SUPERBLOCK? y

2 files, 9 used, 2022806 free (14 frags, 252849 blocks, 0.0% fragmentation)

***** FILE SYSTEM WAS MODIFIED *****
Recover superblock from backup superblock



Mount fs
File system have 3 different meanings in unix world :
- as a FS type
- as a slice/partition on the disk
- as mount point in directory tree

In order to mount fs there are 2 ways :
- to mount at boot by editing the /etc/vfstab file
- to mount manually by using the mount cmd

Structure of /etc/vfstab file.
# cat /etc/vfstab
#device         device          mount           FS      fsck    mount   mount
#to mount       to fsck         point           type    pass    at boot options
#
fd      -       /dev/fd fd      -       no      -
/proc   -       /proc   proc    -       no      -
/dev/dsk/c0t0d0s1       -       -       swap    -       no      -
/dev/dsk/c0t0d0s0       /dev/rdsk/c0t0d0s0      /       ufs     1       no      -
/dev/dsk/c0t0d0s7       /dev/rdsk/c0t0d0s7      /export/home    ufs     2       yes     -
/devices        -       /devices        devfs   -       no      -
sharefs -       /etc/dfs/sharetab       sharefs -       no      -
ctfs    -       /system/contract        ctfs    -       no      -
objfs   -       /system/object  objfs   -       no      -
swap    -       /tmp    tmpfs   -       yes     -

Column definitions :
------------------------------
- device to mount (device to be mounted)

- device to fsck (device character or raw to be check by fsck utility, pseudo fs have - in this field)

- mount point (the name of the dir that serves as attach point in SOLARIS10 directory tree
)
- FS type (type of fs to be mounted)

- fsck pass (is used by the fsck whether to check fs, when this field contains -, the fs isn't checked. WHen contain 0, UFS fs are not checked however non UFS fs are checked. When contains value >0 fs is always checked.
All fs with a value of 1 are checked one at a time in the order they appear in /etc/vfstab file.
When the fsck cmd is run on multiple UFS fs that have this field >1 and preen option -o p is used, the fsck automatically checks the fs on different disks in parallel to max efficiency . Otherwise the value of this field doesn't have any affect.)

- mount at boot (if yes, you enable mountall cmd at boot to mount file systems.)

- mount options (a coma separated list of options for the mount cmd. A dash indicates use of default options)

IMPORTANT !!!
For /, /usr, /var (if it is separate fs) the mount at boot field is specified as no.
The kernel mounts theses fs as part of boot sequence before the mountall cmd is run.


Structure of /etc/mnttab file.
# cat /etc/mnttab
/dev/dsk/c0t0d0s0       /       ufs     rw,intr,largefiles,logging,xattr,onerror=panic,dev=780000       1309376599
/devices        /devices        devfs   dev=4840000     1309376558
ctfs    /system/contract        ctfs    dev=48c0001     1309376558
proc    /proc   proc    dev=4880000     1309376558
mnttab  /etc/mnttab     mntfs   dev=4900001     1309376558
swap    /etc/svc/volatile       tmpfs   xattr,dev=4940001       1309376558
objfs   /system/object  objfs   dev=4980001     1309376558
sharefs /etc/dfs/sharetab       sharefs dev=49c0001     1309376558
/usr/lib/libc/libc_hwcap1.so.1  /lib/libc.so.1  lofs    dev=780000      1309376582
fd      /dev/fd fd      rw,dev=4b40001  1309376599
swap    /tmp    tmpfs   xattr,dev=4940002       1309376602
swap    /var/run        tmpfs   xattr,dev=4940003       1309376602
/dev/dsk/c0t0d0s7       /export/home    ufs     rw,intr,largefiles,logging,xattr,onerror=panic,dev=780007       1309376634
-hosts  /net    autofs  nosuid,indirect,ignore,nobrowse,dev=4c00001     1309376644
auto_home       /home   autofs  indirect,ignore,nobrowse,dev=4c00002    1309376644
The /etc/mnttab contains read-only info from the kernel about currently mounted fs on the local host.

Mount cmd

SYNTAX :
----------
mount -o options device mount_point

The Default Options For the mount Command
Option Description

read/write


Indicates whether reads and writes are allowed on the file system.


setuid


Permits the execution of setuid programs in the file system.


intr/nointr


Allows and forbids keyboard interrupts to kill a process that is waiting for an operation on a locked file system.


logging


Indicates that logging is enabled for the ufs file system. This is the default for the Solaris 10 OS.


largefiles


Allows for the creation of files larger than 2 Gbytes. A file system mounted with this option can contain files larger than 2 Gbytes.


xattr


Supports extended attributes not found in standard UNIX attributes.

IMPORTANT !!!
Due to file system overhead, the largest file size that can be created is approximately 1 Tbyte. The data capacity of a 1 Tbyte file system is approximately 1 Tbyte minus 0.5% overhead and the recommended 1% free space.



onerror=action


Specifies the action that the ufs file system should take to recover from an internal inconsistency on a file system. An action can be specified as:


panic
Causes a forced system shutdown. This is the default.

lock

Applies a file system lock to the file system.


umount

Forcibly unmounts the file system.


Usage scenario :
-------------------
# mount /dev/dsk/c0t2d0s0 /export/home
Mount device with default options : read/write,setuid,intr,logging,largefiles,xattr,onerror

# mount -o ro,nosuid /dev/dsk/c0t2d0s0 /export/home
Mount device with multiple mount options.

# mount -o nolargefiles /dev/dsk/c0t2d0s0 /export/home
IMPORTANT !!!
Use of the nolargefiles option fails if the file system to be mounted contains a large file or did contain a large file at one time.
If the file system currently contains a large file and the root user needs to mount it with this option, then the large file must be located and moved or removed from the file system. Then you must execute the fsck command manually to update the superblock information.
The mount also fails if the file system at one time contained a large file, even though it was moved or removed. You must execute the fsck command to clear the old information and allow the file system to be mounted.

# mountall
Mount all fs listed in /etc/vfstab file which has mount at boot option yes.


mountall -l
Mount all local fs listed in /etc/vfstab file.

IMPORTANT !!!
By default mount cmd assumes you always mount UFS fs type. When you want to mount different type you have to use mount -F fs type syntax. FS type must exist in one of 3 files : /etc/vfstab, /etc/default/fs, /etc/dfs/fstypes.

The default local file system type is specified in the /etc/default/fs file by the line entry LOCAL=fstype.

LOCAL=ufs

The first line entry in the /etc/dfs/fstypes file determines the default remote file system type.

nfs NFS Utilities
autofs AUTOFS Utilities
cachefs CACHEFS Utilities

# fstype /dev/rdsk/c0t2d0s0
ufs

Determine defualt fs type on particular device.

# mount -F hsfs -o ro /dev/dsk/c0t6d0s0 /cdrom
Mount CD-ROM when vold daemon is stopped.

# mount -F pcfs /dev/diskette /pcfs
MOunt fs from diskette.



Unmounts fs
Fs must be unmounted when it needs to be backedup or checked for inconsistency by fsck.

SYTNAX :
--------
umount device / mount_point


Usage scenario :
-----------------
# umount /dev/dsk/c0t2d0s0
Unmounts fs.

# unmountall
Unmounts all fs from /etc/mnttab file.

umount -l
Unmounts only local fs.
IMPORTANT !!!
The /etc/mnttab file is read by the /usr/sbin/umountall command during the system shutdown sequence or when umountall is invoked from the command line. The umountall unmounts all file systems specified in the vfstab file except / (root), /usr, /proc, /dev/fd, /var, /var/run, and /tmp.

# fuser -cu /export/home
List all the PID that are accessing the fs.

# fuser -ck /export/home
Kill all PID that are accessing the fs, needed when trying to unmount fs but it displays message that is busy.

# umount -f /export/home
Force to unmount fs.
IMPORTANT !!!
The file system is unmounted even if it contains open files. A forced unmount can result in loss of data and in zombie processes that are left running on the system. However, it is particularly useful for unmounting a shared file system if the remote file server is nonfunctional.



VOLD Volume Management Daemon
It is service that allows you to automatically mount cd/dvd, diskette into SOL10.
Volume Management (vold) features automatic detection of CD-ROMs. However, it does not detect the presence of a diskette that has been inserted in the drive until the volcheck command is run. This command instructs the vold daemon to check the diskette drive for any inserted media. Volume Management (vold) can mount ufs, pcfs, hsfs, and udfs file systems.

Volume Management (vold) Configuration Files

File

Description

/etc/vold.conf 


The Volume Management (vold) configuration file. This file defines items, such as what action should be taken when media is inserted or ejected, which devices are managed by Volume Management (vold), and which file system types are unsafe to eject.


/etc/rmmount.conf


The rmmount command configuration file. The rmmount command is a removable media mounter that is executed by the Volume Management (vold) daemon whenever a CD-ROM or diskette is inserted.

Usage scenarios :
---------------------------
/etc/init.d/volmgt stop
Stop VOLD service.

/etc/init.d/volmgt start
Start VOLD sevice.

Accessing a diskette, cd/dvd without VOLD :
--------------------------------------------------------------------
1. Insert the media device.
2. Become the root user.
3. Create a mount point, if necessary.
4. Determine the file system type.
5. Mount the device by using the mount options listed in the following sections.
6. Work with files on the media device.
7. Unmount the media device.
8. Eject the media device.
9. Exit the root session.