Give a minimum size of swap area through lvm method

asked 2017-11-19 23:16:15 -0600

sumitsharma gravatar image

While building Ubuntu_16.04 image through packer, I have to do partitioning in preseed file such that the method used is LVM and the minimum size of swap area must be 2GB. Currently, the VM is giving the swap area same as the size of the RAM given as input. If RAM is 1GB , the swap area created by default is also 1GB. This I have to change and put it minimum to 2GB.

Current preseed file -

d-i partman-auto/method string lvm
d-i partman-lvm/device_remove_lvm boolean true
d-i partman-lvm/confirm boolean true
d-i partman-lvm/confirm_nooverwrite boolean true
d-i partman-auto/expert_recipe string                       \
    boot-root ::                                            \
            512 50 1024 ext3                                \
                    $primary{ } $bootable{ }                \
                    method{ format } format{ }              \
                    use_filesystem{ } filesystem{ ext3 }    \
                    mountpoint{ /boot }                     \
            .                                               \
            50000 10000 1000000000 ext3                     \
                    lv_name{ root }                         \
                    method{ lvm } format{ }                 \
                    use_filesystem{ } filesystem{ ext4 }    \
                    mountpoint{ / }                         \
                    $lvmok{ }                               \
            .                                               \
            2148 512 200% linux-swap                        \
                    lv_name{ swap }                         \
                    method{ swap } format{ }                \
                    $lvmok                                  \
            .
d-i     partman-partitioning/confirm_write_new_label boolean true
d-i     partman/choose_partition select finish
d-i     partman/confirm boolean true
d-i     partman/confirm_nooverwrite boolean true

This code is not working to restrict swap size to minimum of 2GB.

edit retag flag offensive close merge delete