How to Mount/Unmount Directory in Solaris

Let’s follow the steps.

1. Use format utility to define the disk on which you want to mount directory.

# format

Searching for disks…done

–I have disk named c0d0.
AVAILABLE DISK SELECTIONS:
0. c0d0 <DEFAULT cyl 2085 alt 2 hd 255 sec 63>
/pci@0,0/pci-ide@1,1/ide@0/cmdk@0,0

–Choose the disk number, in my case it is 0.
Specify disk (enter its number): 0

selecting c0d0
Controller working list found
[disk formatted, defect list found]
Warning: Current Disk has mounted partitions.
/dev/dsk/c0d0s0 is currently mounted on /. Please see umount(1M).
/dev/dsk/c0d0s1 is currently used by swap. Please see swap(1M).
/dev/dsk/c0d0s7 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
show       – translate a disk address
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
volname    – set 8-character volume name
!<cmd>     – execute <cmd>, then return
quit

–Type p to define the partition table.
format> p

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
!<cmd> – execute <cmd>, then return
quit

Type p to display the current table.
partition>p

Current partition table (original):
Total disk cylinders available: 2085 + 2 (reserved cylinders)

Part      Tag    Flag     Cylinders        Size            Blocks
0       root            wm      70 – 921      6.53GB       (852/0/0)    13687380
1       swap         wu       3   – 69          525.56MB  (67/0/0)      1076355
2     backup        wm     0   – 2084     15.97GB     (2085/0/0)  33495525
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

partition>

–Let’s stop here and discuss this situation.

So as you can see, there are several directories that already use some cylinders, but just several of them are mounted. To see what directories or disk slices are mounted you should open /etc/vfstab file:

#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/c0d0s1    –    –    swap    –    no    –
/dev/dsk/c0d0s0    /dev/rdsk/c0d0s0    /    ufs    1    no    –

/devices    –    /devices    devfs    –    no    –
sharefs    –    /etc/dfs/sharetab    sharefs    –    no    –
ctfs    –    /system/contract    ctfs    –    no    –
objfs    –    /system/object    objfs    –    no    –
swap    –    /tmp    tmpfs    –    yes    –

As you can see, 2 directories are already mounted.
These are:
root (/), mounted on the disk slice 0(c0d0s0),
swap , mounted on the disk slice 1(c0d0s1)

Note that, you should choose free cylinders.If you choose the cylinders that are already in use you may not get the desired result. For example, if we choose cylinders from 71 to 900, that are already in use by root directory, then mount some directory, for example u0, on this slice(which we have allocated on these cylinders). After entering in u0 directory, you will see the files that are located in root directory(So it will not be empty)

Not let’s continue…

–Let’s choose the second slice(It is not mouned)

partition> 2
Part      Tag    Flag     Cylinders        Size            Blocks
2     backup    wm       0 – 2084       15.97GB    (2085/0/0) 33495525

–Type the name for the partition, in our case usr
Enter partition id tag[backup]: usr

–Press enter, leave default
Enter partition permission flags[wm]:

–Type the starting cylinder number, in our case 922
Enter new starting cyl[3]: 922

–I choose 200mb as the partition size
Enter partition size[18683595b, 1163c, 2084e, 9122.85mb, 8.91gb]: 200mb

–To save the changes type label
partition>label

Ready to label disk, continue? y

–Press Ctrl+c to quite
partition> ^C

2. Let’s create the directory, that should be mounted, for example /u0

# cd /
# mkdir u0

3. Open /etc/vfstab file again, but now for editing and enter the following entry:

#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/c0d0s1    –    –    swap    –    no    –
/dev/dsk/c0d0s0    /dev/rdsk/c0d0s0    /    ufs    1    no    –
/dev/dsk/c0d0s2    /dev/rdsk/c0d0s2    /u0    ufs    1    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    –

Highlighted entry indicates that /u0 directory is mounted on c0d0s2 disk slice. One more thing that you should note is that if you want to mount this directory at startup you should write yes below the “mount at boot” column(If it is not necessary write no instead of yes).

4. Mount directory

# mount /u0

If everything is OK it will show nothing, but if you get the following error:

mount: /dev/dsk/c0d0s2 is not this fstype

Which means that there is no file system on this slice, then let’s create it.

First of all, you should comment, or temporarily remove the following entry from /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/c0d0s1    –    –    swap    –    no    –
/dev/dsk/c0d0s0    /dev/rdsk/c0d0s0    /    ufs    1    no    –
#/dev/dsk/c0d0s2    /dev/rdsk/c0d0s2    /u0    ufs    1    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    –

Go to the console and run the following command:

newfs /dev/dsk/c0d0s2
newfs: construct a new file system /dev/rdsk/c0d0s2: (y/n)? y

Now uncomment previous entry from /etc/vfstab , and run the following

# mount /u0

To check that it is mounted, again use format utility

# format
Searching for disks…done

AVAILABLE DISK SELECTIONS:
0. c0d0 <DEFAULT cyl 2085 alt 2 hd 255 sec 63>
/pci@0,0/pci-ide@1,1/ide@0/cmdk@0,0
Specify disk (enter its number): 0
selecting c0d0
Controller working list found
[disk formatted, defect list found]
Warning: Current Disk has mounted partitions.
/dev/dsk/c0d0s0 is currently mounted on /. Please see umount(1M).
/dev/dsk/c0d0s1 is currently used by swap. Please see swap(1M).
/dev/dsk/c0d0s2 is currently mounted on /u0. Please see umount(1M).

The highlighted entry shows that /u0 is already mounted on c0d0s2 disk slice.

To unmount directory

# umount /u0

Advertisements

One Response to How to Mount/Unmount Directory in Solaris

  1. Sunny says:

    Gr8 Work.. Thanks a lot

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: