# NanoBSD: Updating partition with SSH



## OlliC (May 16, 2017)

Hi,

I've got my NanoBSD installation running so far and now I was trying to update it.
It's booted into the first partition. So I want to use the updatep2 script.

This is how it says to do it:


```
# usage:
#       ssh somewhere cat image.s1 | sh updatep2
```

This is the command I tried:


```
ssh dchrist@192.168.5.10 cat /mnt/Mond/Sachen/NanoBSD/_.disk.image | sh updatep2
```

But this doesn't do anything and returns directly to shell.
This is what ssh -v gives me:


```
...
dchrist@192.168.5.10's password:
debug1: Authentication succeeded (password).
Authenticated to 192.168.5.10 ([192.168.5.10]:22).
debug1: channel 0: new [client-session]
debug1: Requesting no-more-sessions@openssh.com
debug1: Entering interactive session.
debug1: pledge: network
debug1: client_input_global_request: rtype hostkeys-00@openssh.com want_reply 0
debug1: Sending command: cat /mnt/Mond/Sachen/NanoBSD/_.disk.image
debug1: client_input_channel_req: channel 0 rtype exit-signal reply 0
debug1: client_input_channel_req: channel 0 rtype eow@openssh.com reply 0
debug1: channel 0: free: client-session, nchannels 1
debug1: fd 1 clearing O_NONBLOCK
Transferred: sent 1880, received 215924 bytes, in 0.1 seconds
Bytes per second: sent 15939.0, received 1830640.7
debug1: Exit status -1
root@nanobsd-nas:~ #
```

So the command seems to be sent and the paths are all correct. Does somebody know what the problem might be?

Edit: The same happens when using nc to transfer the image like described in the FreeBSD documentation. 
I run this on the host:


```
nc -l 2222 < _.disk.image
```

and then this happens on the nanobsd machine: 


```
root@nanobsd-nas:~ # nc 192.168.5.10 2222 | sh updatep2
root@nanobsd-nas:~ #
```


----------



## OlliC (May 16, 2017)

Ok I think I found the problem. 

The first thing the script updatep2 does is this:


```
# Blow away old system.
dd if=/dev/zero of=/dev/${NANO_DRIVE}s2 bs=1m count=1 > /dev/null 2>&1
```

If I run this with the variable ${NANO_DRIVE} inserted from /etc/nanobsd.conf which is "NANO_DRIVE=ufs/nanobsd" I get this:


```
# dd if=/dev/zero of=/dev/ufs/nanobsds2 bs=1m count=1
dd: /dev/ufs/nanobsds2: Operation not supported
```

These are the UFS device labels: 


```
# ls -l /dev/ufs/
total 0
crw-r-----  1 root  operator  0xb2 May 16 12:50 nanobsds1a
crw-r-----  1 root  operator  0xb3 May 16 12:50 nanobsds2a
crw-r-----  1 root  operator  0xab May 16 12:50 nanobsds3
```

So is this a bug in the script or what is going on?


----------



## Phishfry (May 17, 2017)

2 things come to mind. Did you add the ssh 'allow root' settings to your cfg file?
What about NanoBSD read only slices, how will that affect saving your ssh keys on first go.

# We allow root to ssh directly
customize_cmd cust_allow_ssh_root


----------



## OlliC (May 17, 2017)

Yes *I* have that setting. Otherwise *I* wouldn't be able to log into the NanoBSD box. This is the other way round. From the NanoBSD box I ssh into my ArchLinux machine where I have the _.disk.image.

I think it's not a SSH problem. Doing `ssh dchrist@192.168.5.10 cat /mnt/Mond/Sachen/NanoBSD/_.disk.image` works fine and *I* see the file flying by in the terminal.

I think it's a problem of this update script. In particular this part here:


```
# dd if=/dev/zero of=/dev/ufs/nanobsds2 bs=1m count=1
dd: /dev/ufs/nanobsds2: Operation not supported
```


----------



## OlliC (May 17, 2017)

So apparently the update scripts are broken when using disk labels. I have found this discussion from 2013 about the topic: 

http://markmail.org/message/ez6ybarr5cwcguun

I need to use disk labels because otherwise the image would not boot from a USB stick on my server. The more I try this NanoBSD thing the more I think its an unmaintained mess nobody uses.


----------



## Phishfry (May 17, 2017)

It does seem like the handbook shows 4 easy bullet points to building an image but in reality it needs help.
Like I said earlier pfSense, Nas4Free, FreeNAS and OpnSense are all using it. I wish it were better documented.


----------

