-
Notifications
You must be signed in to change notification settings - Fork 0
How to add swap space to a roboRIO
This only need to be done once for a thumb drive, unless the drive is reformatted.
-
Use putty to connect to the roboRIO (address 172.11.22.1 if connected via USB, 10.36.20.2 if connected via wireless or Ethernet). The userid is 'admin', and there is no password.
-
Insert the thumb drive you will use as swap space in the roboRIO. All contents of the thumb drive will be destroyed. Doug recommends using the low profile black thumb drives for swap files, and saving the red ones for log files.
-
Use the
dfcommand to see if there are any mounted partitions on the thumb drive. If so, useumountto unmount them.
admin@roboRIO-3620-FRC:~# df Filesystem 1K-blocks Used Available Use% Mounted on ubi1:rootfs 395580 141628 249116 36% / devtmpfs 124564 4 124560 0% /dev tmpfs 125076 152 124924 0% /run tmpfs 65040 128 64912 0% /var/volatile ubi0:bootfs 50128 46876 3252 94% /boot ubi0:config 2012 84 1792 4% /etc/natinst/share /dev/sda2 3937324 7832 3729480 0% /media/sda2 /dev/sda3 1762160 4 1762156 0% /media/sda3 admin@roboRIO-3620-FRC:~# umount /dev/sda2 admin@roboRIO-3620-FRC:~# umount /dev/sda3 admin@roboRIO-3620-FRC:~# df Filesystem 1K-blocks Used Available Use% Mounted on ubi1:rootfs 395580 141624 249120 36% / devtmpfs 124564 4 124560 0% /dev tmpfs 125076 152 124924 0% /run tmpfs 65040 128 64912 0% /var/volatile ubi0:bootfs 50128 46876 3252 94% /boot ubi0:config 2012 84 1792 4% /etc/natinst/share admin@roboRIO-3620-FRC:~#
- Make sure you have one and only one sd* device. If you have more than one, stop and get a mentor.
admin@roboRIO-3620-FRC:~# lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 1 29.3G 0 disk mtdblock0 31:0 0 128K 1 disk mtdblock1 31:1 0 11M 1 disk mtdblock2 31:2 0 70M 0 disk mtdblock3 31:3 0 430.4M 0 disk mtdblock4 31:4 0 252K 0 disk mtdblock5 31:5 0 252K 0 disk mtdblock6 31:6 0 54M 0 disk mtdblock7 31:7 0 4.1M 0 disk mtdblock8 31:8 0 413.3M 0 disk admin@roboRIO-3620-FRC:~#
- Put a fresh label and swap partition on the disk, using the sd device you found in the
lsblkcommand.
admin@roboRIO-3620-FRC:~# parted /dev/sda GNU Parted 3.2 Using /dev/sda Welcome to GNU Parted! Type 'help' to view a list of commands. (parted) unit MB (parted) mklabel msdos Warning: The existing disk label on /dev/sda will be destroyed and all data on this disk will be lost. Do you want to continue? Yes/No? y (parted) p Model: SanDisk Cruzer Blade (scsi) Disk /dev/sda: 31407MB Sector size (logical/physical): 512B/512B Partition Table: msdos Disk Flags: Number Start End Size Type File system Flags (parted) mkpart pri linux-swap 0% 4096 (parted) p Model: SanDisk Cruzer Blade (scsi) Disk /dev/sda: 31407MB Sector size (logical/physical): 512B/512B Partition Table: msdos Disk Flags: Number Start End Size Type File system Flags 1 1.05MB 4096MB 4095MB primary linux-swap(v1) lba (parted) <control-D> Information: You may need to update /etc/fstab. admin@roboRIO-3620-FRC:~#
- Format the swap partition you just created (using the correct sd device; note the '1' at the end).
admin@roboRIO-3620-FRC:~# mkswap /dev/sda1 mkswap: /dev/sda1: warning: wiping old swap signature. Setting up swapspace version 1, size = 3.8 GiB (4094685184 bytes) no label, UUID=d6b07ecd-abf1-40cd-9b05-af6770987831 admin@roboRIO-3620-FRC:~#
- Test to see if the new swap partition works. The
swapon -scommand shows all active swap files and partitions.
admin@roboRIO-3620-FRC:~# swapon -s admin@roboRIO-3620-FRC:~# swapon /dev/sda1 admin@roboRIO-3620-FRC:~# swapon -s Filename Type Size Used Priority /dev/sda1 partition 3998716 0 -2 admin@roboRIO-3620-FRC:~#
This needs to be redone if swap space is necessary, and the roboRIO has been reformatted since the last time the scripts were changed.
-
Use putty to connect to the roboRIO (address 172.11.22.1 if connected via USB, 10.36.20.2 if connected via wireless or Ethernet). The userid is 'admin', and there is no password.
-
Create the addswap.sh. You can copy-and-paste from here; right clicking in putty does a paste.
admin@roboRIO-3620-FRC:~# cat > /etc/init.d/addswap.sh #!/bin/sh ### BEGIN INIT INFO # Provides: swap # Required-Start: udev # Required-Stop: # Default-Start: S # Default-Stop: # Short-Description: Add swap space # Description: ### END INIT INFO [ -x /sbin/swapon ] && swapon --summary echo "Adding Swap" [ -x /sbin/swapon ] && swapon --verbose /dev/sda1 [ -x /sbin/swapon ] && swapon --summary : exit 0 <control-d> admin@roboRIO-3620-FRC:~#
- Make the script executable.
admin@roboRIO-3620-FRC:~# chmod +x /etc/init.d/addswap.sh admin@roboRIO-3620-FRC:~#
- Set the system up to run the script when the system is started.
admin@roboRIO-3620-FRC:~# update-rc.d addswap.sh defaults Adding system startup for /etc/init.d/addswap.sh. admin@roboRIO-3620-FRC:~#
-
Reboot the roboRIO (using the reset button).
-
Wait for the roboRIO to reboot.
-
Use putty to connect again to the roboRIO (address 172.11.22.1 if connected via USB, 10.36.20.2 if connected via wireless or Ethernet). The userid is 'admin', and there is no password. Issue a
swapon -scommand to confirm that there is swap. If none, get a mentor.
login as: admin Pre-authentication banner message from server: | NI Linux Real-Time (run mode) | | Log in with your NI-Auth credentials. | End of banner message from server admin@roboRIO-3620-FRC:~# swapon -s Filename Type Size Used Priority /dev/sda1 partition 3998716 0 -2 admin@roboRIO-3620-FRC:~#