2

So I probably lack some basic fundamental understanding when it comes to unix drives.

On amazon-ec2, I just created an instance where I specified the root device to be 30 GB. If I goto volumes I see the volume in use. But when I ssh into the system and run :

# df -h 
Filesystem    Size    Used   Avail Capacity  Mounted on
/dev/ad0a     9.9G    1.4G    7.7G    16%    /
devfs         1.0k    1.0k      0B   100%    /dev

I don't get it?!

Also, on volumes in amazon, on the details I see Attachment : /dev/sda1 , what does this really mean?

2

For the first question, your partition is 10GB, while the drive is 30. Run gpart show to see the partitions on each "drive", including the freespace. You can then figure out what size you want the partition to be and use gpart resize.

Once the partition is 30GB, or whatever size you want, run growfs to resize the filesystem on the partition. Both of these commands take more arguments than I've listed here, see their man pages for details man gpart and man growfs respectively. If you have any specific problems running the commands ask again, or drop into chat, there are a few FreeBSD experts in there.

FreeBSD is not Linux, though many people confuse the two (as did two Answerers who have subsequently deleted their wrong answers). Unfortunately Amazon is guilty too. Linux uses labeling similar to /dev/sda1 for it's first hard drive. FreeBSD uses /dev/ad0 for it's first (S)ATA hard drive (and /dev/da0 for SCSI/SAS drives, including ATAPI, USB, FireWire). Solaris uses /dev/rdsk/cWtXdYsZ... Also FreeBSD adds letters after the device name for MBR Partitions, so /dev/ad0a is the first partition of the first ATA disk. You'll also see /dev/ad0b/, for historical reasons this is the whole disk just like the device name without a partition letter.

| improve this answer | |
3

Most AMI images will expect an 8gb or 10gb root. Consider using the default 8GB and adding a second 20GB device and mounting that where you need to use the data

If you must resize, you can't do it online so you can:

  • Stop Instance
  • Create Snapshot of Volume A from Instance
  • Create Volume B from Snapshot A
  • Attach Volume B to Instance as xbdf
  • Get the new device name and size in bsd
    gpart show
  • Resize your partition (xbd5 for me)
    gpart resize -i 1 -s 30G xbd5
    The parameter to -s might need to be slightly under 30G if your partitioning uses up some free blocks at the start of the drive.
  • Grow your file system
    growfs xbd5a
  • Stop instance A
  • Detach Volume B from Instance
  • Detach Volume A from Instance
  • Attach Volume B as /dev/sda1

The root partitioning of the AMI's from here looks a little strange, I'm not quite sure that they've done so ymmv.

If you plan on creating lots of these, you might want to setup your own AMI image or snapshot your working resized volume so you can start with the same 30GB filesystem each time.

Amazon use /dev/sda1 to refer to an instances initial boot/root device. In Linux it refers to the first partition of the first device which is equivalent to /dev/ad0a in your FreeBSD.

| improve this answer | |
1

Early FreeBSD AMIs created by Colin Percival initialized the rootfs with a 10GB partition regardless of the actual volume size. That has since been fixed and the initial root partition should match the initial volume size.

If you want to increase the size of an existing volume, you need to:

1) move /dev/sda1 to a larger volume and

2) resize the root partition:

> gpart show
=>       3  62914549  ada0  GPT  (50G) [CORRUPT]
         3       125     1  freebsd-boot  (63K)
       128  62914424     2  freebsd-ufs  (30G)

> gpart recover ada0
ada0 recovered

> gpart show
=>        3  104857589  ada0  GPT  (50G)
          3        125     1  freebsd-boot  (63K)
        128   62914424     2  freebsd-ufs  (30G)
   62914552   41943040        - free -  (20G)

> gpart resize -i2 ada0
ada0p2 resized

> gpart show
=>        3  104857589  ada0  GPT  (50G)
          3        125     1  freebsd-boot  (63K)
        128  104857464     2  freebsd-ufs  (50G)

> growfs /
Device is mounted read-write; resizing will result in temporary write suspension for /.
It's strongly recommended to make a backup before growing the file system.
OK to grow filesystem on /dev/gpt/rootfs, mounted on /, from 30GB to 50GB? [yes/no] yes
super-block backups (for fsck_ffs -b #) at:
. . .

NB: the size of a FreeBSD volume can not be reduced, only increased.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.