This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
usb_formatting_with_swap_partition [2021/08/16 22:44] – [Final setup] hogwild | usb_formatting_with_swap_partition [2024/03/27 15:32] (current) – [Deactivating the Swap Partition (Pre-unmount command)] -condense hogwild | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== USB formatting with swap partition ====== | ====== USB formatting with swap partition ====== | ||
- | It is highly recommended to make some form of permanent storage available for FreshTomato. | + | A swap partition can prevent several types of insufficient RAM symptoms, such as system instability, |
- | This example assumes you are using either | + | This example assumes you are using an ARM or MIPS build with USB support, and USB support |
+ | |||
+ | For this example, we use a 16GB USB flash drive seen in the system as device **sda**. | ||
- | For this example we used a 16GB USB flash drive which is seen in the system as device **sda**. | ||
===== Automatic method ===== | ===== Automatic method ===== | ||
- | This assumes your drive device | + | This assumes your drive' |
- | The **echo 1000M** statement below defines the size of the swap partition (in MB). You may want to adjust that, according to your needs. | + | The **echo 1000M** statement below defines the size of the swap partition (in MB). You may adjust that according to your needs. |
+ | |||
+ | \\ | ||
Then enter: | Then enter: | ||
- | < | ||
+ | \\ | ||
+ | |||
+ | <code -> | ||
device=/ | device=/ | ||
partition=$device' | partition=$device' | ||
+ | swappartition=$device' | ||
nvram set usb_automount=" | nvram set usb_automount=" | ||
(echo o; echo n; echo p; echo 2; echo ; echo +1000M; echo t; echo 82; echo n; echo p; echo 1; echo ; echo ; echo w) | fdisk $device | (echo o; echo n; echo p; echo 2; echo ; echo +1000M; echo t; echo 82; echo n; echo p; echo 1; echo ; echo ; echo w) | fdisk $device | ||
- | mkfs.ext2 -L USB $partion | + | # Uncomment the preferred option here below: |
- | mkswap | + | # mkfs.ext2 -L usb $partion |
- | swapon | + | # mkfs.vfat -n usb $partion |
- | mkdir /mnt/sda1 && mount /dev/sda1 /mnt/sda1 | + | mkswap |
+ | swapon | ||
+ | mkdir /mnt/usb && mount /dev/sda1 /mnt/usb | ||
nvram set usb_automount=" | nvram set usb_automount=" | ||
- | |||
</ | </ | ||
- | ===== Manual method: ===== | + | \\ |
- | From the Web interface, disable the Automount checkbox in the [[usb_support|USB Support]] menu. | + | ===== Manual method ===== |
- | [[https:// | + | From the Web interface, disable the Automount checkbox in the [[nas-usb|USB Support]] menu. |
\\ | \\ | ||
- | Then, logon via SSH or Telnet and delete any existing partitions: | + | |
+ | [[https:// | ||
+ | |||
+ | \\ \\ Then, logon via SSH or Telnet and delete any existing partitions: | ||
<code -> | <code -> | ||
Line 68: | Line 78: | ||
</ | </ | ||
- | \\ | + | |
- | \\ | + | |
- | At this point you should have two unformatted partitions on your USB flash drive: | + | |
- | \\ | + | * sda1 |
- | sda1 ~14GB (fs-type ext2/3/4) | + | |
- | \\ | + | |
- | and | + | |
- | \\ sda2 ~1GB (fs-type swap) | + | |
[[https:// | [[https:// | ||
\\ | \\ | ||
- | \\ | + | |
- | Now, let' | + | |
<code -> | <code -> | ||
Line 89: | Line 94: | ||
</ | </ | ||
- | \\ | + | |
- | Now, mount the partitions: | + | |
<code -> | <code -> | ||
Line 96: | Line 100: | ||
mkdir /mnt/sda1 && mount /dev/sda1 /mnt/sda1 | mkdir /mnt/sda1 && mount /dev/sda1 /mnt/sda1 | ||
</ | </ | ||
+ | |||
+ | | ||
+ | |||
+ | You can now re-enable USB Automount on the [[nas-usb|USB Support]] menu. | ||
\\ | \\ | ||
- | You can now re-enable USB Automount on the USB and NAS menu. | ||
- | ===== Final setup ===== | + | ===== Configuring Post-mount and Pre-unmount Commands |
+ | |||
+ | For best practice, the swap partition should be activated as swap once the USB drive/flash is mounted. Additionally, | ||
\\ | \\ | ||
- | The USB flash drive is now formatted. Your USB and NAS page settings should look like this: | ||
- | [[https:// | + | ==== Activating Swap Partition (Post Mount Command) ==== |
+ | |||
+ | To activate the swap partition you created on the drive, enter the following into the "**Run after mounting**" | ||
\\ | \\ | ||
+ | |||
+ | <code -> | ||
+ | swapon /dev/sda2 | ||
+ | </ | ||
+ | |||
\\ | \\ | ||
- | Under Attached Devices, you should | + | |
+ | The field should | ||
+ | |||
+ | {{: | ||
+ | You may have additional commands within the field. | ||
+ | )) | ||
\\ | \\ | ||
- | [[https://wiki.freshtomato.org/lib/exe/detail.php? | + | |
+ | |||
+ | ==== Deactivating the Swap Partition (Pre-unmount command) ==== | ||
+ | |||
+ | To configure the router to automatically deactivate the swap partition (in this case, **///dev/sda2//**) , the "**Run before unmounting**" | ||
\\ | \\ | ||
+ | |||
+ | <code -> | ||
+ | swapoff / | ||
+ | </ | ||
+ | |||
\\ | \\ | ||
- | To verify the swap partition works properly, check the [[:overview|Overview]] menu. You should see information | + | |
+ | The field should appear like this: | ||
+ | |||
+ | {{: | ||
+ | Again, your form field may have additional data within it. | ||
+ | )) | ||
+ | |||
+ | In both cases, click the Save button at the bottom before continuing. | ||
+ | |||
+ | |||
+ | ===== Final setup ===== | ||
+ | |||
+ | | ||
+ | |||
+ | \\ [[https:// | ||
+ | |||
+ | | ||
+ | |||
+ | \\ [[https:// | ||
+ | |||
+ | | ||
+ | |||
+ | \\ [[https:// | ||
+ | |||
+ | \\ | ||
\\ | \\ | ||
- | [[https:// | ||