CLI method of adding and deleting a hard drive?

Status
Not open for further replies.
S

sef

Guest
Since the GUI doesn't allow me to do some of the things I'd like to do with ZFS, I have to consider ways of working around it. Unfortunately, it's not entirely clear to me how I do two basic things:

1: Add a hard drive to the system. By this, I mean partitioning it (although I think I have that figured out), and then adding it to the database(s) so that it shows up properly. (While I can simply add it to a zfs pool, that won't -- as far as I can tell by going through the scripts -- cause the swap partition to show up.)

2: Similarly, for removing a hard drive from the system. Again, I'm mostly concerned with the various databases that are maintained by the GUI.

Any pointers?

Thanks.
 

William Grzybowski

Wizard
iXsystems
Joined
May 27, 2011
Messages
1,754
Care to explain what exactly GUI doesn't allow you to do?

1. Any GPT partition of type freebsd-swap will be added on boot time

2. This was true for 8.0.x, >= 8.2 the disk database is synced automatically and it do not reflect the state of the zpool anymore (except for encrypted zpool in 8.3.1)
 
S

sef

Guest
The GUI doesn't allow me to add an Nth disk to a mirror. I've file an enhancement request for that.

Are you sure about (1)? I looked over the code that is used to generate the fstab file, and it cycled through disks in a squlite database, rather than checking the system to see which disks are attached to it. I admit I have not tested this yet (as I am being very paranoid and careful :)), so I'll be glad to find out I'm wrong.

Thank you!

eta I should make it clear I'm running 8.3.0, sorry for not saying that earlier.
 

William Grzybowski

Wizard
iXsystems
Joined
May 27, 2011
Messages
1,754
Understood.

Yes, I'm sure. There is a disk table but it is synced with the state of the system (contrary to 8.0.x that would be used to associate with a pool), think it as a cache and to hold disk information (SMART enabled?, APM, etc).
We loop through that table and search for a freebsd-swap partition type using GEOM XML.

Good luck.
 
S

sef

Guest
So, if I hot-add a disk drive, partition it to match the others, and attach it as a mirror to the existing pool (all via the command-line), then things will Just Work? Most excellent to hear! Thank you!

Perhaps I will go buy a hard drive this weekend to test it :).
 
S

sef

Guest
So, no, that didn't work.

I got another hard drive; hooked it up to the system; partitioned it manually, using

gpart create -s GPT ${DISK}
gpart add -s 4194304 -t freebsd-swap ${DISK}
gpart add -t freebsd-zfs -l a-name-i-could-remember ${DISK}

I attached it to one of the existing devices in the mirror, and ensured it was in fact resilvering.

Then I rebooted, and checked via "swapinfo -k". The new disk was not listed there.
 
S

sef

Guest
You responded while I was rebooting and verifying :).

The problem was that the disk came with an MBR; my notes file had a commented out "# May need to do "dd if=/dev/zero of=/dev/${DISK} bs=1m count=25"" line, and so I forgot to do it.

After I detached the drive, did the dd, re-partitioned, and so forth, after I rebooted it, it was there in the swap list.

Thank you VERY much; you have been very helpful, and I am quite grateful.
 
Status
Not open for further replies.
Top