milkv-duo / duo-buildroot-sdk

Milk-V Duo Official buildroot SDK
411 stars 174 forks source link

There is no Swap on Duo #148

Closed nopnop2002 closed 1 month ago

nopnop2002 commented 1 month ago

I used v1.1.3 on Duo from here. https://github.com/milkv-duo/duo-buildroot-sdk/releases

They say: Duo deleted the third partition reserved for swap and used swap file instead.

However, there is no Swap. I used a 16GB SD card.

# free -h
              total        used        free      shared  buff/cache   available
Mem:          28.3M       13.6M        5.8M       68.0K        8.9M       12.0M
Swap:             0           0           0

As they say, there is no third partition.

# fdisk /dev/mmcblk0

Welcome to fdisk (util-linux 2.36.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Command (m for help): p
Disk /dev/mmcblk0: 14.84 GiB, 15931539456 bytes, 31116288 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: 0xf778ee68

Device         Boot  Start     End Sectors  Size Id Type
/dev/mmcblk0p1 *         1  262144  262144  128M  c W95 FAT32 (LBA)
/dev/mmcblk0p2      262145 1835008 1572864  768M 83 Linux
carbonfix commented 1 month ago

https://milkv.io/docs/duo/getting-started/setup#enable-swap

nopnop2002 commented 1 month ago

@carbonfix Thank you fo replay.

[root@milkv-duo]~# fallocate -l 256M /mnt/swapfile
chmod 600 /mnt/swapfile
[root@milkv-duo]~# chmod 600 /mnt/swapfile
mkswap /mnt/swapfile
[root@milkv-duo]~# mkswap /mnt/swapfile
swapon /mnt/swapfileSetting up swapspace version 1, size = 256 MiB (268431360 bytes)
no label, UUID=71fc6ff8-0506-4f4a-a471-7d57b9bd6ea7
[root@milkv-duo]~# swapon /mnt/swapfile
[root@milkv-duo]~# free -h
              total        used        free      shared  buff/cache   available
Mem:          28.3M       13.7M        4.3M       68.0K       10.3M       11.9M
Swap:        255.8M           0      255.8M

Swap is now enabled.

nopnop2002 commented 1 month ago

@carbonfix Swap is now enabled, but it disappears when I reboot. Is there a way to enable it permanently?

carbonfix commented 1 month ago

The method is mentioned at the end of the document link above :)

nopnop2002 commented 1 month ago

@carbonfix

echo "/mnt/swapfile swap swap defaults 0 0" >> /etc/fstab && sync

Good!!