Virtualbox changing zfs pool device name

Discussions related to using VirtualBox on Linux hosts.
Post Reply
Jedi
Posts: 16
Joined: 21. Oct 2017, 23:34

Virtualbox changing zfs pool device name

Post by Jedi »

I am running Ubuntu 22.04 host with Ubuntu 22.04 guest both root on zfs.

Virtualbox is version 6.1

On the guest I add a new hard drive, copy the partition table over then the device name changes on rpool?!

Code: Select all

root@zen:~# zpool status -L rpool
  pool: rpool
 state: ONLINE
  scan: scrub repaired 0B in 0 days 00:01:50 with 0 errors on Sun Oct  8 00:25:51 2023
config:

	NAME        STATE     READ WRITE CKSUM
	rpool       ONLINE       0     0     0
	  sda7      ONLINE       0     0     0

errors: No known data errors
root@zen:~# lsblk | grep sd
sda      8:0    0   250G  0 disk 
├─sda1   8:1    0   512M  0 part /boot/efi
├─sda2   8:2    0     1K  0 part 
├─sda5   8:5    0     2G  0 part [SWAP]
├─sda6   8:6    0     2G  0 part 
└─sda7   8:7    0 245.5G  0 part 
sdb      8:16   0   250G  0 disk 
root@zen:~# sfdisk -d /dev/sda | sfdisk --force /dev/sdb
Checking that no-one is using this disk right now ... OK

Disk /dev/sdb: 250 GiB, 268435456000 bytes, 524288000 sectors
Disk model: VBOX HARDDISK   
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

>>> Script header accepted.
>>> Script header accepted.
>>> Script header accepted.
>>> Script header accepted.
>>> Created a new DOS disklabel with disk identifier 0xc2aba028.
/dev/sdb1: Created a new partition 1 of type 'W95 FAT32' and of size 512 MiB.
/dev/sdb2: Created a new partition 2 of type 'Extended' and of size 249.5 GiB.
/dev/sdb3: Created a new partition 5 of type 'Linux swap / Solaris' and of size 2 GiB.
/dev/sdb6: Created a new partition 6 of type 'FreeBSD' and of size 2 GiB.
/dev/sdb7: Created a new partition 7 of type 'FreeBSD' and of size 245.5 GiB.
/dev/sdb8: Done.

New situation:
Disklabel type: dos
Disk identifier: 0xc2aba028

Device     Boot   Start       End   Sectors   Size Id Type
/dev/sdb1  *       2048   1050623   1048576   512M  b W95 FAT32
/dev/sdb2       1052670 524285951 523233282 249.5G  5 Extended
/dev/sdb5       1054720   5249023   4194304     2G 82 Linux swap / Solaris
/dev/sdb6       5251072   9445375   4194304     2G a5 FreeBSD
/dev/sdb7       9447424 524285951 514838528 245.5G a5 FreeBSD

The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
root@zen:~# zpool status -L rpool
  pool: rpool
 state: ONLINE
  scan: scrub repaired 0B in 0 days 00:01:50 with 0 errors on Sun Oct  8 00:25:51 2023
config:

	NAME        STATE     READ WRITE CKSUM
	rpool       ONLINE       0     0     0
	  sdb7      ONLINE       0     0     0

errors: No known data errors
Now I can't make the pool a mirrored pool, it won't let me add the device :shock:

Code: Select all

root@zen:~# zpool attach rpool /dev/sda /dev/sdb
cannot attach /dev/sdb to /dev/sda: no such device in pool
root@zen:~# zpool attach rpool /dev/sdb /dev/sda
/dev/sda is in use and contains a unknown filesystem.
scottgus1
Site Moderator
Posts: 20945
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: Virtualbox changing zfs pool device name

Post by scottgus1 »

The only part of this where Virtualbox is involved is getting the new "drive" attached to the "motherboard". A VM log will show if this has happened.

Please start the VM from full normal shutdown, not save-state. get logged on to the desktop or command line, then shut down the VM from within the VM's OS if possible. If not possible, close the Virtualbox window for the VM with the Power Off option set.

Right-click the VM in the main Virtualbox window's VM list, choose Show in Explorer/Finder/File Manager. In the "Logs" subfolder, zip the VM's "vbox.log", and post the zip file, using the forum's Attachments tab. (Configure your host OS to show all extensions so you can find the "vbox.log", not "vbox.log.1", etc.)
Post Reply