Skip to content

Commit 881386c

Browse files
lpancescukbsingh
authored andcommitted
Use a single partition for the Vagrant images (#115)
* Use a single partition for Vagrant images There is no performance penalty for using a swapfile instead of a swap partition; by not defining a swap of boot partition, we allow our users to create a swapfile themselves if they need one. * Use Kickstart to set the bootloader timeout * Remove several unneccessary packages - plymouth displays a bootup screen, not needed by Vagrant - manpages don't bring anything if we use --excludedocs - linux-firmware isn't useful for VM hardware - support for ext[234] and btrfs isn't needed, we use XFS * Add the man pages again to the image * Configure swapping to a file We use a 2GiB file as swap, as recommended by Red Hat for systems with up to 4G RAM. * Add cifs-utils to the images (for Windows users) * Switch the filesystem from xfs to ext4 All CentOS Linux 7 images in the last few months are unable to boot due to apparent XFS filesystem corruption. This is 100% reproducible with both Image Factory and Packer when using libvirt (the images for VirtualBox are working). It might be caused by qemu-img, since the initial boot performed by Packer immediately after the installation is successful.
1 parent 84f8258 commit 881386c

File tree

2 files changed

+24
-23
lines changed

2 files changed

+24
-23
lines changed

vagrant/centos6.ks

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,13 @@ timezone --utc UTC
1313
services --enabled ntpd,tuned
1414
# The biosdevname and ifnames options ensure we get "eth0" as our interface
1515
# even in environments like virtualbox that emulate a real NW card
16-
bootloader --location=mbr --append="no_timer_check console=tty0 console=ttyS0,115200n8 net.ifnames=0 biosdevname=0 elevator=noop"
16+
bootloader --timeout=1 --append="no_timer_check console=tty0 console=ttyS0,115200n8 net.ifnames=0 biosdevname=0 elevator=noop"
1717
zerombr
1818
clearpart --all --drives=vda
19+
part / --fstype=ext4 --asprimary --size=1024 --grow --ondisk=vda
1920

2021
user --name=vagrant --password=vagrant
2122

22-
part biosboot --fstype=biosboot --size=1
23-
part /boot --fstype ext4 --size=250 --ondisk=vda
24-
part pv.2 --size=1 --grow --ondisk=vda
25-
volgroup VolGroup00 --pesize=32768 pv.2
26-
logvol swap --fstype swap --name=LogVol01 --vgname=VolGroup00 --size=768 --grow --maxsize=1536
27-
logvol / --fstype ext4 --name=LogVol00 --vgname=VolGroup00 --size=1024 --grow
2823
reboot
2924

3025
%packages
@@ -35,6 +30,7 @@ bzip2
3530
rsync
3631
screen
3732
nfs-utils
33+
cifs-utils
3834
tuned
3935
hyperv-daemons
4036
# Microcode updates cannot work in a VM
@@ -72,6 +68,12 @@ hyperv-daemons
7268

7369
%post
7470
71+
# configure swap to a file
72+
fallocate -l 2G /swapfile
73+
chmod 600 /swapfile
74+
mkswap /swapfile
75+
echo "/swapfile none swap defaults 0 0" >> /etc/fstab
76+
7577
# sudo
7678
echo "%vagrant ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers.d/vagrant
7779
@@ -127,9 +129,6 @@ echo 'vag' > /etc/yum/vars/infra
127129
# Configure tuned
128130
tuned-adm profile virtual-guest
129131
130-
# Configure grub to wait just 1 second before booting
131-
sed -i 's/^timeout=[0-9]\+$/timeout=1/' /boot/grub/grub.conf
132-
133132
# Enable VMware PVSCSI support for VMware Fusion guests. This produces
134133
# a tiny increase in the image and is harmless for other environments.
135134
pushd /etc/dracut.conf.d

vagrant/centos7.ks

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,32 +12,30 @@ selinux --enforcing
1212
timezone --utc UTC
1313
# The biosdevname and ifnames options ensure we get "eth0" as our interface
1414
# even in environments like virtualbox that emulate a real NW card
15-
bootloader --location=mbr --append="no_timer_check console=tty0 console=ttyS0,115200n8 net.ifnames=0 biosdevname=0 elevator=noop"
15+
bootloader --timeout=1 --append="no_timer_check console=tty0 console=ttyS0,115200n8 net.ifnames=0 biosdevname=0 elevator=noop"
1616
zerombr
1717
clearpart --all --drives=vda
18+
part / --fstype=ext4 --asprimary --size=1024 --grow --ondisk=vda
1819

1920
user --name=vagrant --password=vagrant
2021

21-
part biosboot --fstype=biosboot --size=1
22-
part /boot --fstype xfs --size=1024 --ondisk=vda
23-
part pv.2 --size=1 --grow --ondisk=vda
24-
volgroup VolGroup00 --pesize=32768 pv.2
25-
logvol swap --fstype swap --name=LogVol01 --vgname=VolGroup00 --size=768 --grow --maxsize=1536
26-
logvol / --fstype xfs --name=LogVol00 --vgname=VolGroup00 --size=1024 --grow
2722
reboot
2823

29-
%packages --excludedocs --instLangs=en
24+
%packages --instLangs=en
3025
deltarpm
3126
bash-completion
3227
man-pages
3328
bzip2
34-
@core
3529
rsync
36-
screen
3730
nfs-utils
31+
cifs-utils
3832
chrony
3933
yum-utils
4034
hyperv-daemons
35+
-e2fsprogs
36+
-btrfs-progs
37+
# Vagrant boxes aren't normally visible, no need for Plymouth
38+
-plymouth
4139
# Microcode updates cannot work in a VM
4240
-microcode_ctl
4341
# Firmware packages are not needed in a VM
@@ -62,6 +60,7 @@ hyperv-daemons
6260
-iwl6050-firmware
6361
-iwl7260-firmware
6462
-iwl7265-firmware
63+
-linux-firmware
6564
# Don't build rescue initramfs
6665
-dracut-config-rescue
6766
# Disable kdump
@@ -76,6 +75,12 @@ hyperv-daemons
7675

7776
%post
7877
78+
# configure swap to a file
79+
fallocate -l 2G /swapfile
80+
chmod 600 /swapfile
81+
mkswap /swapfile
82+
echo "/swapfile none swap defaults 0 0" >> /etc/fstab
83+
7984
# sudo
8085
echo "%vagrant ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers.d/vagrant
8186
@@ -130,9 +135,6 @@ EOF
130135
131136
echo 'vag' > /etc/yum/vars/infra
132137
133-
# Configure grub to wait just 1 second before booting
134-
sed -i 's/^GRUB_TIMEOUT=[0-9]\+$/GRUB_TIMEOUT=1/' /etc/default/grub && grub2-mkconfig -o /boot/grub2/grub.cfg
135-
136138
# Blacklist the floppy module to avoid probing timeouts
137139
echo blacklist floppy > /etc/modprobe.d/nofloppy.conf
138140
chcon -u system_u -r object_r -t modules_conf_t /etc/modprobe.d/nofloppy.conf

0 commit comments

Comments
 (0)