Software RAID problem

NAS.

Drives are as follow:

A: 250GB
BCDE: 1TB/each

If we are going away with the dedicated OS drive I wouldn't mind getting rid of the A. It's the only PATA in the system and I also have no idea how to rearrange the drives do getting rid of A seems the easiest.

I think I should bring up the old mirror first. I don't want to lose data on the BC mirror.
 
I also failed to mention that it seems that DE drives are indeed part of a mirror:

I may have forgot this over the years but I may have added the DE drives to another mirror because it seems that I have RAID and RAID1 mirrors.

I remember working on adding the drives, but I guess I fit remember succeeding if at all.
 
Being that the obvious issue of having one terabyte drive less than we need to perform Sebulon's solution I have some thoughts on how to achieve a similar goal:

1. Verify full data integrity of the BC mirror
2. Use CDE drives for ZFS mirror
3. Copy B's data to the ZFS mirror

Will this work?
 
I am pretty sure that DE drives are empty, but I need to bring this system fully up to verify this. Can someone help me with the remapping of ad2s1a from the old ad0s1a please?
 
@FreeDomBSD

If we use B and C to boot, that will give 1TB of storage just for booting the machine and compiling ports or storing packages. That will only sum up to to a few GB´s and the rest of the 1TB would essentially be waste space sooner or later, since you cannot grow the pool you are booting from. Then, D and E would become a separate mirror 1TB big mounted on /usr/home.

Getting rid of drive A would be the best choice. But using B and C just for booting would be a waste of storage space. My best advice I can give you is to buy two cheap 4GB USB-drives that you can boot with and have / on, then create a big pool using B,C,D and E, giving you 3TB storage that you mount /usr, /usr/local, /usr/home and /var on.

In short:

Using B and C for boot and /, /usr, /usr/local and /var, and D and E for /usr/home gives you essentially only 1TB of storage and the ability to grow /usr/home.

Using two USB-drives for boot and /, and B,C,D and E for /usr, /usr/local, /usr/home and /var gives you 3TB storage and the ability to grow everything except /.

The only downside to having / on the USB-drives is that doing make installworld or freebsd-update install is going to SUCK, since USB are so IOPS constraint. It´s just going to take longer, that´s all. But this is how we setup our servers and we have never had any problems with this kind of setup.

/Sebulon
 
FreeDomBSD said:
I am pretty sure that DE drives are empty, but I need to bring this system fully up to very this.
Can someone help me with the remapping of ad2s1a from the old ad0s1a please.

To re-map the boot drive to a different device, reboot the machine into Single User Mode, then edit your /etc/fstab using vi(1). This is the file that contains the info about what partitions are mounted at boot.

Be sure to make a note of what's currently in your fstab file, in case you need to change it back, or just copy it to a backup. Also, if you are a beginner, vi can be a little tricky. You may want to open the vi(1) man page on a nearby screen. The mount command is to switch to read-write so you can make changes to the file you are editing, because Single User Mode it read-only by default.

Code:
mount -uw /
cp /etc/fstab /etc/fstab.old
vi /etc/fstab
 
Thanks Dave and wblock!

I'm actually familiar with vi, but didn't know the mount command.

I will check out ee because I never heard of it before.
 
I'm ready to go with the USB stick solution Sebulon proposed (I'm be using an identical pair of 8gb USB sticks) unless anyone else has anything to add?

I will try to bring up the BC & DE RAIDs. Wish me luck!
 
IN-DETAIL INSTRUCTION SET:

Locate and identify your drives (example):
Code:
[CMD="#"]camcontrol devlist[/CMD]
<ATA SOMETHING 0001>         at scbus0 target 0 lun 0 (ada0,pass0) (Disk B?)
<ATA SOMETHING 0001>         at scbus0 target 1 lun 0 (ada1,pass1) (Disk C?)
<ATA SOMETHING 0001>         at scbus0 target 2 lun 0 (ada2,pass2) (Disk D?)
<ATA SOMETHING 0001>         at scbus0 target 3 lun 0 (ada3,pass3) (Disk E?)
<USB SOMETHING 1.0>          at scbus0 target 4 lun 0 (pass4,da0) (USB A?)
<USB SOMETHING 1.0>          at scbus0 target 5 lun 0 (pass5,da1) (USB B?)

If you want to know more about one of them, you can use e.g.:
# diskinfo -v da0

Load up gmirror, identify the partitions and slices, check the filesystem/s, mount and then split the mirror to free up a drive to use for your new data-pool:
# gmirror load
Code:
[CMD="#"]ls -1 /dev/mirror[/CMD]
gm0
gm0s1
gm0s1a
# fsck -t ufs /dev/mirror/gm0s1a
Repeat for each slice, if more than just the "a".
# gmirror remove gm0 /dev/ada1
# gpart delete -i 1 ada1
# gpart destroy ada1

Now to check if there´s any partitioning on D or E (the sizes and sectors are different from yours, it´s just an example):
Code:
[CMD="#"]gpart show ada2[/CMD]

=>     34  8388541  ada2  BSD  (4.0G)
       34  8388541    1  freebsd-ufs  (4G)
[CMD="#"]gpart show ada3[/CMD]
=>     34  8388541  ada3  BSD  (4.0G)
       34  8388541    1  freebsd-ufs  (4G)
And if any, clean them:
# gpart delete -i 1 ada2
# gpart delete -i 1 ada3
# gpart destroy ada2
# gpart destroy ada3

Create new partitioning scheme and set partition start- and stop aligned after 4k:
# gpart create -s gpt ada1
# gpart create -s gpt ada2
# gpart create -s gpt ada3
# gpart add -t freebsd-zfs -l diskC -b 2048 -a 4k ada1
# gpart add -t freebsd-zfs -l diskD -b 2048 -a 4k ada2
# gpart add -t freebsd-zfs -l diskE -b 2048 -a 4k ada3

This is a tricky part. For retarted reasons, you need to create "fake" drives to create your pool with. You shouldn´t have to do this really, but it´s the only workaround I´ve found for the gnop-trick to work and the labels to show up. The recipe for dd is to seek forwards to your total size of your drives, minus one MB, for the partition start- and stop boundary. Use diskinfo to see the size of one of your drives in bytes:
Code:
[CMD="#"]diskinfo -v ada0[/CMD]
	512         	# sectorsize
	1000199467008	# mediasize in bytes (1T)
	1953514584  	# mediasize in sectors

... ( I didn´t have any 1TB drives available, so these numbers are based on a 2TB drive divided by 2 )

[CMD="#"]echo "1000199467008 / 1024000 - 1" | bc[/CMD]
976756

# dd if=/dev/zero of=/tmp/tmpdsk2 bs=1m seek=976756 count=1
# dd if=/dev/zero of=/tmp/tmpdsk3 bs=1m seek=976756 count=1
# dd if=/dev/zero of=/tmp/tmpdsk4 bs=1m seek=976756 count=1
# dd if=/dev/zero of=/tmp/tmpdsk5 bs=1m seek=976756 count=1

# mdconfig -a -t vnode -f /tmp/tmpdsk2 md2
# mdconfig -a -t vnode -f /tmp/tmpdsk3 md3
# mdconfig -a -t vnode -f /tmp/tmpdsk4 md4
# mdconfig -a -t vnode -f /tmp/tmpdsk5 md5

Do the files need to be called the same as the md´s? No, but it´s alot easier to remember what was what.

# gnop create -S 4096 md2
# zpool create -O mountpoint=none -o autoexpand=on -o cachefile=/var/tmp/zpool.cache pool2 raidz md2.nop md{3,4,5}
# zpool export pool2
# gnop destroy md2.nop
# zpool import -o cachefile=/var/tmp/zpool.cache pool2

So the data-pool is now imported again with the "fake" drives. By using the gnop-trick, we tell ZFS that the smallest write it can send is 4k. Now we begin to replace the fake ones with the real, minus drive B which we will have to deal with after we´ve copied the data out from it.
# zpool offline pool2 md2
# mdconfig -d -u 2
# rm /tmp/tmpdsk2

# zpool offline pool2 md3
# mdconfig -d -u 3
# rm /tmp/tmpdsk3
# zpool replace pool2 md3 gpt/diskC

# zpool offline pool2 md4
# mdconfig -d -u 4
# rm /tmp/tmpdsk4
# zpool replace pool2 md4 gpt/diskD

# zpool offline pool2 md5
# mdconfig -d -u 5
# rm /tmp/tmpdsk5
# zpool replace pool2 md5 gpt/diskE

Using the same method to create the boot-pool:
# gpart create -s gpt da0
# gpart create -s gpt da1

# gpart add -t freebsd-zfs -l usbA -b 2048 -a 4k da0
# gpart add -t freebsd-zfs -l usbB -b 2048 -a 4k da1

# dd if=/dev/zero of=/tmp/tmpdsk2 bs=1m seek=8191 count=1
# mdconfig -a -t vnode -f /tmp/tmpdsk2 md2
# gnop create -S 4096 md2
# zpool create -O mountpoint=none -o cachefile=/var/tmp/zpool.cache pool1 md2.nop
# zpool export pool1
# gnop destroy md2.nop
# zpool import -o cachefile=/var/tmp/zpool.cache pool1
# zpool attach pool1 md2 gpt/usbB
# zpool offline pool1 md2
# mdconfig -d -u 2
# rm /tmp/tmpdsk2
# zpool replace pool1 md2 gpt/usbA

# zfs create -o mountpoint=legacy -o compress=on pool1/root
# zfs create -o mountpoint=legacy -o compress=on pool2/root
# zfs create pool2/root/usr
# zfs create pool2/root/usr
# zfs create pool2/root/usr/local
# zfs create pool2/root/usr/home
# zfs create pool2/root/var
# zfs create -o compress=on -s -V 512m pool2/swap
Swap is historically decided on "your amount of RAM"x2

# zpool set bootfs=pool1/root pool1
# mount -t zfs pool1/root /mnt
# mkdir /mnt/tmp
# mkdir /mnt/usr
# mkdir /mnt/var
# mount -t zfs pool2/root/usr /mnt/usr
# mount -t zfs pool2/root/var /mnt/var
# mkdir /mnt/usr/home
# mkdir /mnt/usr/local
# mount -t zfs pool2/root/usr/home /mnt/usr/home
# mount -t zfs pool2/root/usr/local /mnt/usr/local

Edit the configuration files needed for the system to boot up and mount everything in place:
Code:
[CMD="#"]ee /tmp/bsdinstall_etc/fstab[/CMD]
/dev/zvol/pool2/swap    none            swap    sw      0       0
pool1/root              /               zfs     rw      0       0
tmpfs                   /tmp            tmpfs   rw      0       0
pool2/root/usr          /usr            zfs     rw      0       0
pool2/root/usr/home     /usr/home       zfs     rw      0       0
pool2/root/usr/local    /usr/local      zfs     rw      0       0
pool2/root/var          /var            zfs     rw      0       0
[CMD="#"]ee /mnt/boot/loader.conf[/CMD]
autoboot_delay="5"
zfs_load="YES"
vfs.root.mountfrom="zfs:pool1/root"

Now we start copying everything out from the old BC-mirror:
# mkdir -p /mnt/usr/home/BC-mirror/gm0s1a
# mount -t ufs /dev/mirror/gm0s1a /media
# cd /media
# find -xs . | cpio -pv /mnt/usr/home/BC-mirror/gm0s1a
# cd /
# umount /media
Repeat for each slice, if more than just the "a".

Crash the old mirror, clean partitioning, create new partitioning and complete the data-pool:
# gmirror stop gm0
# gmirror unload gm0
# gpart delete -i 1 ada0
# gpart destroy ada0
# gpart create -s gpt ada0
# gpart add -t freebsd-zfs -l diskB -b 2048 -a 4k ada0
# zpool replace pool2 md2 gpt/diskB

Resilvering this disk can take a while depending on much you copied in from the old BC mirror. Watch the progress with:
# zpool status pool2
# zpool iostat pool2 1

When done, wrap it up with:
# mkdir -p /mnt/boot/zfs
# cp /var/tmp/zpool.cache /mnt/boot/zfs/
# exit

I have tried to describe the process as detailed as possible, and in doing so there´s also a greater risk of typos. I have re-read this a couple of times to minimize this risk and I have also gone through this exact process in a VMWare virtual machine, except with a smaller disk size (4GB), and it worked from start to finish. I have taken as many things as I can into consideration, still there might be things that differs when you attempt this; device names e.g. Either you rearrange how the drives are connected in you chassis to match the instruction set, or you correct the commands as appropriate.

May the Schwartz be with you, always.

/Sebulon
 
dave said:
To re-map the boot drive to a different device, reboot the machine into Single User Mode, then edit your /etc/fstab using vi(1). This is the file that contains the info about what partitions are mounted at boot.

Be sure to make a note of what's currently in your fstab file, in case you need to change it back, or just copy it to a backup. Also, if you are a beginner, vi can be a little tricky. You may want to open the vi(1) man page on a nearby screen. The mount command is to switch to read-write so you can make changes to the file you are editing, because Single User Mode it read-only by default.

Code:
mount -uw /
cp /etc/fstab /etc/fstab.old
vi /etc/fstab

Code:
vi: not found

And

Code:
ee: not found
 
Code:
Trying to mount root from ufs:/dev/ad0s1a

manual root filesystem specification:
   <fstype>:<device>   Mount <device> using filesystem <fstype>
                         eg. ufs:da0s1a
?                      List valid disk boot devices
<empty line>           Abort manual input

mountroot> ufs:ad2s1a
Trying to mount root from ufs:ad2s1a
Loading configuration files.
No suitable dump device was found.
Entropy harvesting: interupts ethernet point_to_point kickstart.
swapon: /dev/ad0s1b: No such file  or directory
Starting file system checks:
/dev/ad2s1a: FILE SYSTEM CLEAN: SKIPPING CHECKS
/dev/ad2s1a: clean 3171 free (3171 frags, 0 blocks, 0.3% fragmentation)
Can't stat /dev/mirror/raid: No such file or directory
Can't stat /dev/mirror/raid: No such file or directory
Unknown error; help!
ERROR: ABORTING BOOT (sending SIGTERM to parent)!
Jan 4 15:16:04 init: /binsh on /etc/rc terminated abnormaly, going to single user mode
Enter full pathname of shell or RETURN for /bin/sh:
#

Code:
# mount -uw /
# cp /etc/fstab
vi: not found
#
 
Code:
#mount -a
mount: /dev/ad0s1g : No such file or directory
#

The reason I am attempting to edit fstab is to change all ad0 references to ad2.

Thanks for your help wblock.
 
Sorry, until fstab is fixed, you will have to do the manual equivalent of mount -a.
Code:
mount -uw /
mount /dev/ad0s1d /var
mount /dev/ad0s1e /tmp
mount /dev/ad0s1g /usr

Adjust those based on what is in the current fstab. Use labels and it won't be a problem ever again.
 
Thanks for the link Mr. Block!

OT: I just realized that that's not the first time I've been to your site! I read the heck out of your All About Bikes in 2011.
Internet becoming a smaller world? :)
 
Hi Sebulon,

I encountered some problems following your instructions and am unsure if I should follow further without resolving them first.


Code:
#camcontrol devlist
<ST31000340NS SN04> at scbus0 target 0 lun 0 (ada0,pass0)
<ST31000340NS SN04> at 1 target 0 lun 0 (ada1,pass1)
<SAMSUNG HD103J 1AJ10001> at 2 target 0 lun 0 (ada2,pass2)
<SAMSUNG HD103J 1AJ10001> at 1 target 0 lun 0 (ada3,pass3)
<Kingston DataTraveler 2.0 1.00> at 8 target 0 lun 0 (pass4,da0)
<  1.20> at 9target 0 lun 0 (pass5,da1)
<  1.20> at 10target 0 lun 0 (pass6,da2)

* ada0&ada1 --> Drives B&C in unknown order
* ada2&ada3 --> Drives D&E in unknown order
* da0 --> USB drive with FreeBSD 9
* da1&da2 --> pair of 8GB USB drives (drives F&G, shall we?)

Code:
# gmirror load
GEOM_MIRROR: Cannot add disk ada3 to raid1 (error=17).
GEOM_MIRROR: Component ada1 (device raid) broken, skipping.
GEOM_MIRROR: Device mirror/raid launched (1/2).
#GEOM_MIRROR: Force device raid1 start due to timeout.
GEOM_MIRROR: Device mirror/raid1 launched (1/2).
GEOM_MIRROR: integrity check failed (mirror/raid1, BSD)
 
From earlier in this thread:
FreeDomBSD said:
Code:
#gmirror status
Name Status Components
mirror/raid DEGRADED ad6
mirror/raid1 DEGRADED ad8

And recently:
FreeDomBSD said:
Code:
# gmirror load
GEOM_MIRROR: Cannot add disk ada3 to raid1 (error=17).
GEOM_MIRROR: Component ada1 (device raid) broken, skipping.
GEOM_MIRROR: Device mirror/raid launched (1/2).
#GEOM_MIRROR: Force device raid1 start due to timeout.
GEOM_MIRROR: Device mirror/raid1 launched (1/2).
GEOM_MIRROR: integrity check failed (mirror/raid1, BSD)

It looks like you might have two separate mirrors there, each missing it other half. What happens if you mount them and see what data is there?

Code:
# mkdir /mnt/raid
# mount /dev/mirror/raid /mnt/raid
# ls -lah /mnt/raid

# mkdir /mnt/raid1 
# mount /dev/mirror/raid1 /mnt/raid1
# ls -lah /mnt/raid1
 
After the first command it announces that it is a read-only file system:

Code:
# mkdir /mnt/raid
mkdir: /mnt/raid: Read-only file system

Keep in mind that this is while installing FreeBSD 9 (not my old installation of FreeBSD).
 
wblock@ said:
Sorry, until fstab is fixed, you will have to do the manual equivalent of mount -a.
Code:
mount -uw /
mount /dev/ad0s1d /var
mount /dev/ad0s1e /tmp
mount /dev/ad0s1g /usr

Adjust those based on what is in the current fstab. Use labels and it won't be a problem ever again.

After mounting /var/tmp/usr on my old install I still was unable to use ee or vi (same error message as before)
 
FreeDomBSD said:
After the first command it announces that it is a read-only file system:

Code:
# mkdir /mnt/raid
mkdir: /mnt/raid: Read-only file system

Keep in mind that this is while installing FreeBSD 9 (not my old installation of FreeBSD).

Hmmm, OK. Thought you have FreeBSD 9 running on your OS drive. If not, you could use the Live CD to boot up, access those mirrors and at least figure out what's what.
 
@Sebulon, for the one vdev limit issue, I've found that it is simple enough to slice up your disks to put your root slices on the same disks as your big pool that uses all disks. For example with 2 mirror vdevs:

1st data vdev disks:
disk 1: boot, root, and data slices
disk 2: boot, root, and data slices

2nd data vdev disks:
disk 3: data slice
disk 4: data slice

Then put a 2 way mirror on the first 2, and make a pool (using -f since you have different size disks) with the 4 data slices. That way you have as many vdevs as you want for data, but a single one for root. (and then you can put /usr/src or whatever else on data if you run out of space on the root mirror).

# zpool create zroot mirror gpt/root1 gpt/root2
# zpool create -f data mirror gpt/data1d1 gpt/data1d2 mirror gpt/data2d1 gpt/data2d2

Optional for a small performance boost. I do this to all my slow disks (USB sticks), and non-root pools.
# zfs set atime=off data


Only problems with the above suggestion I see:
-slightly more complex (eg. What happens when disk 1 fails and is replaced? Does the admin know it is part of 2 pools plus bootcode? Is a hotspare replace script going to handle this? data with raidz instead, etc.)
-performance would be hurt if you put stress on the root slices (maybe /tmp) (in my setups, my root disks see nearly nothing, so I assume this is a non-issue in most cases)

[And on a fun and dangerous side note, from reading mailing lists, it seems if you change the bootfs property to trick it into allowing 2 vdevs, then set bootfs back, and (maybe not necessary: ) set copies=<number of vdevs+1> (for whichever datasets are needed for boot, /boot only?), booting seems to work]
 
Dave,

I tried to run the commands you gave me in post #46

Code:
# gmirror load
GEOM_MIRROR: Cannot add disk ada3 to raid1 (error=17).
GEOM_MIRROR: Component ada1 (device raid) broken, skipping.
GEOM_MIRROR: Device mirror/raid launched (1/2).
#GEOM_MIRROR: Force device raid1 start due to timeout.
GEOM_MIRROR: Device mirror/raid1 launched (1/2).
GEOM_MIRROR: integrity check failed (mirror/raid1, BSD)

Code:
# mkdir /mount/raid
mkdir: /mnt/raid: Read-only file system
# mount /dev/mirror/raid /mnt/raid
mount: /mnt/raid: No such file or directory

I didn't bother continuing attempting to run the command sets
 
Back
Top