Sample Header Ad - 728x90

Amazon instance automatically creating and resizing partitions after VM Import

1 vote
0 answers
189 views
I'm using Packer to create a VM with CentOS 7, and exporting it as a .ova file at the final of installation. By default, Packer creates a 40GB Virtual Disk (.vmdk). After the installation, if I import the .ova file in VirtualBox (just for tests) and list the file system of the created VM, I got this: [root@localhost ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/cl-root 37G 1.6G 35G 5% / devtmpfs 1.3G 0 1.3G 0% /dev tmpfs 1.4G 0 1.4G 0% /dev/shm tmpfs 1.4G 8.4M 1.3G 1% /run tmpfs 1.4G 0 1.4G 0% /sys/fs/cgroup /dev/sda1 1014M 166M 849M 17% /boot tmpfs 268M 0 268M 0% /run/user/1000 tmpfs 268M 0 268M 0% /run/user/0 If I import the same .ova file in a Amazon Instance, this time increasing the size of my root storage volume to 100GB, I got this file system: [root@localhost ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/cl-root 50G 4,0G 46G 9% / devtmpfs 15G 0 15G 0% /dev tmpfs 15G 0 15G 0% /dev/shm tmpfs 15G 18M 15G 1% /run tmpfs 15G 0 15G 0% /sys/fs/cgroup /dev/xvda1 1014M 185M 830M 19% /boot /dev/mapper/cl-home 45G 89M 45G 1% /home tmpfs 3,0G 0 3,0G 0% /run/user/0 tmpfs 3,0G 0 3,0G 0% /run/user/1000 Note that the / was increased to 50GB, and now a new /home was automatically created. This was driving me crazy, until I find the cause: All the instalallation was made automatically by Packer, using a kickstart config file wich uses autopart for partitioning. In RedHat docs, I found this: autopart (optional) Automatically creates partitions: a root (/) partition (1 GB or larger), a swap partition, and an appropriate /boot partition for the architecture. On large enough drives (50 GB and larger), this also creates a /home partition. So, I decided to manually create the partitions, using this lines in the kickstart file instead of autopart: part /boot --fstype ext4 --size=1014 part pv.01 --size=1000 --grow volgroup cl pv.01 logvol swap --fstype swap --name=swap --vgname=cl --size=2048 logvol / --fstype ext4 --name=root --vgname=cl --size=1 --grow Importing the .ova again to Amazon, selecting the same storage size of 100GB for the root volume, I finally got what I wanted: [root@localhost ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/cl-root 94G 2,3G 87G 3% / devtmpfs 15G 0 15G 0% /dev tmpfs 15G 0 15G 0% /dev/shm tmpfs 15G 8,3M 15G 1% /run tmpfs 15G 0 15G 0% /sys/fs/cgroup /dev/xvda1 983M 154M 762M 17% /boot tmpfs 3,0G 0 3,0G 0% /run/user/1000 So I found **WHAT** is going on, but not **HOW** it happens. The questions are: - The kickstart file is supposed to be used only in installation time. How after Amazon VM import the file system get changed using the same conventions of the kickstart installation? - Where this info is stored, and how the resizing is being done automatically in CentOS 7?
Asked by Eduardo Baitello (656 rep)
Mar 17, 2017, 07:18 PM
Last activity: Mar 27, 2017, 12:42 PM