There are various ways you can upgrade and backup JunOS Image of Juniper SRX device. You can use either web console or command line. When performing an upgrade there is always some chances of failure. So, to be able to recover from catastrophic failures, always create a backup before upgrading the JunOS operating system.
Upgrade and Backup JunOS Image of Juniper SRX Device
In this example I am using Juniper SRX 300 to backup and upgrade firmware of the device using command-line. I will also show how to do the upgrades in SRX cluster.
Backup JunOS Image of Juniper SRX device
To create a backup to USB type the following command in operational mode
root@SRX-FW> request system snapshot media usb partition Clearing current label... Partitioning usb media (/dev/da1) ... Partitions on snapshot: Partition Mountpoint Size Snapshot argument s1a / 4.8G none s2a /altroot 4.9G none s3e /config 370M none s3f /var 4.1G none s4a /recovery/software 425M none s4e /recovery/state 38M none Copying '/dev/da0s1a' to '/dev/da1s1a' .. (this may take a few minutes) Copying '/dev/da0s2a' to '/dev/da1s2a' .. (this may take a few minutes) Copying '/dev/da0s3e' to '/dev/da1s3e' .. (this may take a few minutes) Copying '/dev/da0s3f' to '/dev/da1s3f' .. (this may take a few minutes) Copying '/dev/da0s4e' to '/dev/da1s4e' .. (this may take a few minutes) Copying '/dev/da0s4a' to '/dev/da1s4a' .. (this may take a few minutes) The following filesystems were archived: / /altroot /config /var /recovery/state /recovery/software
You can view the snapshot information on USB by typing following command,
root@SRX-FW> show system snapshot media usb Information for snapshot on usb (/dev/da1s1a) (primary) Creation date: Apr 10 04:39:55 2017 JUNOS version on snapshot: junos : 15.1X49-D45-domestic Information for snapshot on usb (/dev/da1s2a) (backup) Creation date: Apr 10 04:42:39 2017 JUNOS version on snapshot: junos : 15.1X49-D45-domestic
Just in case, to reboot the device from the backup USB stick enter the following command in operational mode
root@SRX-FW> request system reboot media usb Reboot the system ? [yes,no] (no)
Type Yes and press Enter button on the keyboard. The device will now reboot and load the OS from USB stick.
Upgrading the JunOS Software
First of all download the latest JunOS software from Juniper’s website www.juniper.net. Now copy that downloaded JunOS file into the USB stick. Remember that the USB Stick must have FAT32 file type partitioned or the upgrade won’t work. Then, log in to the device using root user. We need to mount the USB stick into the device first. Type the following command from shell prompt.
root@SRX-FW% ls /dev/da* /dev/da0 /dev/da0s1c /dev/da0s2c /dev/da0s3e /dev/da0s4a /dev/da0s1 /dev/da0s2 /dev/da0s3 /dev/da0s3f /dev/da0s4c /dev/da0s1a /dev/da0s2a /dev/da0s3c /dev/da0s4 /dev/da0s4e
After you hit enter you will see the above output. These are partitions of the JunOS in SRX. Now, insert the USB stick into the SRX device. Again type the previous command.
root@SRX-FW% ls /dev/da* /dev/da0 /dev/da0s2 /dev/da0s3c /dev/da0s4a /dev/da1s1 /dev/da0s1 /dev/da0s2a /dev/da0s3e /dev/da0s4c /dev/da1s5 /dev/da0s1a /dev/da0s2c /dev/da0s3f /dev/da0s4e /dev/da0s1c /dev/da0s3 /dev/da0s4 /dev/da1
Here we can notice that there are three new partition of the USB stick. Note that /dev/da1s1 or /dev/da1s5 is the one you must mount. Now create a folder named flash under /var/tmp. This will be the mounting location. Now type the following command to create the folder.
root@SRX-FW% mkdir /var/tmp/flashNow mount the USB stick to flash folder. To do so type following commands,
root@SRX-FW% mount_msdosfs /dev/da1s5 /var/tmp/flashNote: – You might get following error if the location you entered is not correct. You can try different location randomly (the bolded and underlined ones that are listed above)
root@SRX-FW% mount_msdosfs /dev/da1s1 /var/tmp/flash mount_msdosfs: /dev/da1s1: Invalid argument
After mounting you can view the lists of files under USB Flash Drive by typing this command.
root@SRX-FW% ls /var/tmp/flash/ System Volume Information junos-srxsme-15.1X49-D75.5-domestic.tgzJut if you need unmount the USB stick, type following cmd
root@SRX-FW% umount /var/tmp/flash
By now what we have done is, just inserted the USB in the device and the USB stick is visible. You can install JunOS directly from the USB or copy the installation file to other location and start the install. To install JunOS directly from USB type following commands,
root@SRX-FW> request system software add /var/tmp/flash/junos-srxsme-15.1X49-D75.5-domestic.tgz no-validate no-copy
You can also copy the installation file into the device’s hard disk after mounting is done. Here I will copy to /var/tmp location. To do so type following commands: –
root@SRX-FW% cp /var/tmp/flash/junos-srxsme-15.1X49-D75.5-domestic.tgz /var/tmp root@SRX-FW% ls /var/tmp/flash System Volume Information junos-srxsme-15.1X49-D75.5-domestic.tgz
After copying the file, exit from shell mode and remove the USB from device. To install the JunOS, enter the following command in operation mode.
root@SRX-FW> request system software add /var/tmp/junos-srxsme-15.1X49-D75.5-domestic.tgz no-validate no-copy partition unlink reboot
The device will install the software and reboot the SRX. In this way you can upgrade JunOS in SRX device.
Now, what if the SRX devices are in cluster. How do you perform the upgrade? To upgrade branch series SRX cluster, you need to upgrade the SRX device one by one and then reboot all device in cluster at the same time. You can mount the USB and copy installation file to say node 0 and upgrade the node 0 first. Then you can copy the file from node 0 to node 1 and then upgrade node 1. You can also use same USB to mount and copy files to node 1. To copy file from node 0 to node 1 directly, type following command,
{primary: node 0} root@host> file copy /var/tmp/junos-srxsme-10.4R8.5-domestic.tgz node1:/var/tmp
After copying the JunOS file to node 1, login to node 1 device. To switch the login, type following command.
{primary: node 0} root@host> request routing-engine login node 1
Now you can upgrade node 1 and reboot both device at the same time.