Resize a partition

Hello!

First of all, I'm quite new to FreeBSD (about a month), and I'm French, so excuse me if my English is not really correct (don't hesitate to correct me ;))

I would like to resize my FreeBSD partition. I had got some other operating systems on my computer, but I removed them. So I have now a lot of free space. I wish to allocate it to FreeBSD. I found about growfs, but a part of the free space is before the OS.
How can I use the entire disk without re-installing the system please?

Thanks.
 
Well, if you read the handbook properly, it will tell you that when you install FreeBSD for the first time, prepare to install it once again later.

I guess it will take longer to resize the partitions than to dump(8) everything on an USB drive, partition it from scratch and restore it back. That's how I would do it.
 
Well, you'll be a little bit disappointed - FreeBSD is not that good with resizing partitions (or slices, as the case may be) as other OSes; especially if you have the free space before the FreeBSD partition. Not sure if even gparted can deal with it appropriately.

You could use rsync to copy the old system to new partition - depending how much free space you have and what is your FS layout right now. Or even rescue CD can help - trick is the same - create new partition, slice it , mount it somwhere and do a dump/restore or rsync -- whichever you are more comfortable with. Then you can use this system's partition for other use.

World is a better place when you use GPT instead of MBR on disks, but still doesn't solve your problem (and as of yet not possible to choose during sysinstall).

Nakal's choice suits you the best - there is just too much to deal with and it can be a big deal for a newbie.
 
lefta said:
I would like to resize my FreeBSD partition. I had got some other operating systems on my computer, but I removed them. So I have now a lot of free space. I wish to allocate it to FreeBSD. I found about growfs, but a part of the free space is before the OS.
How can I use the entire disk without re-installing the system please?

AFAIK, there aren't any utilities to do that for UFS filesystems. This isn't anything to do with the OS, it's just that no one has written one.

So back up your data, modify the disk layout, then restore. A full system backup is described in Backup Options For FreeBSD.

matoatlantis suggests rsync(1). It's a great program, and I use it a lot, but not for full system backups. There are weirdnesses in UFS that only dump(8) understands. If you're only backing up certain directories, and know for sure there is nothing more exotic than hardlinks, then rsync is fine. You might be able to back up just /etc, /usr/local/etc, and your user's home directory; then do an install, setting up the disk like you want, and copy those directories back.
 
Thanks for all your replies. I will make a new partition on my external hard drive, and make a backup as you say.
I won't need to reinstall the system, just restore the backup, right?
 
You also need to make your harddisk bootable. You need to write a boot block there.

If you have an MBR based disk read about
Code:
fdisk -B
in fdisk(8).

If you have GPT partitioning scheme, read about
Code:
gpart bootcode
in gpart(8).
 
I did a dump(8), a minimal installation and a restore(8).
I had some little problems, but nothing important. Now, almost all are fixed.

There is just a last little annoying one: my installed packages/ports is empty, so I can't know when a new release is out!
How can I fix it please?
 
lefta said:
There is just a last little annoying one: my installed packages/ports is empty, so I can't know when a new release is out!

Could you explain what you mean by that? If /usr/ports is empty, just repopulate it with portsnap(8).
 
No, /usr/ports is not empty. In desktopbsd package manager, the "Installed packages" tab is empty and when I do a pkg_version :
Code:
# pkg_version
pkg_version: no packages installed
 
I did. I backed up each slice separately and then restored them.
I tried
Code:
#make index
but nothing changed.
My ports database was not dumped, I had to reinstall it. Can it be the same problem? Where is the installed software database located?
 
First, partition is not the same as a slice. You need to backup all the filesystems separately (usually on BSD partitions).

Then, you need to chdir in every mountpoint you saved and run restore(8) there. Maybe you did not chdir and got everything restored onto the rootfs?

Example to restore /var:
Code:
mkdir /var
cd /var
restore -rf /backups/var-backup.dump
 
That is what I did. I followed the instructions given in wblock's link.
I was unable to restore from the DVD's live filesystem, so I did a minimal installation, and then restored from the OS.
Could it be problem?
If yes, how can I restore only the files I need?

PS : Installed french firefox translation today. Now 2 soft in the database...
 
You were right, nakal. /var did not restore well, I must have done a mistake somewhere.
Restoring manually, I hope it will be fixed now.
 
lefta said:
No, /usr/ports is not empty. In desktopbsd package manager, the "Installed packages" tab is empty and when I do a pkg_version :
Code:
# pkg_version
pkg_version: no packages installed

That you're using DesktopBSD probably should have been mentioned earlier. It may have a different stock partition layout.
 
Hmm... I really don't know how DesktopBSD expects the drive to be partitioned and if it expects anything at all. As long as you backed up everything correctly, the system should not be unusable, in my opinion.
 
If just /var was lost, that's probably survivable. Ports will still work, and everything can be reinstalled to recreate the database. The tricky part is figuring out which leaf ports need to be installed. Possibly there's a way to automate that, although it seems non-trivial.
 
Everything is OK now. I restored /var manually (I kept the dump).
I'm not using DesktopBSD, only the DesktopBSD tools, which provide a graphical ports manager. (Uh... Don't sure my sentence is correct... Did you understand? :$)
 
Yes and no: I copied /var files in /var, but when I restored /etc/fstab, /var became /tmp and /tmp became /var.
 
Back
Top