To align partitions for use in a Linux virtual machine, you need a working Linux virtual machine. Once you have it at hand, follow the steps below:
- Create a new disk for the virtual machine. On this disk, you will create aligned partitions. Then you will connect the disk to a new virtual machine and install your Linux guest OS on this disk.
- Start the virtual machine and log in to it using SSH.
-
Run the
fdisk
utility for the disk you want to align. - Create a primary partition, and set the starting block number for the created partition.
- Repeat steps 3-4 to create and align all partitions you plan to have in your new virtual machine.
The following example creates partition #1 with the size of 1 GB on the /dev/sda
device and uses the offset of 64 KB.
# fdisk /dev/sda Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel Building a new DOS disklabel. Changes will remain in memory only, until you decide to write them. After that, of course, the previous content won't be recoverable. The number of cylinders for this disk is set to 1044. There is nothing wrong with that, but this is larger than 1024, and could in certain setups cause problems with: 1) software that runs at boot time (e.g., old versions of LILO) 2) booting and partitioning software from other OSs (e.g., DOS FDISK, OS/2 FDISK) Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite) Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): 1 First sector (63-16777215, default 63): 64 Last sector or +size or +sizeM or +sizeK (64-16777215, default 16777215): 208848 Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks.
Once you align all the necessary partitions, disconnect the disk from the virtual machine. When creating a new virtual machine, choose this disk for use with this virtual machine.