Resize partitions and zpool on the fly

Posted: June 20th, 2013 | Author: | Filed under: FreeBSD, storage | Tags: | No Comments »

This is how my disk layout looked before the change:

# gpart show -l
=> 63 250069617 ada0 MBR (119G)
63 250069617 1 (null) [active] (119G)

=> 0 250069617 ada0s1 BSD (119G)
0 115343360 1 (null) (55G)
115343360 117440512 2 (null) (56G)
232783872 17285745 4 (null) (8.2G)

# bsdlabel ada0s1
# /dev/ada0s1:
8 partitions:
# size offset fstype [fsize bsize bps/cpg]
a: 115343360 0 ZFS
b: 117440512 115343360 ZFS
c: 250069617 0 unused 0 0 # "raw" part, don't edit
d: 17285745 232783872 swap

# zpool status
pool: zroot
state: ONLINE
scan: none requested
config:

NAME STATE READ WRITE CKSUM
zroot ONLINE 0 0 0
ada0s1a ONLINE 0 0 0

errors: No known data errors

# zpool list
NAME SIZE ALLOC FREE CAP DEDUP HEALTH ALTROOT
zroot 54.5G 39.1G 15.4G 71% 1.00x ONLINE -

Above you can see only ada0s1a (55G) was being used by my zpool: zroot.
I wanted to extend it to use the ada0s1b (56G) too.

1) Set autoexpand to “on” on zroot

# zpool get autoexpand zroot
NAME PROPERTY VALUE SOURCE
zroot autoexpand off default

# zpool set autoexpand=on zroot

# zpool get autoexpand zroot
NAME PROPERTY VALUE SOURCE
zroot autoexpand on local

2) Tell geom: “I know what I am doing”

# sysctl kern.geom.debugflags=16
kern.geom.debugflags: 0 -> 16

3) Delete the unused partition

# gpart delete -i 2 ada0s1
ada0s1b deleted
# gpart show
=> 63 250069617 ada0 MBR (119G)
63 250069617 1 freebsd [active] (119G)

=> 0 250069617 ada0s1 BSD (119G)
0 115343360 1 freebsd-zfs (55G)
115343360 117440512 - free - (56G)
232783872 17285745 4 freebsd-swap (8.2G)

4) Resize the partition in use to include the unused space

# gpart resize -s 232783872 -i 1 ada0s1
ada0s1a resized

# gpart show
=> 63 250069617 ada0 MBR (119G)
63 250069617 1 freebsd [active] (119G)

=> 0 250069617 ada0s1 BSD (119G)
0 232783872 1 freebsd-zfs (111G)
232783872 17285745 4 freebsd-swap (8.2G)

# zpool status
pool: zroot
state: ONLINE
scan: none requested
config:

NAME STATE READ WRITE CKSUM
zroot ONLINE 0 0 0
ada0s1a ONLINE 0 0 0

errors: No known data errors

5) Make zfs realize the fact that partition has been changed and make zpool
use the new partition which is actually the same one (ada0s1a).

# zpool online -e zroot ada0s1a ada0s1a
# zpool status
pool: zroot
state: ONLINE
scan: none requested
config:

NAME STATE READ WRITE CKSUM
zroot ONLINE 0 0 0
ada0s1a ONLINE 0 0 0

errors: No known data errors

6) Look at the success (SIZE is now 110G)

# zpool list
NAME SIZE ALLOC FREE CAP DEDUP HEALTH ALTROOT
zroot 110G 39.1G 71.4G 35% 1.00x ONLINE -


Device enumeration in FreeBSD

Posted: February 17th, 2013 | Author: | Filed under: FreeBSD, storage | Tags: , , , | No Comments »

One of the FreeBSD boxes I was working with came up with ad8 as its disk device. After reading around a bit and talking to a few FreeBSD devs, here is my findings of where did that number “8” come from:

On Intel PCH2 6 Port SATA controller, disk was attached to 3rd port i.e. port #2. (That can also be checked from the BIOS settings.)

Now, ATA stack reserves two device numbers (master/slave) per ATA channel. But, first two channels are reserved for legacy (ISA emulation) mode – PATA. That means, ad0 to ad3 are reserved.

So, if a disk is attached to port #0 master, it comes up as ad4. In this particular case, because the disk was attached to port #2 master, it came up as ad8.


Storage subsystem jargons

Posted: February 4th, 2013 | Author: | Filed under: FreeBSD, storage | Tags: , , , , , | No Comments »

Standards in order of their creation/availability:
SCSI (Serial Computer System Interface), oldest
ATA (IDE) : AT Attachment, later became PATA (Parallel ATA)
SATA (Serial ATA) : better than SCSI
SAS (Serial Attached SCSI) : better than SATA

SCSI/SATA controls RAID.

SAS : costlier, better for critical functions, server applications
SATA: cheaper, used for personal computers

SAS controller can access SATA drives but that’s not true the other way around.

SAS and SATA drives can operate in the same environment while SCSI and ATA cannot. For example, using faster SAS drives for primary storage and offloading older data to cheaper SATA disks in the same subsystem, something that could not be achieved with SCSI and ATA.

CAM (Common Access Method) : a specification for SCSI
CAM provides a formal description of the interfaces in a SCSI subsystem.
Benefits: providing round-robin prioritized transaction queuing, guaranteed transaction ordering even during error recovery, and a straight forward error recovery model that increases system robustness.

CAM is not perfect, a lot of issues related to implementation of the standard.

More to come about CAM and RAID.

Credits:
http://people.freebsd.org/~gibbs/ARTICLE-0001.html
http://en.wikipedia.org/wiki/SCSI
http://en.wikipedia.org/wiki/Serial_ATA
http://www.webopedia.com/DidYouKnow/Computer_Science/2007/sas_sata.asp