While searching for solutions to the “online root resize” issue, I came across the following blog post, which contained a comment suggesting that a partition-less/LVM-less disk enabled the online expansion of any file system:
Going to a LVM/partition-less setup reduces expansion to 3 steps and we don’t need to take the VM OS offline!
- Increase size of VMDK
- Inside the VM, OS, rescan the scsi drive with:
echo 1 >/sys/class/scsi_device/<deviceID>/rescan; dmesg
(dmesg will check that you drive size has grown) resize2fs
Our current disk arrangement has 3 VM HD devices
- small device (512M) with a single BOOT partition
- entire device is SWAP
- entire device is /
In addition, there is an interesting discussion on stackexchange.com concerning partitionless file systems. This article also outlines using partitionless file systems.
With this in mind, there are two ways to proceed:
- Convert an existing installation to one using partitionless drives.
- Install from scratch using several drives.
I don’t know of a single Linux distro that supports partitionless file systems out of the box. I have had some success by formatting the drives using the System Rescue CD and then performing an Ubuntu installation. I’ll go through the steps here.
VM Setup
In VMWare Workstation, I set up a VM with the following settings, using thin provisioned disks:
The disks, in order from the top, have the following properties:
Name
|
SCSI BUS:ID
|
Size
|
Device
|
Mount
|
---|---|---|---|---|
Hard Disk | 0:0 | 512MB | /dev/sda | /boot |
Hard Disk 2 | 0:1 | 2GB | /dev/sdb | swap |
Hard Disk 3 | 0:2 | 8GB | /dev/sdc | / |
Set up the CD to boot from the System Rescue CD iso image. Power on your VM and you’ll soon be at a prompt to do some work. Since the boot drive isn’t ever going to be expanded, we can create a primary partition and ext2
filesystem on it. Start the partiton at sector 2048 and end it at the end of the disk (512MB, 536870912 bytes, 1048576 512-byte sectors).
parted -s /dev/sda 'mklabel msdos'
creates an MBR partition table on SCSI disk [0:0]parted -s /dev/sda 'u s mkpart primary 2048 1048575'
creates the first primary partition starting at sector 2048parted -s /dev/sda 'set 1 boot on'
marks the first partition as bootableparted -s /dev/sda 'u s p'
prints out the partition table in sectors
Terminal session:
root@sysresccd
/root
% parted -s
/dev/sda
'mklabel msdos'
root@sysresccd
/root
% parted -s
/dev/sda
'u s mkpart primary 2048 1048575'
root@sysresccd
/root
% parted -s
/dev/sda
'set 1 boot on'
root@sysresccd
/root
% parted -s
/dev/sda
'u s p' Model: VMware, VMware Virtual S (scsi)
Disk
/dev/sda
: 1048576s
Sector size (logical
/physical
): 512B
/512B Partition Table: msdos Disk Flags:
Number Start End Size Type File system Flags
1 2048s 1048575s 1046528s primary boot
This command formats the first partition with the ext2
file system and labels it ‘boot':
root@sysresccd
/root
% mkfs -t ext2 -L boot
/dev/sda1
mke2fs 1.42.6 (21-Sep-2012)
Filesystem label=boot
OS
type
: Linux
...
...
Now, create ext4 filesystems on the rest of the drives, using /dev/sdb
for swap:
root@sysresccd /root % mkswap /dev/sdb mkswap: /dev/sdb : warning: don't erase bootbits sectors on whole disk. Use -f to force. Setting up swapspace version 1, size = 2097148 KiB no label, UUID=1ceb754a-58e7-414c-8ca5-0e7fed04ddf7 root@sysresccd /root % mkfs -t ext4 -L root /dev/sdc mke2fs 1.42.6 (21-Sep-2012) /dev/sdc is entire device, not just one partition! Proceed anyway? (y,n) y Filesystem label=root OS type : Linux ... ... root@sysresccd /root % mkfs -t ext4 -L var /dev/sdd ... root@sysresccd /root % mkfs -t ext4 -L tmp /dev/sde ... root@sysresccd /root % mkfs -t ext4 -L home /dev/sdf ... |
When done, parted -l
will show you your newly formatted disks. Shutdown the system and switch the CD-ROM to use your Ubuntu install CD. I’m going to install 10.04LTS, but these instructions should work with Ubuntu 12 as well. Don’t use the “easy install” feature if given the option! Also, you may have to modify your VM’s BIOS to boot from the CD before attempting to boot from the disk.
Continue with the installation until you reach the partitioning step, then choose “Manual”:
Scroll down to select your boot disk and hit Enter:
Use the following settings. The important ones are “keep existing data” and “Mount point: /boot
”
Choose “Done setting up the partition”, and move on to your root file system:
Use the following settings, choosing to keep existing data and use /
as your mount point …
Continue in a similar manner until all of your disks are set up: