I have an Ubuntu server running as a kvm host. The host has three 1.5TB disks and the host uses lvm and has a 4TB volume group, on which I've created a 3 TB logical volume called nfsserver.
I want to create a guest running ubuntu server, which I'll use as a 3TB fileserver.
Ubuntu vmbuilder uses mbr for the guest filesystem, which cannot handle >2TB harddisks.
I've searched but cannot find any guides or howtos telling, or even mentioning, how to create a guest using GPT for the guest filesystem.
Is there another solution to this that I'm missing?
The command I'm using to create the guest vm:
vmbuilder kvm ubuntu --suite=trusty --flavour=virtual --raw=/dev/server1/nfsserver --rootsize=3000000 --domain=nfsserver --arch=amd64 --mirror=http://dk.archive.ubuntu.com/ubuntu -o --libvirt=qemu:///system --user=admin --name=Admin --pass=PassXXXX --addpkg=unattended-upgrades --addpkg=acpid --addpkg=linux-image-generic --addpkg=openssh-server --mem=1024 --hostname=nfsserver --bridge=br0
With the rootsize set, the vmbuilder fails with "partition length ... exceeds the msdos-partition-table-imposed maximum".
Without it the guest is build and works just fine, but with just the default size disk. When inside the guest system fdisk -l can see that the disk (sda) is 3TB, and the sda1 root partition uses only a few GBs of this. I've tried resizing the partition, but that fails with a similar 'msdos.. max..' error.
I'm aware that I could probably, from inside the guest system, save the small sda1 partition, repartion the filessystem, and change it to use gpt and copy back the saved sda1 partition (to a new 3TB root partition). But that seems like a difficult workaround to me, and I'm thinking that there must be a simpler solution.
lvdisplay on the host:
--- Logical volume ---
LV Path /dev/server1/nfsserver
LV Name nfsserver
VG Name server1
LV UUID F8wWeB-GSUI-rxd3-TDQ1-yjcI-af50-s9jdXZ
LV Write Access read/write
LV Creation host, time server1, 2015-02-02 15:56:20 +0100
LV Status available
# open 0
LV Size 3.04 TiB
Current LE 797964
Segments 3
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 252:1
EDIT: Thomas' answer below was very helpful in solving my problem, for the benefit of others browsing by this question, here is a detailed description of what I did:
I have a VG called server1 with 4TB of space. To prepare some disks for the guest I created and formatted some LVs:
lvcreate -L 3000G -n nfsserver server1
lvcreate -L 6G -n nfsserver-root server1
lvcreate -L 200M -n nfsserver-boot server1
lvcreate -L 2G -n nfsserver-swap server1
mkfs.ext4 /dev/mapper/server1-nfsserver-boot
mkfs.ext4 /dev/mapper/server1-nfsserver-root
mkfs.ext4 /dev/mapper/server1-nfsserver
mkswap -f /dev/mapper/server1-nfsserver-swap
I installed virtinstall (apt-get install virtinst), because you cannot use vmbuilder for this, as it will create partitions, and as Thomas points out we actually don't need/want partitions for this. With virt-install you can create a guest and run the ubuntu server installation in the guest when it boots - this lets you control what the different disks should be used for. You do need a partition on the disk to be used as /boot though, because the installer is either unable to make the partition itself or will fail at installing Grub. So we use fdisk at the host before creating the guest:
user@server1:~$ sudo fdisk /dev/mapper/server1-nfsserver-boot
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x95a40881.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
The device presents a logical sector size that is smaller than
the physical sector size. Aligning to a physical sector (or optimal
I/O) size boundary is recommended, or performance may be impacted.
Command (m for help): n
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-409599, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-409599, default 409599):
Using default value 409599
Command (m for help): p
Disk /dev/mapper/server1-nfsserver-boot: 209 MB, 209715200 bytes
255 heads, 63 sectors/track, 25 cylinders, total 409600 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x95a40881
Device Boot Start End Blocks Id System
/dev/mapper/server1-nfsserver-boot1 2048 409599 203776 83 Linux
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: Re-reading the partition table failed with error 22: Invalid argument.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.
user@server1:~$ sudo fdisk -l /dev/mapper/server1-nfsserver-boot
Disk /dev/mapper/server1-nfsserver-boot: 209 MB, 209715200 bytes
127 heads, 37 sectors/track, 87 cylinders, total 409600 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x95a40881
Device Boot Start End Blocks Id System
/dev/mapper/server1-nfsserver-boot1 2048 409599 203776 83 Linux
user@server1:~$
I ignored the warnings from fdisk, it worked fine. I downloaded the latest Ubuntu LTS
wget http://releases.ubuntu.com/14.04.1/ubuntu-14.04.1-server-amd64.iso
And ran virt-install:
virt-install --name=nfsserver --ram=1024 --os-type=linux --os-variant=ubuntutrusty --cdrom=/home/user/ubuntu-14.04.1-server-amd64.iso --disk path=/dev/mapper/server1-nfsserver-boot --disk path=/dev/mapper/server1-nfsserver-root --disk path=/dev/mapper/server1-nfsserver-swap --network bridge=br0 --vcpus=1 --vnc --noautoconsole
It runs very quickly and boots the guest from the dowloaded iso. Using virt-manager from my desktop computer on the same network as the host, I could connect to the guest and go through the installation. When you come to the point with the partitions, the installer can see all your LV's as disks, and it's just a matter of telling which should be used for what.
I added the 3TB disk afterwords: Shutdown the guest, edit the guest and start it agian:
virsh shutdown nfsserver
virsh edit nfsserver
This opens the guests xml-file defining the guest, I added my 3TB LV as an extra disk below the other disks already present:
<disk type='block' device='disk'>
<driver name='qemu' type='raw' cache='none' io='native'/>
<source dev='/dev/mapper/server1-nfsserver'/>
<target dev='vdd' bus='virtio'/>
</disk>
Then
virsh start nfsserver
And lastly, in your guest you can mount your new drive:
sudo mount /dev/vdd /your/mount/point
And if it mounts, then to make it permanent add this line to your /etc/fstab:
/dev/vdd /your/mount/point ext4 errors=remount-ro 0 0
That's it! You now have a guest with a huge disk. Thanks to Thomas' advice you now also have it amazingly easy, if you want to clone your guest or resize the drives.