Increase size of GCE image. Use disk.raw as name inside tar.gz, as this is compulsory.

This commit is contained in:
Rob Vermaas 2014-03-21 14:55:42 +01:00
parent f3f6f04c7d
commit af6c571a7e

View file

@ -1,7 +1,9 @@
{ config, pkgs, ... }: { config, pkgs, ... }:
with pkgs.lib; with pkgs.lib;
let
diskSize = "200G";
in
{ {
imports = [ ../profiles/headless.nix ../profiles/qemu-guest.nix ]; imports = [ ../profiles/headless.nix ../profiles/qemu-guest.nix ];
@ -12,7 +14,7 @@ with pkgs.lib;
'' ''
mkdir $out mkdir $out
diskImage=$out/$diskImageBase diskImage=$out/$diskImageBase
truncate $diskImage --size 10G truncate $diskImage --size ${diskSize}
mv closure xchg/ mv closure xchg/
''; '';
@ -20,8 +22,9 @@ with pkgs.lib;
'' ''
PATH=$PATH:${pkgs.gnutar}/bin:${pkgs.gzip}/bin PATH=$PATH:${pkgs.gnutar}/bin:${pkgs.gzip}/bin
pushd $out pushd $out
tar -Szcf $diskImageBase.tar.gz $diskImageBase mv $diskImageBase disk.raw
rm $out/$diskImageBase tar -Szcf $diskImageBase.tar.gz disk.raw
rm $out/disk.raw
popd popd
''; '';
diskImageBase = "nixos-${config.system.nixosVersion}-${pkgs.stdenv.system}.raw"; diskImageBase = "nixos-${config.system.nixosVersion}-${pkgs.stdenv.system}.raw";
@ -32,7 +35,7 @@ with pkgs.lib;
'' ''
# Create partition table # Create partition table
${pkgs.parted}/sbin/parted /dev/vda mklabel msdos ${pkgs.parted}/sbin/parted /dev/vda mklabel msdos
${pkgs.parted}/sbin/parted /dev/vda mkpart primary ext4 1 10G ${pkgs.parted}/sbin/parted /dev/vda mkpart primary ext4 1 ${diskSize}
${pkgs.parted}/sbin/parted /dev/vda print ${pkgs.parted}/sbin/parted /dev/vda print
. /sys/class/block/vda1/uevent . /sys/class/block/vda1/uevent
mknod /dev/vda1 b $MAJOR $MINOR mknod /dev/vda1 b $MAJOR $MINOR