Using the full USB Drive

Status
Not open for further replies.

DemoniK

Cadet
Joined
May 30, 2011
Messages
4
Hoping someone can help me out here..
I installed FreeNAS 8 from ISO to my USB Drive. A nice fast 8GB drive.
However, it's only using 1GB of the usable space, and am running into issue as I try to add packages/ports for various software I need/want to run on there.

So I'd really like to increase the / partition from 499MB to 6GB and the /data from 498MB to 1GB.

If this was Linux I'd have this sorted in a jiffy, but am having difficulties removing, adding partitions in freeNAS/BSD and hoe someone can steer me right here...

So what have I done so far...
First off - I installed FreeNAS to 2 USB Drives. DriveA is a 16GB drive which I just want to use to create a proper installation on DriveB which is an 8GB device..

So I boot DriveA, all is good and I can see da1 appearing once I add in DriveB.
I have a 3rd drive which I use for storage, mount it and then dd partitions/slices s2, s3 & s4 to it..
Now I want to move the 3 paritions to their rightful places, and grow the / and /data filesystems.
I gpart delete the s2, s3 & s4 partitions..
I resize the s1 partition to 6GB.

Now I try to resize the filesystem using growfs and it won't let me.
fdisk still reports that there are unused partitions at the original entries
I've tried gpart commit, rebooting, etc.. Still fdisk reports the original 4 partitions, but now there are inconsistencies since partition s1 goes beyond the other 4.

I'm lost at this point. Clearly I've missed a step or just gone completely down the wrong direction.
I've googled and googled and found nothing about helping me to move paritions around.. Plenty on creating partions - but I can't remove them, or move them..

Anyone got any ideas?
Should I maybe consider a freeNAS build environment and maybe change the scripts for creating the images?
 

jfr2006

Contributor
Joined
May 27, 2011
Messages
174
That's why in the older forum i asked if i could create a bootable cd with the full install version of freenas 8. But it seems we can't. In the full install version 7, you could choose the size of the install partition. On 8, whe can't since this option is not given :(

If you find some easy way the increment the size of the partition, let us know!

Regards.
 

rjgould

Dabbler
Joined
May 28, 2011
Messages
32
Another +1 here. I'm happy to install my own additional software at the moment but thus far the limit has been installing Transmission because attempting to install anything else alongside just results in the USB stick being out of disk space.
 

DemoniK

Cadet
Joined
May 30, 2011
Messages
4
Success :)
Well nearly.

BTW - before I start - please don't get upset that I use partition and not slice - I'm new to BSD so this makes more sense to me..

Here's what I did..
I needed 3 USB drives in the end - will explain as I go through the steps.

First off - installed freeNAS 8 to 2 seperate USB drives
Then boot off 1 and we'll modify the other..

next some prep - and this is where I need the 3 drives
I mount the 3rd drive first
Code:
mount -t msdosfs /dev/da2s1 /data/da2s1


Then take images of the 3 partitions I'm about to blow away
Code:
dd if=/dev/da1s2 of=/da2s1/da1s2.img
dd if=/dev/da1s3 of=/da2s1/da1s3.img
dd if=/dev/da1s4 of=/da2s1/da1s4.img


Once done you need to now get a bit of info together
Code:
%fdisk -s da1
/dev/da1: 983 cyl 255 hd 63 sec
part        Start        Size Type Flags
   1:          63      953505 0xa5 0x80
   2:      953631      953505 0xa5 0x80
   3:     1907136        3024 0xa5 0x80
   4:     1910160       41328 0xa5 0x80

%gpart show da1
=>      63  15794100    da1   MBR   (7.5G)
        63    953505      1   freebsd   [active]   (466M)
     ...

The first important thing is the size of the disk - 15794100 in my case.

I used this to then work backwards to calculate what I need to set the new partitions to.
Code:
=>      63  15794100  da1  MBR  (7.5G)
        63  13847967    1  freebsd  [active]  (6.6G)
  13848030   1895670    2  freebsd  (926M)
  15743700      6048       - free -  (3.0M)
  15749748      3024    3  freebsd  (1.5M)
  15752772     41328    4  freebsd  (20M)
  15794100        63       - free -  (32K)

Am sure if you know how to calculate proper paritioning from CHS I could probably have gotten rid of the free space - but honestly, I can put up with 3M loss instead of 7G!

Now I know my sizes and offsets I can edit the partition table
Code:
fdisk -u da1

Just answer Y to edit each partition and update the offset and size according to your numbers from previous step. If you get warnings about starting the partition on correct sector, just let it autocorrect.
It took me a few iterations to get a final set - as you can see with the 32K free space at the end ;)

Once you have the partitions updated - you now need to put back the old partitions
Code:
dd of=/dev/da1s2 if=/da2s1/da1s2.img
dd of=/dev/da1s3 if=/da2s1/da1s3.img
dd of=/dev/da1s4 if=/da2s1/da1s4.img


now to resize that all important / partition.
First up we need to adjust the label on the partition itself
as a precaution - dump your current label
Code:
%bsdlabel da1s1 > /data/da2s1/saved.label

It will look something like
Code:
# /dev/da1s1:
8 partitions:
#        size   offset    fstype   [fsize bsize bps/cpg]
  a:   953489       16    unused        0     0       
  c:   953505        0    unused        0     0         # "raw" part, don't edit

Note the 16 - this is important..
Now we can edit
Code:
%bsdlabel -e da1s1

Remember your partition1 size - mine was 13847967
I need to edit the size for c: to be this number, and for a: to be this number -16 (the offset)
results in
Code:
# /dev/da1s1:
8 partitions:
#        size   offset    fstype   [fsize bsize bps/cpg]
  a: 13847951       16    unused        0     0       
  c: 13847967        0    unused        0     0         # "raw" part, don't edit


Now we're ready to grow the filesystem to match
Code:
%growfs -s <size> da1s1a

Where <size. is the size of your a: partition above..

Now I reboot
It works - but I have 2 issues..

1. On reboot it can't find /ufs/FreeNASs1 and I explcitly have to tell the bootloader the root is on ufs:/dev/da0s1a
I checked out using bsdlabel and tunefs - but neither seem to work. Anyone know how I can fix this?

2. I didn't resize the 2nd partition. Anyone know what this one is used for? Everything is working so again, I'm happy to leave a few 100MBs of loss over Gs of loss..
 

Freezor

Cadet
Joined
Jun 10, 2011
Messages
2
Hi,

I'm trying the same thing and have followed the instructions posted here in the thread which did not quite work out for me because I had problems with getting the right partition sizes.

So I went on and partitioned my 4GB SD-Card using MiniTool Partition Wizard Home Edition 6.0 under WinXP. I then worked out of VMware running Live-FreeBSD-8.2 and with a 2nd USB stick where I had the original FreeNAS "dd"-ed to.

I just followed the rest of the instructions from here and am now getting the same problem where I have to manually tell the bootloader where my root-partition is.

I've done some more research and found this site:

http://www.freebsd.org/cgi/man.cgi?query=glabel&sektion=8

I think using glabel label FreeNASs1a /dev/da0s1a (for example) should solve the problem for mounting the root-partition

I don't know if I'll have time this weekend to try it but I will post the results as soon as I get a chance to.

greetz,
Steve
 

Casper23

Cadet
Joined
Jun 11, 2011
Messages
1
Hi DemoniK, thanks for your well written guide to expanding the partitions. It took me a while to get the partition information correct, I was fooled by some of information of the default FreeNAS image. Mainly the size of the "number 2" partition but I won't get into that. Once I got that going I started receiving the same error about unable to mount /dev/ufs/FreeNASs1a after a ton of reading and getting a good understanding I realized what is going on. The label for the FreeNASs1a disappears after you do the growfs command. You have to recreate the label for the new partition since the metadata for the partition was lost after you resize the partition. Now this can be done a couple of different ways (so I have read) and at first I couldn't get any of them to create a new FreeNASs1a label for anything. Since everything said I should use tunefs over newfs since it was an existing filesystem I keep trying the command but nothing would show up in the /dev/ufs/ directory. Guess what... for some reason it was creating it in the /dev/label/ directory instead of the /dev/ufs directory. Once I found this out I edited the /conf/base/etc/fstab folder to point to the new directory for the label and reboooted and all was well. I am not sure if the problem is a bug with tunefs or I am missing a parameter to have it created in the /dev/ufs/ folder, either way it works without user intervention on a boot now.

I hope this info helps someone and saves them the hours it took me to get it working ;p

Steps:
1) Boot FreeNAS in single user mode (choice 4 on FreeNAS 8)
2) When prompted for the what system to mount type ufs:/dev/da0s1a (da0 is my USB device yours may differ)
3) At the # prompt type: tunefs -L FreeNASs1a /dev/da0s1a (again use your device if it differs)
4) Check the /dev/label/ folder for the new FreeNASs1a label
5) Put the filesystem in write mode: mount -uw /
6) Edit the file with: vi /conf/base/etc/fstab
7) Change the first line from: /dev/ufs/FreeNASs1a / ufs ro 1 1 to: /dev/label/FreeNASs1a / ufs ro 1 1
8) Reboot and see if it worked for you.

Good luck and I hope it works for you.
 

volkov_an

Cadet
Joined
Jun 22, 2011
Messages
1
Hi!
Please help to sort out.
DemoniK technology is too complex for me.
The new drive I would space sysinstall, copied sections dumps FREENAS

dd if =/dev/da1s1 of =/da2s1/da1s1.img
dd if =/dev/da1s2 of =/da2s1/da1s2.img
dd if =/dev/da1s3 of =/da2s1/da1s3.img
dd if =/dev/da1s4 of =/da2s1/da1s4.img

On reboot it can't find/ufs/FreeNASs1 and I have to tell the explcitly bootloader the root is on ufs:/dev/da0s1a

on the advice of Casper23:
3) At the prompt type: # tunefs-L FreeNASs1a/da0s1a (again use your device if it differs)
a write error occurs superblock!

It stalled. I need your help.
Please excuse my bad English

P.S.
Tool for clone HDD on FreeBSD - also not helped.
http://sourceforge.net/projects/clonehdd/
 

DemoniK

Cadet
Joined
May 30, 2011
Messages
4
On reboot it can't find/ufs/FreeNASs1 and I have to tell the explcitly bootloader the root is on ufs:/dev/da0s1a

on the advice of Casper23:
3) At the prompt type: # tunefs-L FreeNASs1a/da0s1a (again use your device if it differs)
a write error occurs superblock!

Yes - this was the issue I had and Casper23 provided a workaround.
You see this error if you haven't got the / partition mounted as read only - either you haven't booted into single user mode (pressing 4 at boot menu) or have mounted it rw and then did the tunefs.

His workaround doesn't fix it for me - for some reason tunefs does label the partition, but it doesn't appear in /dev/ufs or /dev/label for me :(
So I've modifed the fstab file to mount root from /dev/da0s1a and not /dev/ufs/FreeNASs1a
This isn't ideal but it boots and I'm up and running reliably for now :)
 
Status
Not open for further replies.
Top