# shrinking a FreeBSD 7 slice



## dkline201 (May 7, 2012)

HI,

I have a small FreeBSD 7.3 installation on a 160GB HDD.  When the disk was created, it had 5 slices  -  / created with 1GB,  swap created with 4GB,  /var created with 4GB, /tmp created with 4GB, and /usr created with the remainder of the 160GB disk space.

I need to create the same setup on a 40GB SSD drive  -  /, swap, /var, and /tmp will be the same sizes, except that the /usr (remainder) will obviously be MUCH smaller.

I then need to copy all of the information from the 160GB HDD slices to the respective slices on the 40GB SSD.  I KNOW that the /usr slice will be SMALLER than the remainder space on the 40GB SSD /usr slice.

I have found several methods of INCREASING the size of a partition, but not shrinking.  And if I understand what I am reading,  I need to shrink the slice, not the partition.  The drive was created with "use all available space"  on the ad4 drive and the slices are ad4s1a through ad4s1f (except ad4s1c).

And I cannot find the correct command to do the copying so that the new 40GB SSD will be a bootable device.  I think I need to create the 40GB SSD in fdisk with the five appropriate slices and then shrink /usr and copy?

I am very new at FreeBSD, so if this is a really dumb question with an obvious answer,  well, we all started from scratch at some time...

Thanks,

Dale Kline


----------



## jef (May 8, 2012)

First thing to be aware of is that, at least as I understand it, 7.3-RELEASE is EOL, so there won't be any more security updates. Good thing is you've got a little under a year left on 7.4-RELEASE. Bad thing is that the 7.x branches are aging and you probably should move "up" to an 8.x or 9.0 branch (as you're just buying a little more time by going to 7.4).

How much data do you have? If not a lot, I personally would suggest installing a fresh version of 9.0-RELEASE (and, if you feel adventurous, upgrading it to 9.0-STABLE). These days, a lot of people are using a single root partition. Once the system is up and running you can use tar to "properly" copy your home directory from your old system to your new one.

The install process has gotten a lot easier than in the 7.x days, as has the process of building and installing the system from source. On a reasonably pathetic Atom 330 a complete rebuild finishes in under three hours.

For ports, I like using ports-mgmt/portmaster. Its man page has a section on the end about rebuilding all your ports from scratch, or take the time to pare down to just what you need. Of course `# pkg_add -r <some>/<port>` is even easier if you're happy with the default options.

By going to 9.0-STABLE you get a lot of nice features you might want to explore in the future. For me the ZFS filesystem and full networking stacks in jails were enough for me to go through rebuilding several systems.


----------



## wblock@ (May 15, 2012)

FreeBSD 9 also supports TRIM, which helps keep SSDs from getting slower with use.  The default install of one big filesystem is more space-efficient for SSDs; free space is available to everything instead of being locked up in /var and /tmp.


----------



## dkline201 (May 16, 2012)

*(resolved)*

I finally found a set of instructions that worked,  or were at least close enough that I was able to make changes based on my setup and my limited FreeBSD 7 knowledge.  The only "real" change from the link below is that the ./MAKEDEV is no longer necessary in FreeBSD 7.   And since this was a small installation, the whole procedure only took about 20 minutes.

I used a F*ree*BSD 7.2 build DVD to initialize and set up the slices on the Target HDD (SSD in this case),  and then ran these instructions to do the dump and restore from the source HDD to the target.

http://www.bsdguides.org/guides/freebsd/misc/migrate_harddrive.php

And, YES,  we are upgrading this application to F*ree*BSD 9.x (work in progress),  but this had to be done NOW for compatibility with several hundreds of existing systems already installed.

"He can be taught"


----------

