Shrinking UFS and Adding new mirrored slices

Can any kind soul please give me a step by step guide to do the following:

Unmirror the current 2T root partition
Shrink the root partition to say 200G (is there an easy way ?)
Add partitions to disk to give 2 extra slices for /var/appl (600G) and /usr/home (1T)
copy existing data on /var/appl and /usr/home to new partitions
Setup new mirror slices for these new partitions which contain /var/appl and /usr/home.

Current config as follows:

OS version:
Code:
FreeBSD hostname 9.0-RELEASE FreeBSD 9.0-RELEASE #0: Tue Jan  3 07:15:25 UTC 2012     
[email]root@obrian.cse.buffalo.edu[/email]:/usr/obj/usr/src/sys/GENERIC  i386

Code:
$df
Filesystem       1K-blocks      Used      Avail Capacity  Mounted on
/dev/mirror/m0p2 1918673584 52146040 1713033660     3%    /
devfs                    1        1          0   100%    /dev

Code:
$ gmirror status
     Name    Status  Components
mirror/m0  COMPLETE  ada0 (ACTIVE)
                     ada1 (ACTIVE)

Code:
$ gpart show
=>        34  3907026987  mirror/m0  GPT  (1.8T)
          34           6             - free -  (3.0k)
          40         128          1  freebsd-boot  (64k)
         168  3898605432          2  freebsd-ufs  (1.8T)
  3898605600     8388608          3  freebsd-swap  (4.0G)
  3906994208       32813             - free -  (16M)


Your help will be much apprecicated.

A newbie to FreeBSD.

Many Thanks
 
SirDice said:
Backup and restore, that's the only way.

Dear Sir,

Thanks for your speedy reply. Can you elaborate a little bit more ?

Does that mean I have to re-install FreeBSD and repartition the second disk to the required partitions before doing backup (from 1st disk) and restore (to 2nd disk) ? (Something I try to avoid...lol)

Will "gpart resize" help at all ?
 
The traditional way to do this is to backup the data, remove the partition, create a smaller one and restore the data.

I've never used gpart resize, try it. Make sure you have a backup of the whole disk though.
 
resize is just going to delete and recreate a partition. It will not resize the filesystem on that partition, just destroy it.

There are also concerns with using gmirror(8) on a GPT disk. MBR is preferred, because it does not conflict with gmirror(8) metadata at the end of the disk.

Back it up. See Backup Options For FreeBSD.
I'd recommend setting up a new, blank disk. Create a mirror with just that one disk as a member. Use gpart(8) or fdisk(8)/bsdlabel(8) to set up MBR and the desired FreeBSD partitions on that mirror. Restore the backup to the new mirror. Do not modify the original disks; physically disconnect them and connect the new disk for testing. Once it works, the original disks can be added to the mirror.
 
wblcok,

Thanks for your reply.

wblock@ said:
I'd recommend setting up a new, blank disk.

Unfortunately, I don't have a third disk to work with.

I really hope that one can shrink a FreeBSD-ufs filesystem with live data on it.....any suggestions ?

Best Regards.
 
If you want to live dangerously, you can always break the mirror (in other words, disconnect one drive, this is you backup), clear, partition and install on the other drive, then connect your backup drive and copy the data to the new system drive. When you are happy with your new setup, clear the backup drive, partition it like the first one and mirror again.
Note: be careful, if you make a mistake, you might destroy your backup before getting the data off it.
 
Back
Top