ZFS Creating a ZFS partition

Hi
I am trying to resize my Root partition by following:
The partition layout in this guide is a bit different and using (gpart delete -i 3 ada0) to delete 3rd partition. However, I have dualbooted system, with following partition scheme:
Code:
| gpart show ada0
=>        63  1465149105  ada0  MBR  (699G)
          63        1985        - free -  (993K)
        2048     4194304     1  linux-swap  (2.0G)
     4196352   104857600     2  linux-data  (50G)
   109053952  1251235840     3  ebr  (597G)
  1360289792   104857600     4  freebsd  [active]  (50G)
  1465147392        1776        - free -  (888K)
Therefore, obviously I can not issue (gpart delete -i 4 ada0) command. If we dig deeper into /dev/ada0s4, then here is its layout:
Code:
| gpart show ada0s4
=>        0  104857600  ada0s4  BSD  (50G)
          0   98566144       1  freebsd-ufs  (47G)
   98566144    5242880       2  freebsd-swap  (2.5G)
  103809024    1048576          - free -  (512M)
Now, first partition is (ada0s4a) and second, swap partition is (ada0s4b). Therefore, if want to delete this partition (/dev/ada0s4b) then what command should I use? Also, is there any 'dry' option which instead of deleting, only shows what would happen?
Thanks
 
Hi
I am trying to resize my Root partition by following:
The partition layout in this guide is a bit different and using (gpart delete -i 3 ada0) to delete 3rd partition. However, I have dualbooted system, with following partition scheme:
Code:
| gpart show ada0
=>        63  1465149105  ada0  MBR  (699G)
          63        1985        - free -  (993K)
        2048     4194304     1  linux-swap  (2.0G)
     4196352   104857600     2  linux-data  (50G)
   109053952  1251235840     3  ebr  (597G)
  1360289792   104857600     4  freebsd  [active]  (50G)
  1465147392        1776        - free -  (888K)
Therefore, obviously I can not issue (gpart delete -i 4 ada0) command. If we dig deeper into /dev/ada0s4, then here is its layout:
Code:
| gpart show ada0s4
=>        0  104857600  ada0s4  BSD  (50G)
          0   98566144       1  freebsd-ufs  (47G)
   98566144    5242880       2  freebsd-swap  (2.5G)
  103809024    1048576          - free -  (512M)
Now, first partition is (ada0s4a) and second, swap partition is (ada0s4b). Therefore, if want to delete this partition (/dev/ada0s4b) then what command should I use? Also, is there any 'dry' option which instead of deleting, only shows what would happen?
Thanks
Instead of deleting 'freebsd-swap', I use FreeBSD.xyz.img to boot via USB. Then use:
Code:
gpart add -t freebsd-zfs -a 4k ada0s4
Now, my partition layout looks like:
Code:
[root@pc /usr]# gpart show ada0s4
=>        0  104857600  ada0s4  BSD  (50G)
          0   98566144       1  freebsd-ufs  (47G)
   98566144    5242880       2  freebsd-swap  (2.5G)
  103809024    1048576       4  freebsd-zfs  (512M)
Now that partition is created. Do I have to format it (like we used to do in Linux via mkfs utility). Or now it is ready to use by mounting? But mounting is not working:
Code:
[root@pc ~]# mount -t zfs /dev/ada0s4d 1
mount: /dev/ada0s4d: No such file or directory
I am trying to follow:
But I am confused that should I follow (19.2.1 Single Disk Pool) or not? What would be my next steps?
Thanks
 
You don't actually mount partitions but filesystems. As Beastie mentioned, partitions are created empty.
Have you formatted it with newfs ?
I find the -p flag useful with gpart.
gpart show -lp ada0
 
What do you want to achieve? Since the MBR parttion of FreeBSD is set to 50 GiB, I think you won't change that unless you destroy either your FreeBSD system or the linux one.

Create a partition is one thing but you have to use zpool create in this case. And then, zfs mount. Anyway, what do you to do with a 512 MiB space?
 
You don't actually mount partitions but filesystems. As Beastie mentioned, partitions are created empty.
Have you formatted it with newfs ?
I find the -p flag useful with gpart.
gpart show -lp ada0
No, I did not format it with newfs. After reading at:
I just issued following command:
Code:
newfs -U /dev/ada0s4d
But the next part (on above webpage) is confusing for me which is:
Code:
/dev/ada1p1    /newdisk    ufs    rw    2    2
If it is a ZFS drive, then why we have to enter 'ufs' in fstab?
 
What do you want to achieve? Since the MBR parttion of FreeBSD is set to 50 GiB, I think you won't change that unless you destroy either your FreeBSD system or the linux one.

Create a partition is one thing but you have to use zpool create in this case. And then, zfs mount. Anyway, what do you to do with a 512 MiB space?
Actually, I have a dualbooted system (Linux+FreeBSD). In far future I am planning to completely ditch Linux, and move to FreeBSD. But, presently, that is not possible. And, also, my (precious) data is in ext4 drive (mounted as /home). In future I will try to convert my /home to ZFS and share between Linux and FreeBSD. But problem is that I have next-to-nill knowledge regarding ZFS.
I had some empty space (512MB) at the end of my drive, so I created a FreeBSD-zfs partition, so I can learn something about it.
However, there is one more problem that this is my production system, I don't have any data backup, so I have to be very careful regarding command execution. One wrong command can destroy everything. So, I did not touch zpool-create because I have failed to understand it.
FreeBSD handbook shed light on zfs creation, but it showing examples of a Fresh install and my system is not a Fresh install.
Therefore, presently I am struggling at zpool, zroot, stripe etc. I have to learn about it.
If you know any very basic guide about that, kindly share with me.
Thanks
 
However, there is one more problem that this is my production system, I don't have any data backup, so I have to be very careful regarding command execution. One wrong command can destroy everything.

You are playing a very dangerous game, if you have important data you should really back it up before trying to modify the layout of your disk.
 
See how much data is used on up the disks with du -m /usr/home (or other directory, this command takes a while), or with df -m. -m is for megabytes, -g is for gigabytes. If it's a low enough amount, see about a flashdrive for backing up important files. Refurbished harddisks also are cheap, and can be suitable for partitions that don't have user files. Save your configuration files too.
It would seem better to have the /usr/home partition on a different disk.

Did you turn your swap partition off before deleting it? swapinfo -m is to view it. swapoff and swapon are the self descriptive commands.
 
See how much data is used on up the disks with du -m /usr/home (or other directory, this command takes a while), or with df -m. -m is for megabytes, -g is for gigabytes. If it's a low enough amount, see about a flashdrive for backing up important files. Refurbished harddisks also are cheap, and can be suitable for partitions that don't have user files. Save your configuration files too.
It would seem better to have the /usr/home partition on a different disk.

Did you turn your swap partition off before deleting it? swapinfo -m is to view it. swapoff and swapon are the self descriptive commands.
I created new partition from Live CD, thus swap was turned off. I double checked it though.
Regarding data backup, we are talking about 700GB of data :)
 
What I advise you is to install the latest FreeBSD RELEASE on a different system: another computer or a Virtual Machine. Then, you will be free to play with zfs and FreeBSD without any risk.

Running commands like gpart, zpool or zfs can lead to desaster unless you know exactly what you do.
 
Instead of deleting 'freebsd-swap', I use FreeBSD.xyz.img to boot via USB. Then use:
Code:
gpart add -t freebsd-zfs -a 4k ada0s4
Now, my partition layout looks like:
Code:
[root@pc /usr]# gpart show ada0s4
=>        0  104857600  ada0s4  BSD  (50G)
          0   98566144       1  freebsd-ufs  (47G)
   98566144    5242880       2  freebsd-swap  (2.5G)
  103809024    1048576       4  freebsd-zfs  (512M)
Now that partition is created. Do I have to format it (like we used to do in Linux via mkfs utility). Or now it is ready to use by mounting? But mounting is not working:
Code:
[root@pc ~]# mount -t zfs /dev/ada0s4d 1
mount: /dev/ada0s4d: No such file or directory
I am trying to follow:
But I am confused that should I follow (19.2.1 Single Disk Pool) or not? What would be my next steps?
Thanks

It does not get very clear what exactly are you trying to achieve here, so let me see if I understand correctly. You want to:
* Delete your partition #3 (ebr, 597G)
* Resize your root partition (which is UFS).
Is this correct?
What does ZFS have to do with this operation, I am still puzzled why are you trying to create a ZFS partition?

If you want to resize your root partition, it can't be done with the free space in front of it. You need to move the root partition to the beginning of the free space first. But I see that your root is nested inside a slice and has the swap right after it, so you need to get the swap out of the way. In my opinion easiest is to delete the swap partition, delete "ebr" partition. Then move the slice to the beginning of the free space and expand it to take the whole free space. Then expand your root (and leave room for a new swap partition). Then recreate the swap.
It's a lot of work and quite a bit of tinkering with the storage, so definitely make a good backup beforehand.

Also, if you want a ZFS file system, you cannot just mount the partition right after you create it. You need to format it by creating a ZFS pool., which will mount it automatically (no mount, no fstab).
1. Create a freebsd-zfs partition.
2. Create a ZFS pool on it with zpool create.
3. Create some ZFS datasets with zfs create.
The ZFS pool can be analyzed with zpool status and zfs list.
 
Yes, I know, but presently I don't have anything to backup my data on it :-(
Then most definitely do not change anything in the partitioning layout, unless losing the data is fine for you. Moving and resizing paritions is quite risky and can easily go sour. For example if your power goes out for 10 seconds, you lose your data.
If you desperately need the free space, just delete the partition you don't need and create a new ZFS pool or a UFS volume on it, but be extra careful when entering the gpart delete parameters, or you delete your data accidentally.

If you insist on moving the partition and resizing, a safer way of doing it would be to create a new partition, then copy your root with dd(1) and then make sure it worked before deleting the old root. I would not do it without a backup though.
 
Thanks everyone for you suggestions and concern. Now I will not try to mess my production system, and install FreeBSD on virtualbox and will experiment there. If you happen to know some very basic guides about ZFS, then kindly share here. Thanks
 
Back
Top