In addition to renaming metadevices, DiskSuite's metarename command also provides the ability to switch "layered" metadevices. When used with the -x option, metarename switches (exchanges) the names of an existing layered metadevice and one of its subdevices. This includes a mirror and one of its submirrors, or a trans metadevice and its master device.
You must use the command line to exchange metadevices. This functionality is currently unavailable in DiskSuite Tool, although you can rename a metadevice with either the command line or DiskSuite Tool.
When to use metadevice name switching - The metarename -x command can make it easier to mirror or unmirror an existing stripe or concatenation, and to create or remove a trans metadevice of an existing metadevice.
Advantages of using metadevice name switching - Switching metadevice names is an administrative convenience for management of metadevice names. For example, you could arrange all file system mount points in a desired numeric range.
Combinations of metadevices that can be switched - The metarename -x command can be used to switch:
Mirror and submirror (concatenation or stripe)
Trans metadevice and master device, where the master device is a concatenation, stripe, mirror, or RAID5 metadevice
The metadevice name switch can take place in both directions.
Trans metadevice that has a mirrored master device - If the master device is a mirror, you cannot directly switch one of the mirror's submirrors for the trans metadevice. You can switch the mirror and the trans metadevice names, or the mirror and one of its submirrors. The relationship for the switch is always parent-child. In essence, you could achieve the same outcome of a submirror/trans metadevice exchange by using a two-step process: first, switch the submirror for the mirror; then switch the mirror for the trans metadevice.
"Rename busy" message when trying to switch components of a trans metadevice - This message could mean one or more of the following: you did not first detach the logging device; you did not unmount the file system using the trans metadevice; you did not use the -f (force) flag option of the metarename command.
You cannot switch (or rename) a metadevice that is currently in use. This includes metadevices used as mounted file systems, as swap, or as active storage for applications or databases. Thus, before using the metarename command, stop all access to the metadevice being renamed. For example, unmount a mounted file system using a metadevice. An application or database must have its own internal method for stopping access.
You cannot switch metadevices in an errored state, or metadevices using a hot spare replacement.
A switch can only take place between metadevices with a direct parent/child relationship. You could not, for example, directly exchange a stripe in a mirror that is a master device with the trans metadevice.
You must use the -f (force) flag when switching members of a trans device.
You cannot switch (or rename) a logging device. The workaround is to either detach the logging device, rename it, then reattach it to the trans device; or detach the logging device and attach another logging device of the desired name.
Only metadevices can be switched. You cannot switch slices or hot spares.
If you have an existing stripe, you can use the metarename -x command to create a compound metadevice. This includes creating a mirror from a concat/stripe, or a trans device with a metadevice as the master device.
This example begins with a concatenation, d1, with a mounted file system, and ends up with the file system mounted on a two-way mirror named d1.
# metastat d1 d1: Concat/Stripe Size: 5600 blocks Stripe 0: Device Start Block Dbase c0t0d0s1 0 No # metainit d2 1 1 c1t3d0s1 d2: Concat/Stripe is setup # metainit -f d20 -m d1 d20: Mirror is setup # umount /fs2 # metarename -x d20 d1 d20 and d1 have exchanged identities # metastat d1 d1: Mirror Submirror 0: d20 State: Okay ... d20: Submirror of d1 State: Okay ... # metattach d1 d2 d1: submirror d2 is attached # metastat d1 d1: Mirror Submirror 0: d20 State: Okay Submirror 1: d2 State: Okay ... # mount /fs2 |
The metastat command confirms that the concatenation d1 is in the "Okay" state. You use the metainit command to create a second concatenation (d2), and then to force (-f) the creation of mirror d20 from d1. You must unmount the file system before using metarename -x to switch d20 for d1; d1 becomes the top-level device (the mirror), which metastat confirms. You attach d2 as the second submirror, verify the state of the mirror with metastat, then remount the file system. Note that because the mount device for /fs2 did not change, you do not have to edit the /etc/vfstab file.
This example begins with a mirror, d1, with a mounted file system, and ends up with the file system mounted on a trans device named d1.
# metastat d1 d1: Mirror Submirror 0: d20 State: Okay Submirror 1: d2 State: Okay ... # umount /fs2 # metainit d21 -t d1 d21: Trans is setup # metarename -f -x d21 d1 d21 and d1 have exchanged identities # metastat d1 d1: Trans State: Detached Size: 5600 blocks Master Device: d21 ... # metattach d1 d0 d1: logging device d0 is attached # mount /fs2 |
The metastat command confirms that the mirror d1 is in the "Okay" state. You must unmount the file system before using the metainit command to create the trans device d21, with d1 as the master. The metarename -f -x command forces the switch of d21 and d1; d1 is now the top-level trans metadevice, as confirmed by the metastat command. A logging device d0 is attached with the metattach command. You then remount /fs2. Note that because the mount device for /fs2 has not changed (it is still d1), you do not have to edit the /etc/vfstab file.
If you have an existing mirror or trans metadevice, you can use the metarename -x command to remove the mirror or trans metadevice and keep data on an underlying metadevice. For a trans metadevice, as long as the master device is a metadevice (stripe/concat, mirror, or RAID5 metadevice), you keep data on that metadevice.
When you use metarename -x as part of this process, the mount point of the file system remains the same.
This example begins with a mirror, d1, containing a mounted file system, and ends up with the file system mounted on a stripe named d1.
# metastat d1 d1: Mirror Submirror 0: d20 State: Okay Submirror 1: d2 State: Okay Pass: 1 ... # umount /fs2 # metarename -x d1 d20 d1 and d20 have exchanged identities # metastat d20 d20: Mirror Submirror 0: d1 State: Okay Submirror 1: d2 State: Okay ... # metadetach d20 d1 d20: submirror d1 is detached # metaclear -r d20 d20: Mirror is cleared d2: Concat/Stripe is cleared # mount /fs2 |
The metastat command confirms that mirror d1 is in the "Okay" state. This file system is unmounted before exchanging the mirror d1 and its submirror d20. This makes the mirror d20, as confirmed by metastat. Next, d1 is detached from d20, then mirror d20 and the other submirror, d2 are deleted. Finally, /fs2 is remounted. Note that because the mount device for /fs2 did not change, the /etc/vfstab file does not require editing.
This example begins with a trans metadevice, d1, containing a mounted file system, and ends up with the file system mounted on the trans metadevice`s underlying master device, which will be d1.
# metastat d1 d1: Trans State: Okay Size: 5600 blocks Master Device: d21 Logging Device: d0 d21: Mirror Submirror 0: d20 State: Okay Submirror 1: d2 State: Okay ... d0: Logging device for d1 State: Okay Size: 5350 blocks # umount /fs2 # metadetach d1 d1: logging device d0 is detached # metarename -f -x d1 d21 d1 and d21 have exchanged identities # metastat d21 d21: Trans State: Detached Size: 5600 blocks Master Device: d1 d1: Mirror Submirror 0: d20 State: Okay Submirror 1: d2 State: Okay # metaclear 21 # fsck /dev/md/dsk/d1 ** /dev/md/dsk/d1 ** Last Mounted on /fs2 ** Phase 1 - Check Blocks and Sizes ** Phase 2 - Check Pathnames ** Phase 3 - Check Connectivity ** Phase 4 - Check Reference Counts ** Phase 5 - Check Cyl groups FILE SYSTEM STATE IN SUPERBLOCK IS WRONG; FIX? y 3 files, 10 used, 2493 free (13 frags, 310 blocks, 0.5% fragmentation) # mount /fs2 |
The metastat command confirms that the trans metadevice, d1, is in the "Okay" state. The file system is unmounted before detaching the trans metadevice's logging device. The trans metadevice and its mirrored master device are exchanged using the -f (force) flag. Running metastat again confirms that the exchange occurred. The trans metadevice and the logging device (if desired) are cleared, in this case, d21 and d0, respectively. Next, the the fsck command is run on the mirror, d1, and the prompt is answered with a y. After the fsck command is done, the file system is remounted. Note that because the mount device for /fs2 did not change, the /etc/vfstab file does not require editing.