gmirror assistance needed

I'm having a heck of a time figuring out one of the steps for gmirror(). Here is what I have done so far:

Code:
root@localhost:/home/ken # df -h
Filesystem     Size    Used   Avail Capacity  Mounted on
/dev/ada0p2    105G    2.2G     94G     2%    /
devfs          1.0K    1.0K      0B   100%    /dev
fdescfs        1.0K    1.0K      0B   100%    /dev/fd


root@localhost:/home/ken # diskinfo -v ada0 | head -n3
ada0
        512             # sectorsize
        120034123776    # mediasize in bytes (112G)
root@localhost:/home/ken #


root@localhost:/home/ken # geom zero load
root@localhost:/home/ken # gnop create -s 120034123776 gzero 
root@localhost:/home/ken # gmirror label -v gm0 gzero.nop ada1
gmirror: Can't store metadata on ada1: Operation not permitted.
root@localhost:/home/ken # sysctl kern.geom.debugflags=16
kern.geom.debugflags: 0 -> 16
root@localhost:/home/ken # gmirror label -v gm0 gzero.nop ada1
Metadata value stored on gzero.nop.
Metadata value stored on ada1.
Done.
root@localhost:/home/ken # gmirror forget gm0


root@localhost:/home/ken # gpart show ada0
=>       34  234441581  ada0  GPT  (112G)
         34          6        - free -  (3.0K)
         40        128     1  freebsd-boot  (64K)
        168  226492280     2  freebsd-ufs  (108G)
  226492448    7949166     3  freebsd-swap  (3.8G)
  234441614          1        - free -  (512B)

root@localhost:/home/ken # gpart backup ada0 > table.ada0

** I modified table.ada0 so the last partition was reduced by one sector **

root@localhost:/home/ken # more table.ada0 
GPT 128
1   freebsd-boot        40       128  
2    freebsd-ufs       168 226492280  
3   freebsd-swap 226492448   7949165

root@localhost:/home/ken # gpart restore mirror/gm0 < table.ada0

root@localhost:/home/ken # gpart show
=>       34  234441581  ada0  GPT  (112G)
         34          6        - free -  (3.0K)
         40        128     1  freebsd-boot  (64K)
        168  226492280     2  freebsd-ufs  (108G)
  226492448    7949166     3  freebsd-swap  (3.8G)
  234441614          1        - free -  (512B)

=>       34  234441580  mirror/gm0  GPT  (112G)
         34          6              - free -  (3.0K)
         40        128           1  freebsd-boot  (64K)
        168  226492280           2  freebsd-ufs  (108G)
  226492448    7949165           3  freebsd-swap  (3.8G)
  234441613          1              - free -  (512B)

=>       34  234441580  ufsid/53eee3d374c3e517  GPT  (112G)
         34          6                          - free -  (3.0K)
         40        128                       1  freebsd-boot  (64K)
        168  226492280                       2  freebsd-ufs  (108G)
  226492448    7949165                       3  freebsd-swap  (3.8G)
  234441613          1                          - free -  (512B)

Now this is where I'm stuck. The next step says to "Create file systems on these new partitions".

newfs -U /dev/mirror/???? <--- what do I put here?

The geom-mirror "how-to" doesn't cover single partition/slice installations.

Also, the instructions state "the size of both the slice and the last partition must be reduced by one sector".

What "slice" are they referring to in my situation?
 
That is the Handbook section on gmirror(8). Because your existing drive is GPT instead of MBR, the situation is more like the first half of that section. That's the one that shows creating a mirror with two new drives.

Make a full backup. Do not skip this step.

Untested from here on, but should at least be close.

Create a new mirror with only one drive (the new one):
Code:
# gmirror label -v gm0 /dev/ada1
# gpart create -s MBR mirror/gm0
# gpart add -t freebsd mirror/gm0
# gpart create -s BSD mirror/gm0s1
# gpart add -t freebsd-ufs  -a 4k -s 108G mirror/gm0s1
# gpart add -t freebsd-swap -a 4k mirror/gm0s1
# gpart bootcode -b /boot/mbr mirror/gm0
# gpart set -a active -i 1 mirror/gm0
# gpart bootcode -b /boot/boot mirror/gm0s1
# newfs -U /dev/mirror/gm0s1a

Copy the filesystem onto the mirror with dump()/restore().
Code:
# mount /dev/mirror/gm0s1a /mnt
# dump -C16 -b64 -0aL -f - / | (cd /mnt && restore -rf -)

Edit /mnt/etc/fstab to use the mirror:
Code:
# Device		Mountpoint	FStype	Options	Dump	Pass#
/dev/mirror/gm0s1a	/		ufs	rw	1	1
/dev/mirror/gm0s1b	none		swap	sw	0	0

Boot from the mirror and test it.
Destroy the GPT partitioning on the old drive.
Add the old drive to the mirror.
 
Thank you, everything worked great right up to this line :

Code:
# dump -C16 -b64 -0aL -f - / | (cd /mnt && restore -rf -)
mksnap_ffs: Cannot create snapshot //.snap/dump_snapshot: /: Snapshots are not yet supported when running with journaled soft updates: Operation not supported
dump: Cannot create //.snap/dump_snapshot: No such file or directory

Tape is not a dump tape
#

Any ideas how to solve this?

Since my server is not yet live, is it safe to just drop the the "-L" option?
 
I advise disabling soft updates journaling. It makes fsck() run quickly after a crash. In my experience, it also increases the chance of a crash, so you'll need it more.

To disable it, boot into single user and run tunefs -j disable /dev/ada0p2. Then reboot, and do the backup.
 
Ok, I'm assuming I missed a critical step before the reboot?

Code:
boot:
Booting from local disk...
PXE-M0F: Exiting Intel Boot Agent

No /boot/loader

FreeBSD/x86 boot
Default: 0:ad(0,a)/boot/kernel/kernel
boot:
no /boot/kernel/kernel
 
wblock@ said:
Turning off SUJ does not make any noticeable difference. Are you trying to boot from the mirror?

No, not that I'm aware of. The bios is still set to boot off the first SSD.

I never even had to chance to disable SUJ - this is my first reboot trying to get in to single user mode.
 
wblock@ said:
When you created the mirror, did you use ada1?

Yes, and I completed all your steps up to :

Code:
dump -C16 -b64 -0aL -f - / | (cd /mnt && restore -rf -)

Which gave me an error.

So I was rebooting to single user mode to disable SUJ - and got that boot error message.
 
Use the BIOS boot menu to specifically boot from ada0. I think it is trying to boot from the new mirror, but there are no files on it yet.
 
wblock@ said:
Use the BIOS boot menu to specifically boot from ada0. I think it is trying to boot from the new mirror, but there are no files on it yet.

That did the trick, thank you :)
 
I had to put this aside for a day, and running into a new issue.

I've booted into single user mode and trying to delete the swap partition on ada0 (so I can 'destroy' it and add it to the mirror).

# gpart delete -i3 ada0

Code:
gpart: Device busy

I've also tried sysctl kern.geom.debugflags=16 to no avail.

I noticed another issue, the changes I made to /etc/fstab did not stick. To use the mirror, I added :

Code:
/dev/mirror/gm0s1a   /      ufs   rw   1   1
/dev/mirror/gm0s1b   none      swap   sw   0   0

However, those entries are no longer there and forces my server to the 'mountroot>' prompt - which pushes me in to single user mode after pointing to the drive that is mirrored.

Is there any way I can set RW to that file in single user mode?

Edit: this is what I have tried:

Code:
# mount -uw
/mirror/gm0s1a on / (ufs, local, read-only)
...
#
# mount -uw /
mount: /dev/ada0p2: no such file or directory

Not sure why ada0 is showing up.
 
The above issue has been resolved.

Is it safe/possible to use tunefs on the drives when they are already gmirrored?

Code:
# gmirror status
      Name    Status  Components
mirror/gm0  COMPLETE  ada0 (ACTIVE)
                      ada1 (ACTIVE)

# tunefs -p /dev/mirror/gm0s1a
tunefs: POSIX.1e ACLs: (-a)                                disabled
tunefs: NFSv4 ACLs: (-N)                                   disabled
tunefs: MAC multilabel: (-l)                               disabled
tunefs: soft updates: (-n)                                 enabled
tunefs: soft update journaling: (-j)                       disabled
tunefs: gjournal: (-J)                                     disabled
tunefs: trim: (-t)                                         disabled
tunefs: maximum blocks per file in a cylinder group: (-e)  4096
tunefs: average file size: (-f)                            16384
tunefs: average number of files in a directory: (-s)       64
tunefs: minimum percentage of free space: (-m)             8%
tunefs: space to hold for metadata blocks: (-k)            6408
tunefs: optimization preference: (-o)                      time
tunefs: volume label: (-L)

Will modifying any of these settings effect both drives?

If not, how to I access / set the settings on each drive individually?
 
The filesystem is now on the mirrored device so if you do any changes to the gm0s1a filesystem with tunefs(8) the changes are automatically mirrored on both copies. Remember that the filesystem code doesn't care about (nor does it know the dirty details of the device it's told to use) what it actually sits on top of as long as the device works like a block device and that's what the mirror device is, just another block device.

Accessing and changing the filesystem settings on the individual drives is ill-advised because a change that is done only on one of the drives effectively puts the mirror in the degraded state. You can see the filesystem settings of course with tunefs -p ada0s1a and the same for ada1s1a but as long as the mirror is in healthy condition the settings you see will be guaranteed to be identical to the settings of the mirror device gm0s1a.
 
Yes, only change the top-level mirror device, not the underlying components.

Also, these are SSDs, so I suggest leaving SUJ disabled. SSDs have such fast seek times that a full fsck() is usually fast enough without the complications of SUJ.
 
kpa said:
The filesystem is now on the mirrored device so if you do any changes to the gm0s1a filesystem with tunefs(8) the changes are automatically mirrored on both copies. Remember that the filesystem code doesn't care about (nor does it know the dirty details of the device it's told to use) what it actually sits on top of as long as the device works like a block device and that's what the mirror device is, just another block device.

Accessing and changing the filesystem settings on the individual drives is ill-advised because a change that is done only on one of the drives effectively puts the mirror in the degraded state. You can see the filesystem settings of course with tunefs -p ada0s1a and the same for ada1s1a but as long as the mirror is in healthy condition the settings you see will be guaranteed to be identical to the settings of the mirror device gm0s1a.

Thank you, I was hoping this would be the case.
 
wblock@ said:
Yes, only change the top-level mirror device, not the underlying components.

Also, these are SSDs, so I suggest leaving SUJ disabled. SSDs have such fast seek times that a full fsck() is usually fast enough without the complications of SUJ.

Yes, I left SUJ disabled - I just wanted to enable trim support.

Thank you so much for all your help, everything is working great now :)
 
Back
Top