<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Openwrt on Блог Агапова Максима</title><link>https://magapov.nmph.ru/tags/openwrt/</link><description>Recent content in Openwrt on Блог Агапова Максима</description><generator>Hugo</generator><language>ru</language><lastBuildDate>Sat, 06 Oct 2018 09:30:44 +0000</lastBuildDate><atom:link href="https://magapov.nmph.ru/tags/openwrt/index.xml" rel="self" type="application/rss+xml"/><item><title>Openwrt. Расширяем дисковое пространство</title><link>https://magapov.nmph.ru/2018/03/openwrt.html</link><pubDate>Sat, 24 Mar 2018 14:22:00 +0000</pubDate><guid>https://magapov.nmph.ru/2018/03/openwrt.html</guid><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on">Инструкция по расширению места для программ под openwrt. В большинстве случаев, достаточно будет 2Гб. Установим необходимые пакеты для работы с USB-устройствами&lt;br />
&lt;pre>&lt;code class="bash hljs">root@OpenWrt:~# opkg update
root@OpenWrt:~# opkg install nano kmod-usb-core block-mount kmod-fs-ext4 kmod-usb-storage-extras e2fsprogs blkid&lt;/code>&lt;/pre>Затем fdisk для openwrt&lt;br />
&lt;pre>&lt;code class="bash hljs">root@OpenWrt:~# opkg install fdisk&lt;/code>&lt;/pre>Вставляем флэшку в роутер и создаем разделы&lt;br />
&lt;pre>&lt;code class="bash hljs">root@OpenWrt:~# fdisk /dev/sda
Welcome to fdisk (util-linux 2.25.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Command (m for help): m
Help:
&amp;nbsp; DOS (MBR)
&amp;nbsp; &amp;nbsp;a &amp;nbsp; toggle a bootable flag
&amp;nbsp; &amp;nbsp;b &amp;nbsp; edit nested BSD disklabel
&amp;nbsp; &amp;nbsp;c &amp;nbsp; toggle the dos compatibility flag
&amp;nbsp; Generic
&amp;nbsp; &amp;nbsp;d &amp;nbsp; delete a partition
&amp;nbsp; &amp;nbsp;l &amp;nbsp; list known partition types
&amp;nbsp; &amp;nbsp;n &amp;nbsp; add a new partition
&amp;nbsp; &amp;nbsp;p &amp;nbsp; print the partition table
&amp;nbsp; &amp;nbsp;t &amp;nbsp; change a partition type
&amp;nbsp; &amp;nbsp;v &amp;nbsp; verify the partition table
&amp;nbsp; Misc
&amp;nbsp; &amp;nbsp;m &amp;nbsp; print this menu
&amp;nbsp; &amp;nbsp;u &amp;nbsp; change display/entry units
&amp;nbsp; &amp;nbsp;x &amp;nbsp; extra functionality (experts only)
&amp;nbsp; Save &amp;amp; Exit
&amp;nbsp; &amp;nbsp;w &amp;nbsp; write table to disk and exit
&amp;nbsp; &amp;nbsp;q &amp;nbsp; quit without saving changes
&amp;nbsp; Create a new label
&amp;nbsp; &amp;nbsp;g &amp;nbsp; create a new empty GPT partition table
&amp;nbsp; &amp;nbsp;G &amp;nbsp; create a new empty SGI (IRIX) partition table
&amp;nbsp; &amp;nbsp;o &amp;nbsp; create a new empty DOS partition table
&amp;nbsp; &amp;nbsp;s &amp;nbsp; create a new empty Sun partition table&lt;/code>&lt;/pre>&lt;pre>&lt;code class="bash hljs">Command (m for help): d
Selected partition 1
Partition 1 has been deleted.&lt;/code>&lt;/pre>&lt;pre>&lt;code class="bash hljs">Command (m for help): p
Disk /dev/sda: 1.9 GiB, 2013265920 bytes, 3932160 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xcad4ebea&lt;/code>&lt;/pre>&lt;pre>&lt;code class="bash hljs">Command (m for help): n
Partition type
&amp;nbsp; &amp;nbsp;p &amp;nbsp; primary (0 primary, 0 extended, 4 free)
&amp;nbsp; &amp;nbsp;e &amp;nbsp; extended (container for logical partitions)
Select (default p):
Using default response p.
Partition number (1-4, default 1):
First sector (2048-3932159, default 2048):
Last sector, +sectors or +size{K,M,G,T,P} (2048-3932159, default 3932159): +100M
Created a new partition 1 of type 'Linux' and of size 100 MiB.&lt;/code>&lt;/pre>&lt;pre>&lt;code class="bash hljs">Command (m for help): n
Partition type
&amp;nbsp; &amp;nbsp;p &amp;nbsp; primary (1 primary, 0 extended, 3 free)
&amp;nbsp; &amp;nbsp;e &amp;nbsp; extended (container for logical partitions)
Select (default p):
Using default response p.
Partition number (2-4, default 2):
First sector (206848-3932159, default 206848):
Last sector, +sectors or +size{K,M,G,T,P} (206848-3932159, default 3932159):
Created a new partition 2 of type 'Linux' and of size 1.8 GiB.&lt;/code>&lt;/pre>Меняем метку первого тома на Linux Swap&lt;br />
&lt;pre>&lt;code class="bash hljs">Command (m for help): t
Partition number (1,2, default 2): 1
Hex code (type L to list all codes): 82
Changed type of partition 'Linux' to 'Linux swap / Solaris'.&lt;/code>&lt;/pre>Сохраняем изменения&lt;br />
&lt;pre>&lt;code class="bash hljs">Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.&lt;/code>&lt;/pre>Форматируем второй раздел для данных в ext3 (при желании, можно и в ext4)&lt;br />
&lt;pre>&lt;code class="bash hljs">root@OpenWrt:~# mkfs.ext3 /dev/sda2
mke2fs 1.42.12 (29-Aug-2014)
/dev/sda2 contains a ext4 file system
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; last mounted on Mon Oct 31 11:04:05 2016
Proceed anyway? (y,n) y
Creating filesystem with 465664 4k blocks and 116640 inodes
Filesystem UUID: ec33af13-8569-471e-a6d3-22b3ba95d6fd
Superblock backups stored on blocks:
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 32768, 98304, 163840, 229376, 294912
Allocating group tables: done
Writing inode tables: done
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done&lt;/code>&lt;/pre>Готовим раздел под swap&lt;br />
&lt;pre>&lt;code class="bash hljs">root@OpenWrt:~# mkswap /dev/sda1
Setting up swapspace version 1, size = 104853504 bytes
Device &amp;nbsp; &amp;nbsp; Boot &amp;nbsp;Start &amp;nbsp; &amp;nbsp; End Sectors &amp;nbsp;Size Id Type
/dev/sda1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2048 &amp;nbsp;206847 &amp;nbsp;204800 &amp;nbsp;100M 82 Linux swap / Solaris
/dev/sda2 &amp;nbsp; &amp;nbsp; &amp;nbsp; 206848 3932159 3725312 &amp;nbsp;1.8G 83 Linux&lt;/code>&lt;/pre>После того, как флэшка готова, скопируем содержимое overlay на наш раздел /dev/sda2&lt;br />
&lt;pre>&lt;code class="bash hljs">mount /dev/sda2 /mnt
tar -C /overlay -cvf - . | tar -C /mnt -xf -
umount /mnt&lt;/code>&lt;/pre>Посмотрим uuid диска&lt;br />
&lt;pre>&lt;code class="bash hljs">root@OpenWrt:~# block info /dev/sda2
/dev/sda2: UUID="08514a99-ab63-43bd-9a99-ac83e0b4f240" NAME="EXT_JOURNAL" VERSION="1.0" TYPE="ext4"&lt;/code>&lt;/pre>Отредактируем fstab&lt;br />
&lt;pre>&lt;code class="bash hljs">nano /etc/config/fstab
config 'global'
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; option &amp;nbsp;anon_swap &amp;nbsp; &amp;nbsp; &amp;nbsp; '0'
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; option &amp;nbsp;anon_mount &amp;nbsp; &amp;nbsp; &amp;nbsp;'0'
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; option &amp;nbsp;auto_swap &amp;nbsp; &amp;nbsp; &amp;nbsp; '1'
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; option &amp;nbsp;auto_mount &amp;nbsp; &amp;nbsp; &amp;nbsp;'1'
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; option &amp;nbsp;delay_root &amp;nbsp; &amp;nbsp; &amp;nbsp;'5'
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; option &amp;nbsp;check_fs &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;'0'

config 'mount'
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; option &amp;nbsp;target &amp;nbsp;'/overlay'
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; option &amp;nbsp;uuid &amp;nbsp; &amp;nbsp;'08514a99-ab63-43bd-9a99-ac83e0b4f240'
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; option &amp;nbsp;fstype &amp;nbsp;'ext4'
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; option &amp;nbsp;enabled '1'

config 'swap'
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; option &amp;nbsp;device &amp;nbsp;'/dev/sda1'
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; option &amp;nbsp;enabled '1'&lt;/code>&lt;/pre>Сохраняем и перезагружаем роутер&lt;br />
&lt;pre>&lt;code class="bash hljs">root@OpenWrt:~# reboot&lt;/code>&lt;/pre>Глянем что там со свободным местом&lt;br />
&lt;pre>&lt;code class="bash hljs">root@OpenWrt:~# df -h
Filesystem &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Size &amp;nbsp; &amp;nbsp; &amp;nbsp;Used Available Use% Mounted on
rootfs &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1.7G &amp;nbsp; &amp;nbsp; &amp;nbsp;3.4M &amp;nbsp; &amp;nbsp; &amp;nbsp;1.6G &amp;nbsp; 0% /
/dev/root &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2.5M &amp;nbsp; &amp;nbsp; &amp;nbsp;2.5M &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0 100% /rom
tmpfs &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;13.9M &amp;nbsp; &amp;nbsp; 76.0K &amp;nbsp; &amp;nbsp; 13.9M &amp;nbsp; 1% /tmp
/dev/sda2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1.7G &amp;nbsp; &amp;nbsp; &amp;nbsp;3.4M &amp;nbsp; &amp;nbsp; &amp;nbsp;1.6G &amp;nbsp; 0% /overlay
overlayfs:/overlay &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1.7G &amp;nbsp; &amp;nbsp; &amp;nbsp;3.4M &amp;nbsp; &amp;nbsp; &amp;nbsp;1.6G &amp;nbsp; 0% /
tmpfs &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 512.0K &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0 &amp;nbsp; &amp;nbsp;512.0K &amp;nbsp; 0% /dev&lt;/code>&lt;/pre>&lt;pre>&lt;code class="bash hljs">root@OpenWrt:~# free
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;total &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; used &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; free &amp;nbsp; &amp;nbsp; &amp;nbsp; shared &amp;nbsp; &amp;nbsp; &amp;nbsp;buffers
Mem: &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 28556 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;24332 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 4224 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 76 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 3008
-/+ buffers: &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;21324 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 7232
Swap: &amp;nbsp; &amp;nbsp; &amp;nbsp; 102396 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0 &amp;nbsp; &amp;nbsp; &amp;nbsp; 102396&lt;/code>&lt;/pre>&lt;/div></description></item></channel></rss>