# RPI2b and FreeBSD with external HD



## Vctrsnts (May 6, 2018)

Hi

I have an RPI2B with FreeBSD 11.1 and at the moment it is working correctly, but now I want to install the system on an external hard drive, in order to extend the life of the SD.

So, what I'm trying to do is copy the system (/, / usr, / etc, / tmp, / var) to the external hard drive, but I can not get it.

I have tried with `dd`, `dump`, `cp`, but I have not managed to copy the information correctly, or I am not using the correct instructions to do so.

Looking for information to do so, I have seen that if you enter the rpi as a simple user, it is easier to do so, but I have not been able to enter as a simple user in the RPI either.

Can someone help me, to solve this problem.

Thank you


----------



## Phishfry (May 6, 2018)

I have used an external hard drive to compile the Pi2 kernel with /usr/obj and usr/src mounted on the USB drive.
Not sure that you can move the whole system off the microSD card.
I believe you must keep /boot with FreeBSD uboot and the dtb's on the SD card.
Linux uboot is different and you can uboot off of hard disk and usb thumbdrives as well as microSD.
With FreeBSD uboot I have only seen microSD and PXE booting. Maybe its possible but I have seen no examples.


----------



## Vctrsnts (May 7, 2018)

Hi.

Thanks a lot

Ok, is impossible move all system in a external HD, but is possible put :

/usr
/usr/home
/tmp
/var
This is possible?

How?

Thanks a lot...


----------



## Phishfry (May 7, 2018)

Yes. That is defiantly possible. So partition and format the external drive.
Then point to mountpoints in /etc/fstab. Some of these will already be there like /tmp, you just need to point to usb disk instead. Then copy over your files(not tmp) and reboot.
The only drawback of this method is if the drive does not attach via fstab then booting may fail.
So once you add them to fstab the drive must remain attached. The other way is manually mounting them.

http://www.wonkity.com/~wblock/docs/html/disksetup.html
This works good for disk formatting. I use MBR myself found at the bottom. You need to skip the bootcode + set active parts.
He also shows how to use disk labels with fstab.


----------



## Vctrsnts (May 7, 2018)

Thanks a lot


----------



## Vctrsnts (May 7, 2018)

Thanks a lot

I read the link, but I dont understand how make when copy ( for example /var, /tmp, /usr ) in the new partition?

I read when explain how make the copy the filesystem in this point :


```
See http://www.freebsd.org/doc/en_US.ISO8859-1/books/faq/disks.html#SAFE-SOFTUPDATES for more information on using soft updates on the root filesystem.

Restore data.  Labels are used in the mount command here because they’re easier to identify, but device names like /dev/da0p2 will work.
# mount /dev/gpt/gprootfs /mnt
# (cd /mnt && gzcat root.dump.gz | restore -ruf -)
# umount /mnt
```

I dont understand the proces for make secure filesystem ( /usr ) and copy in the new partition

Can help me?


----------



## Phishfry (May 7, 2018)

Yes. First thing I notice is you'r using the instructions from the top of the page for GPT disk layout.
On FreeBSD the Arm boards use MBR scheme.  I see no benefit from having your USB drive GPT layout.
Stick with the MBR instructions at the very bottom of that page.
They are very concise and exactly what you need,
If this part is tripping you up there are other ways.

```
# mount /dev/da0s1a /mnt
# gzcat root.dump.gz | (cd /mnt && restore -rf -)
# umount /mnt
```

You could simply copy using the correct options:
cp -vipr /var /mnt/var
This copy's the entire directory and sub-directories.
Usually this is not a good option especially with a usr/home/
You could upset the file ownership or file permissions.


----------



## aragats (May 8, 2018)

Phishfry said:


> You could simply copy using the correct options:
> cp -vipr /var /mnt/var
> This copy's the entire directory and sub-directories.
> Usually this is not a good option especially with a usr/home/
> You could upset the file ownership or file permissions.


You should use the "archive" mode:
`cp -a <src> <dst>`
to preserve the permissions, symlinks etc.


----------

