Juniper MX150 mount USB

  1. Change the shell from Junos CLI to BSD shell.
    1. user@mx150> start shell
    2. %

  2. Before inserting the USB device, check current disk device partitions. "192.168.1.1" is a fixed address for Linux host via internal connection.
    You can issue Linux command via SSH connection with Juniper private routing instance onward.
    1. % ssh -JU __juniper_private4__ root@192.168.1.1 'ls /dev/sd*'
    2. /dev/sda
    3. /dev/sda1
    4. /dev/sda2
    5. /dev/sda3
    6. /dev/sda4
    7. /dev/sda5
    8. /dev/sda6
    9. /dev/sda7 <-- Currently there is only "sda(and number at the tail)" device found
    10.  
  3. Insert USB stick to MX150 box USB port. You can check the disk partition of USB from dmesg.
    1. % ssh -JU __juniper_private4__ root@192.168.1.1 'dmesg | grep -i scsi'
    2. [600876.608516] scsi7 : usb-storage 3-1:1.0
    3. [600877.608645] scsi 7:0:0:0: Direct-Access SanDisk Cruzer Blade 1.27 PQ: 0 ANSI: 6
    4. [600877.616627] sd 7:0:0:0: [sdb] Attached SCSI removable disk <-- [sdb] is the device name
    Note: Or, you can check the disk partition of USB by lsblk command as well.
    1. % ssh -JU __juniper_private4__ root@192.168.1.1 'lsblk -S'
    2. NAME HCTL TYPE VENDOR MODEL REV TRAN
    3. sda 0:0:0:0 disk ATA StorFly VSFBM6CC 0629 sata
    4. sdb 7:0:0:0 disk SanDisk Cruzer Blade 1.27 usb <-- sdb shows usb transport type
    There is certainly such disk partition attached in Linux host.
    1. % ssh -JU __juniper_private4__ root@192.168.1.1 'ls /dev/sd*'
    2. /dev/sda
    3. /dev/sda1
    4. /dev/sda2
    5. /dev/sda3
    6. /dev/sda4
    7. /dev/sda5
    8. /dev/sda6
    9. /dev/sda7
    10. /dev/sdb <-- "sdb" device is attached. (The last letter "b" may vary depending on your circumstance.)
    11. /dev/sdb1
    12.  
  4. Create a directory for the USB drive to mount in Linux host side.
    1. % ssh -JU __juniper_private4__ root@192.168.1.1 'mkdir /var/tmp/usb'
    2. %
    3.  
  5. Mount the USB drive to the /var/tmp/usb directory in Linux host side.
    1. % ssh -JU __juniper_private4__ root@192.168.1.1 'mount /dev/sdb /var/tmp/usb'
    如果mount失敗出現下面訊息:
    1. mount: /dev/sdb is write-protected, mounting read-only
    2. mount: wrong fs type, bad option, bad superblock on /dev/sdb,
    3. missing codepage or helper program, or other error
    4.  
    5. In some cases useful info is found in syslog - try
    6. dmesg | tail or so.
    則先需格式化USB為etx4格式,使用下列指令:
    1. % ssh -JU __juniper_private4__ root@192.168.1.1 'mkfs -t ext4 /dev/sdb'
    Check if it is properly mounted in Linux host.
    1. % ssh -JU __juniper_private4__ root@192.168.1.1 'mount | grep usb'
    2. /dev/sdb on /var/tmp/usb type ext2 (rw,relatime,errors=continue,user_xattr,acl) <-- You can see this line
  6. Copy any of files:
    a.  From MX150 storage to the USB disk(/var/tmp/usb directory) with the following SCP command:

    scp -JU __juniper_private4__ <filename> root@192.168.1.1:/var/tmp/usb/
    1. % scp -JU __juniper_private4__ /var/tmp/testfile.txt root@192.168.1.1:/var/tmp/usb/ <-- source-file name is "testfile.txt" in current directory
    2. testfile.txt 100% 9 0.0KB/s 00:00 <-- transfer completed
    3.  
    4. %ssh -JU __juniper_private4__ root@192.168.1.1 'ls /var/tmp/usb'
    5. testfile.txt <-- you can see the same file in the USB mounted directory

    b.  From the USB disk to MX150 storage with the following SCP command:

    scp -JU __juniper_private4__ root@192.168.1.1:/var/tmp/usb/<filename> <target_directory_in_MX150_Junos>
    1. % scp -JU __juniper_private4__ root@192.168.1.1:/var/tmp/usb/testfile.txt /var/tmp/ <-- source-file name is "testfile.txt" in USB destins "/var/tmp" directory in MX150
    2.  
  7. Unmount the USB drive after the file is completely copied:
    1. % ssh -JU __juniper_private4__ root@192.168.1.1 umount /var/tmp/usb
    2.  

    參考: Juniper

留言

熱門文章

[美股]2021年報及未來展望

[美股]初入美股市場半年投資心路歷程&績效

主力如何控盤&台股處置制度解析

公司可以用什麼方式回饋股東