Sample Header Ad - 728x90

How to change zram sector size?

3 votes
1 answer
730 views
I have cloned a disk into a sparse file that is about 80G but indeed requires only about 12G, even not compressed it fits on my memory, but in order to save some resources I want to use **zram**: sudo modprobe zram num_devices=1 echo 79999997952 | sudo tee /sys/block/zram0/disksize sudo fdisk -c=dos --sector-size 512 /dev/zram0 However when I create the partition it is using 4096 sector size even I told **fdisk** to use 512. It do not let me type the size of the partition based on 512 sector size, and it is not a exact number which I could divide by 8 in order to have a 4096 based one, so I have done on a sparse **mbr**: truncate -s79999997952 /tmp/block fdisk -c=dos --sector-size 512 /tmp/block # o, n, p, 1, 63, 156232124, t, 7, a, w sudo dd if=/tmp/block of=/dev/zram0 count=1 bs=512 It seems with regular files **fdisk** sees no problem in using a 512 sector size! But **zram** is still weird, I do not know if it is going to work, because it shows a different disk size when on 512 mode: $ sudo fdisk -lu /dev/zram0 Disk /dev/zram0: 74.5 GiB, 80000000000 bytes, 19531250 sectors Units: sectors of 1 * 4096 = 4096 bytes Sector size (logical/physical): 4096 bytes / 4096 bytes I/O size (minimum/optimal): 4096 bytes / 4096 bytes Disklabel type: dos Disk identifier: 0x5f8b6465 Device Boot Start End Sectors Size Id Type /dev/zram0p1 * 63 156232124 156232062 596G 7 HPFS/NTFS/exFAT $ sudo fdisk -lu --sector-size 512 /dev/zram0 Disk /dev/zram0: 9.3 GiB, 10000000000 bytes, 19531250 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 4096 bytes Disklabel type: dos Disk identifier: 0x5f8b6465 Device Boot Start End Sectors Size Id Type /dev/zram0p1 * 63 156232124 156232062 74.5G 7 HPFS/NTFS/exFAT Understand, once 156232062 / 8 = 19529007.75 there is no way it can fit on 4096 sector size. How to force **fdisk** or the **zram** itself to use 512 sector size?
Asked by Tiago Pimenta (646 rep)
Mar 5, 2019, 02:45 PM
Last activity: Dec 20, 2023, 04:52 PM