Solved: How to add disk in a virtual box VM

To add new disk in Virtual box VM it should be in powered off state.

  • Select the Virtual box VM in which you want to add the disk and power off the VM.
  • Right click on the VM and go to “Settings” .

Select “Storage” .

  • In the right Window you will see two icons with + sign.
  • Hover the mouse on the icon which says “Adds Hard Disk” and click on it.

  • Click on “Create New Disk”
  • Select VDI
  • Select “Dynamically Allocated”
  • Give disk a name and select size.
  • Click Create
  • Click OK

Once the disk is  created start the VM and login to it.

  • You should now see the new disk in VM.
  • If the disk is not visible run OS commands to scan the disk.

For Solaris execute “devfsadm -Cv” in the OS to scan the disk.

And if you are using Linux follow this post for scanning new LUNs .

Hope this post is helpful to you. Do let us know if you have any query.

How to take zfs snapshot and rollback

In this post we will discuss how to take ZFS snapshot and restore data using that snapshot.

If you want to take snapshot of a ZFS filesystem the syntax is simple.

zfs snapshot pool/filesystem@somename

Let’s take an example, we have a zpool named “cvpool” and it has a filesystem “cldvdsfs”.

  • If we wanting​ to take a snapshot of this filesystem on weekend we will give snapshot a name let’s say “sunday”.
zfs snapshot cvpool/cldvdsfs@sunday
  • Now if you do a “zfs list” you should see the zfs snapshot.
# zfs list
cvpool                     500M 4.40G 22K /cvpool
cvpool/cldvdsfs             22K 500M  22K /cvpool/cldvdsfs
cvpool/cldvdsfs@sunday        0   -   22K   -
  • Have a look at the content of the filesystem. We can see 5 test files.
# cd /cvpool/cldvdsfs

# ls
test1 test2 test3 test4 test5


  • If you want to do a rollback/restore of this snapshot on the filesystem you can simply do it by:-
zfs rollback pool/filesystem@sunday
  • Let’s give it a try  by removing some files.
# rm test5
# rm test4
# ls
 test1 test2 test3
  • Now when we try rollback we should see all our data back.
# zfs rollback cvpool/cldvdsfs@sunday

# cd /cvpool/cldvdsfs
# ls
 test1 test2 test3 test4 test5

So we can see above we got our removed files back.

Remote backup

  • Let’s try sending the snapshot on a different filesystem or on a remote server NFS filesystem. This is very useful for backup purposes where the data is stored on a different server.
# zfs send cvpool/cldvdsfs@sunday > /remoteNFS/sunday.snap
  • Let’s check our snapshot size
-rw-r--r-- 1 root root 14K Sep 23 07:52 sunday.snap
  • Zip the snapshot

You also have an option to zip the snapshot to save space. Like in below example the snapshot got shrinked by 94% .

# gzip -9 -v /remoteNFS/sunday.snap
 /remoteNFS/sunday.snap: 94.0% -- replaced with /remoteNFS/sunday.snap.gz

-rw-r--r-- 1 root root 899 Sep 23 07:52 sunday.snap.gz
  • Now let’s  create a new ZFS filesystem sunday and try to restore the snapshot on it.
# zfs create cvpool/sunday

# zfs list
 cvpool 500M 4.40G 22K /cvpool
 cvpool/cldvdsfs 22K 500M 22K /cvpool/cldvdsfs
 cvpool/cldvdsfs@sunday 0 - 22K -
 cvpool/sunday 21K 4.40G 21K /cvpool/sunday
  • Currently our new filesystem has nothing in it.
# cd /cvpool/sunday
# ls

Unzip the snapshot

Let’s unzip and restore the snapshot.

# gzip -d -c /remoteNFS/sunday.snap.gz | zfs receive -F cvpool/sunday

Note:- When you restore the snapshot the filesystem /cvpool/sunday should not be in use else you will get device busy error.

  • We can now see our files in the the sunday filesystem.
 # cd /cvpool/sunday
 # ls
 test1 test2 test3 test4 test5
  • You can make the restored snapshot as your main filesystem by renaming it.

So here we will first rename the current filesystem to old.

 # zfs rename cvpool/cldvdsfs cvpool/cldvdsfs.old
 # zfs list
 cvpool 500M 4.40G 24K /cvpool
 cvpool/cldvdsfs.old 40K 500M 22K /cvpool/cldvdsfs.old
 cvpool/cldvdsfs.old@sunday 18K - 22K -
 cvpool/sunday 22K 4.40G 22K /cvpool/sunday
 cvpool/sunday@sunday 0 - 22K -
  • Now we will make the filesystem which was restored from sunday snapshot as main.
 # zfs rename cvpool/sunday cvpool/cldvdsfs
 # zfs list
 cvpool 500M 4.40G 24K /cvpool
 cvpool/cldvdsfs 40K 4.40G 22K /cvpool/cldvdsfs
 cvpool/cldvdsfs@sunday 18K - 22K -
 cvpool/cldvdsfs.old 40K 500M 22K /cvpool/cldvdsfs.old
 cvpool/cldvdsfs.old@sunday 18K - 22K -

Crash course on zpool and zfs in Solaris

In this post we will have a look on how to use zpool and zfs in Solaris.

We will start after labeling a new disk c0t2d0.

Create zpool

  • Once we have labelled the disk let’s add it in a zpool “cvpool” .
# zpool create cvpool c0t2d0
  • Let’s see our new pool.
# zpool list
 cvpool 4.97G 95.5K 4.97G 0% ONLINE -

Create new ZFS

  • So our pool is ready now let’s create a ZFS filesystem in it.
# zfs create cvpool/cldvdsfs
  • Ok that was easy. Have a look at what ZFS we have created.
# zfs list
cvpool              104K   4.89G     21K   /cvpool
cvpool/cldvdsfs     21K    4.89G     21K   /cvpool/cldvdsfs
  • Check if our filesystem is mounted.
# df -h | grep -i cldvdsfs
 cvpool/cldvdsfs 4.9G 21K 4.9G 1% /cvpool/cldvdsfs

Restrict ZFS

  • Above we can see that the filesystem is having 4.9GB which is actually the complete zpool size.
  • We don’t want to give the full pool to one filesystem so let’s restrict it to 500MB .
# zfs set quota=500m cvpool/cldvdsfs
# zfs set reservation=500m cvpool/cldvdsfs
  • Now if we check again the filesystem we can see it’s now has total size of 500MB only.
# df -h | grep -i cldvdsfs
 cvpool/cldvdsfs 500M 21K 500M 1% /cvpool/cldvdsfs

Grow or extend ZFS

  • What if you want to grow or extend the filesystem. Well that’s also easy. If you have free space available you can increase the FS by just changing quota and reservation. If you want to know how to add new disks in a pool refer this post .
# zfs set quota=700m cvpool/cldvdsfs
# zfs set reservation=700m cvpool/cldvdsfs
  • So above we have increased the FS size to 700MB. Let’s see if it reflects in “df -h” command.
 # df -h | grep -i cldvdsfs
 cvpool/cldvdsfs 700M 21K 700M 1% /cvpool/cldvdsfs

Yes it does!!

View ZFS properties

  • You can see the properties assigned to a ZFS filesystem by running a zfs get.
# zfs get all cvpool/cldvdsfs

Rename ZFS mountpoint

  • Now if you don’t like the mountpoint name of the ZFS filesystem and want to rename it to say  /cldvdsfs_new. You can do it by modifying the mountpoint property.
# zfs set mountpoint=/cldvdsfs_new cvpool/cldvdsfs
  • If we look in df command output we can see the mountpoint name changed.
# df -h | grep -i cldvdsfs
 cvpool/cldvdsfs 700M 21K 700M 1% /cldvdsfs_new

Mirror zpool and zfs

  • If you want to mirror your ZFS filesystem you can do it by mirroring the zpool.
# zpool attach cvpool c0t2d0 c0t3d0
  • If we check status of the zpool we can see the disks are mirrored.
# zpool status cvpool
 pool: cvpool
 state: ONLINE
 scrub: resilver completed after 0h0m with 0 errors on Thu Sep 21 07:42:35 2017

 cvpool ONLINE 0 0 0
 mirror-0 ONLINE 0 0 0
 c0t2d0 ONLINE 0 0 0
 c0t3d0 ONLINE 0 0 0 117K resilvered

errors: No known data errors

Delete zpool and ZFS

  • If you want to delete a zfs file system you can do it with destroy command. It will automatically unmount the filesystem if it’s not in use.
zfs destroy cvpool/cldvdsfs
  • Finally delete the zpool.
# zpool destroy cvpool

Hope this post is helpful to you. Do let me know if you have any query.

Solved: Error on labeling the disk

You may get below error when you are trying to label a new disk in Solaris.

format> la
 WARNING - This disk may be in use by an application that has
 modified the fdisk table. Ensure that this disk is
 not currently in use before proceeding to use fdisk.


Before you proceed for the solution ensure that this is the correct disk which you want to label.

  • Once you are sure about the correct disk, select the disk from the format menu.
  • Before you try labeling the disk execute “fdisk” while in format menu.
format> fdisk
 No fdisk table exists. The default partition for the disk is:

a 100% "SOLARIS System" partition

Type "y" to accept the default partition, otherwise type "n" to edit the
 partition table.
  • Once you press “y” it will accept the default disk layout.
  • Now you can also change the disk layout format as per your requirement and finally label the disk.