<

Go Premium for a chance to win a PS4. Enter to Win

x

Moving a Solaris File System to Another Partition Dynamically

Published on
9,596 Points
2,896 Views
2 Endorsements
Last Modified:
Let's say you need to move the data of a file system from one partition to another. This generally involves dismounting the file system, backing it up to tapes, and restoring it to a new partition. You may also copy the file system from one place to another while it is unmounted. This process could take a significant amount of time for a large file system, and it will impact the use of the system.
To move a file system to a different partition on the fly, you can use Solaris Volume Manager software. If you don't need to expand the file system, you don't even have to mount it as a metadevice. In the end, you only need to dismount the file system, and mount it onto the new partition. All the processes can be executed in the background while the file system is still in use.
You can swap to the new partition at any time. This can reduce system downtime in many cases. Let's use the /home file system as an example:
# df -k /home

/dev/dsk/c0t2d1s3 50700783 39746386 10530839 80% /home

Open in new window

First, on top of this physical mount point of the /home file system, create a metadevice named d101. Remember, the /home file system is still mounted.
# metainit -f d101 1 1 c0t2d1s3

Open in new window

Next, you need to initialize a one-way mirror metadevice, d100, with the submirror d101 you have created.
# metainit d100 -m d101
# metastat d100

d100: Mirror
    Submirror 0: d101
      State: Okay
    Pass: 1
    Read option: roundrobin (default)
    Write option: parallel (default)
    Size: 102961152 blocks
d101: Submirror of d100
    State: Okay
    Size: 102961152 blocks
    Stripe 0:
        Device              Start Block  Dbase State        Hot Spare
   c0t2d1s3                   0     No    Okay

Open in new window

Now it's time to create a single-stripe metadevice (in this example, d102 on c0t2d1s7), where the target file system would be. The size of the new partition should be the same as d101.

# metainit d102 1 1 c0t2d1s7
d102: Concat/Stripe is setup

# metastat d102
d102: Concat/Stripe
    Size: 102975488 blocks
    Stripe 0:
        Device              Start Block  Dbase
        c0t2d1s7                   0     No

Open in new window

After that, you add the metadevice d102 as the second submirror to d100. Here the resynchronization will automatically take place in the background.
# metattach d100 d102

Open in new window

After the resynchronization has been completed successfully, here's an example of the two-way mirrors you would get:
# metastat d100
d100: Mirror
    Submirror 0: d101
      State: Okay
    Submirror 1: d102
      State: Okay
    Pass: 1
    Read option: roundrobin (default)
    Write option: parallel (default)
    Size: 102961152 blocks

d101: Submirror of d100
    State: Okay
    Size: 102961152 blocks
    Stripe 0:
        Device              Start Block  Dbase State        Hot Spare 
   c0t2d1s3                   0     No    Okay

d102: Submirror of d100
    State: Okay
    Size: 102961152 blocks
    Stripe 0:
        Device              Start Block  Dbase State        Hot Spare 
   c0t2d1s7                   0     No    Okay

Open in new window

Now, you have a new partition for the /home file system, ready to swap at any time while it's still online.
With your user, you can schedule when to dismount the home file system. You can then mount the system to the new partition on c0t2d1s7, shown as follows:
# df -k /home

/dev/dsk/c0t2d1s7 50700783 39746386 10530839 80% /home

Open in new window

Finally, you'll detach and clean up all metadevices from your system:
# metadetach d100 d101
d100: submirror d101 is detached

# metaclear d101
d101: Concat/Stripe is cleared

# metaclear d100
d100: Concat/Stripe is cleared

# metaclear d102
d102: Concat/Stripe is cleared

Open in new window

Now you have performed fewer than 10 steps, and the /home file system has been moved dynamically.

Please note: This procedure must be done during a quiet period, or the file system must be locked, in order to avoid possible changes to the file system during the sync. You can use the fuser -u command to check that no one is using the file system. If users are logged on overnight in their logging directory, the system admin could write-lock the file system if it is possible. In that case, users can still read files in the directory. As long as no one creates files during the sync, everything will be fine.       

2
Comment
Author:Joseph Gan
0 Comments

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Join & Write a Comment

Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.
Suggested Courses

Keep in touch with Experts Exchange

Tech news and trends delivered to your inbox every month