# How to merge different mount points into the root filesystem?



## Goette (Dec 22, 2012)

Say that I use the default partitioning scheme, which is



```
[pcbsd@pcbsd-1126] ~% df -h
Filesystem            Size    Used   Avail Capacity  Mounted on
/dev/label/rootfs0      2G    409M    1.4G    22%    /
devfs                 1.0k    1.0k      0B   100%    /dev
/dev/label/var0         2G    457M    1.4G    25%    /var
/dev/label/usr0        42G    9.2G     30G    23%    /usr
procfs                4.0k    4.0k      0B   100%    /proc
```

Basically I want to get rid of 'var0' and 'usr0' partitions and integrate them into 'rootfs0'.

How can I do this?


----------



## wblock@ (Dec 22, 2012)

I had a long answer written which Firefox helpfully erased thanks to the middle mouse button.

The short answer is that with your partitions the way they are, you can't.  / is not big enough to hold the others.

Back up, repartition and restore.  See Disk Setup On FreeBSD and Backup Options For FreeBSD.

Before you do that, reconsider.  One big filesystem for everything has disadvantages.


----------



## jb_fvwm2 (Dec 22, 2012)

I had to do this once, /var into the root (Bad disk sectors).  I used mtree   then rsync ; rewrote fstab then rebooted.  (The disk has been since replaced).   But as you see, the root filesystem has enough space just for /var in this case.


----------



## Goette (Dec 22, 2012)

wblock@ said:
			
		

> I had a long answer written which Firefox helpfully erased thanks to the middle mouse button.



And hitting back (backspace) didn't bring back the filled textbox?



			
				wblock@ said:
			
		

> Before you do that, reconsider.  One big filesystem for everything has disadvantages.


For example, what should I be aware of?


----------



## wblock@ (Dec 22, 2012)

Goette said:
			
		

> And hitting back (backspace) didn't bring back the filled textbox?



No, just back to before I started typing.



> For example, what should I be aware of?



Long fsck(8) times on a big filesystem, for a start.  Separation of the bare minimum base from all the add-ons, too.

One big filesystem does have advantages if space is really limited.


----------



## nakal (Dec 22, 2012)

You should consider that each filesystem has special read/write access characteristics and different backup strategies.

The tools dump(8) and restore(8) can be used for copying the files properly (especially for restore(8) it does not matter what partition layout you use when restoring the previously backuped files).


----------



## Goette (Dec 22, 2012)

nakal said:
			
		

> You should consider that each filesystem has special read/write access characteristics and different backup strategies.
> 
> The tools dump(8) and restore(8) can be used for copying the files properly (especially for restore(8) it does not matter what partition layout you use when restoring the previously backuped files).



The main have exactly the same partition type and mount options:

```
[pcbsd@pcbsd-1126] ~% cat /etc/fstab 
# Device		Mountpoint		FStype		Options	Dump Pass
/dev/label/rootfs0	/		ufs	rw,noatime	1	1
/dev/label/swap1	none		swap	sw	0	0
/dev/label/var0	/var		ufs	rw,noatime	1	1
/dev/label/usr0	/usr		ufs	rw,noatime	1	1
procfs			/proc			procfs		rw		0	0
linprocfs		/compat/linux/proc	linprocfs	rw		0	0
```


----------



## Goette (Dec 23, 2012)

ok this is how I made it:

1) Reboot from a FreeBSD live cd. Personally I used mfsBSD which wasn't the best idea, since it's old and does not support ufs with journaling. At distrowatch you can see more alternatives

2) Attach a new disk / pendrive empty

3) Create a gpt partition on new disk (skip boot partition and other)

4) Create partition with ufs filesystem

5) Format the new filesystem and then label it 'newfs'

6) Mount 'newfs' and then copy into it the partitions in the old drive: 'rootfs0', 'usr0' and 'var0' each one into its corresponding folder or subfolder. Use 'rsync -a source dest' for this.

7) Unmount the old partitions and replace the four of them (3+swap) by a single one in ufs as well. The original ufs one can be enlarged, but is just more complicated. Create the swap again if necessary and label it 'swap1'

8) The newest ufs parition in the old drive, format it with ufs and label 'rootfs0' to be like before

9) rsync 'newfs' to 'rootfs0'

10) Edit 'rootfs0'/etc/fstab to comment unused entries and check that rootfs0 and swap1 are configured correctly. I've used 'nano -w /etc/fstab' for this

11) Unmount and reboot into the system


----------



## nakal (Dec 23, 2012)

I am not talking about the read/write options, but about _access characteristics_.

Namely, e.g.:
- you should treat files in /tmp differently from files in /home (or /usr/home)
- you should also treat files in /usr differently from any other filesystem
- also there is a difference between /var and other filesystems (many people don't even understand why there is /var/tmp and /tmp and install a softlink for this)

You should read up why the filesystem make sense like it is. This is quite a basic matter in Unix-like systems.


----------



## UNIXgod (Dec 23, 2012)

Look at tuning(7) for explanation of various methods for different services. It's a good read btw.


----------



## wblock@ (Dec 23, 2012)

Goette said:
			
		

> ok this is how I made it:
> 
> 1) Reboot from a FreeBSD live cd. Personally I used mfsBSD which wasn't the best idea, since it's old and does not support ufs with journaling. At distrowatch you can see more alternatives



mfsBSD is not that old, it just hasn't been rebuilt yet with 9.1.  I recommend not using SU+J, it prevents making snapshots and using dump(8).



> 6) Mount 'newfs' and then copy into it the partitions in the old drive: 'rootfs0', 'usr0' and 'var0' each one into its corresponding folder or subfolder. Use 'rsync -a source dest' for this.



rsync(1) is not the best tool for this.  It doesn't copy hard links, so the /rescue directory will get a lot bigger.  -axHAXS is better, but dump(8)/restore(8) are better yet.

You might find hier(7) helpful.


----------



## Goette (Dec 24, 2012)

wblock@ said:
			
		

> I recommend not using SU+J, it prevents making snapshots and using dump(8).


I had an error, but didn't know that journaling was the cause, the two filesystem were mounted:

```
mfsbsd# dump -C16 -b64 -OuanL -h0 -f - /p.rootfs0/ | ( cd /backup/ && restore -ruf - )
 DUMP: WARNING: Cannot use -L on an unmounted filesystem.
dump: /p.rootfs0/: unknown file system
Tape is not a dump tape
```

PC-BSD vmware and virtualbox images come with ufs journaling and soft-updates enabled, so I couldn't workaround the _dump_ issue.



			
				wblock@ said:
			
		

> rsync(1) is not the best tool for this.  It doesn't copy hard links, so the /rescue directory will get a lot bigger.  -axHAXS is better, but dump(8)/restore(8) are better yet.
> 
> You might find hier(7) helpful.



Thanks for the tip


----------



## wblock@ (Dec 24, 2012)

Goette said:
			
		

> I had an error, but didn't know that journaling was the cause, the two filesystem were mounted:
> 
> ```
> mfsbsd# dump -C16 -b64 -OuanL -h0 -f - /p.rootfs0/ | ( cd /backup/ && restore -ruf - )
> ...



That's not the SU+J error, though.  I don't know what /p.rootfs0/ is--a directory with backup files?  A mountpoint?  dump(8) works fine on unmounted filesystems specified by device path, like ada0s1a or ada0p2.



> PC-BSD vmware and virtualbox images come with ufs journaling and soft-updates enabled, so I couldn't workaround the _dump_ issue.



Boot mfsBSD from a CD on those images, determine the filesystem device paths, and use tunefs -j disable on them.


----------

