How to dual boot Fedora (under LVM) and Windows
I had Fedora 12 in a logical volume taking up all the space in my hard drive. Here is what I did to shrink the Fedora partition and create a new partition for Windows 7. I am not an expert so I had to google for solutions to each problem, and I did not find any guide that covers all the steps.
Step 1: Boot Fedora Live media
I used liveusb-creator to create a Live USB. For alternatives, see Live USB instructions or Live CD instructions.
Boot the Live media. My screen was permanently blank after booting; I fixed this by using the kernel option nomodeset.
Step 2: Install Gnome Partition Editor
# yum install gparted
Since GParted does not support LVM, it could not be used to resize my Fedora partition. However, it was useful for visually inspecting my partitions throughout the following steps.
Step 3: Shrink the ext3 filesystem
For reference below:
/dev/sda1is my boot partition./dev/sda2is my main partition./dev/VolGroup00/LogVol00is my Fedora volume./dev/VolGroup00/LogVol01is my swap volume.
Execute these commands:
# e2fsck -f /dev/VolGroup00/LogVol00
# resize2fs /dev/VolGroup00/LogVol00 400G
References:
http://equivocation.org/node/103
http://www.netadmintools.com/art367.html
http://serverfault.com/questions/13666/how-can-i-resize-a-lvm-partition-in-red-hat-without-lose-of-data
Step 4: Shrink the logical volume
Step 5: Shrink the physical volume
Here is where I started encountering problems. Being confused about physical and logical volumes, I figured out what the respective sizes were:
df /dev/VolGroup00/LogVol00gives the size of the logical volume (when it is mounted), 400G.lvdisplaygives the sizes of all logical volumes, 401.94G total (the extra 1.94G is taken by the swap volume).vgdisplaygives the size of the volume group, 465.57G.fdisk -l /dev/sda2gives the size of the physical volume /dev/sda, 465.57G.
Trying to resize the physical volume with the command
gave the error “cannot resize to 12895 extents as later ones are allocated.” I figured that the extents were being taken up by the swap volume. I tried using pvmove to move the swap volume to earlier extents, which did not work (reason). Instead, I removed the swap volume:
# lvm lvremove /dev/VolGroup00/LogVol01
Resize the physical volume:
# pvresize –setphysicalvolumesize=403G /dev/sda2
Re-create the swap volume:
# mkswap /dev/VolGroup00/LogVol01
References:
Red Hat Docs: Adding Swap Space
Red Hat Docs: Removing Swap Space
Step 6: Shrink the partition
The idea here is to delete and re-create the partition in a different size. Don’t forget to correct the partition type afterwards.
Command: d
Partition number: 2
Command: n
Logical or primary: p
Partition number: 2
First cylinder: 26 (default)
Last cylinder or +size: +412700M (a little over 403G)
Command: t
Partition number: 2
Partition type: 8e (Linux LVM)
Command: w
References:
http://www.howtoforge.com/linux_resizing_ext3_partitions
https://help.ubuntu.com/community/ResizeEncryptedPartitions
Step 7: Reboot Fedora Live
Check that the changes were successful using fdisk -l /dev/sda2 or GParted.
Step 8: Create an NTFS partition
Create a new partition over the empty space. When I tried to do this in GParted, it gave the error “The kernel was unable to re-read the partition table…” So I went back to using fdisk with what was learned above.
Command: n
Logical or primary: p
Partition number: 3
Cylinders: (use defaults)
Command: t
Partition number: 3
Partition type: 7 (NTFS)
Command: w
Step 9: Remove GRUB
I made a SuperGrubDisk USB to uninstall GRUB using their instructions. This will help prevent errors with the Windows installation such as “Ensure that the disk’s controller is enabled in the computer’s BIOS menu” or “An error occurred while attempting to read the boot configuration data.”
Step 10: Install Windows 7
First I tried to install Windows XP, but booting the install CD the screen goes blank permanently after “Setup is inspecting your computer’s hardware configuration.”
Then I went with install Windows 7. Facing the errors mentioned in the previous step, I made the mistake of deleting and re-creating the NTFS partition with an extra 8 MB that wasn’t partitioned before, using the tool available in the Windows 7 install DVD. This caused the error “Current NTFS volume size is bigger than the device! Corrupt partition table or incorrect device partitioning?” upon rebooting, and another error by ntfsresize -n. The lesson learned is to make sure sizes are consistent.
I redid steps above to get back to this point. Still, Windows 7 would not install because “Startup Repair cannot repair this computer automatically.” In command prompt:
The volume does not contain a recognized file system.
The solution was to use diskpart to make the NTFS partition active. Startup Repair was then successful and Windows 7 could be installed.
References:
http://channel9.msdn.com/forums/TechOff/255464-Vista-boot-problems/
http://support.microsoft.com/kb/300415
Step 11: Restore GRUB
Boot SuperGrubDisk to restore GRUB.
Step 12: Dual boot
Boot Fedora. Append the following to /boot/grub/menu.lst:
root (hd0,2) (press TAB to list the disks)
makeactive
chainloader +1
Now whenever you boot, you can press any key to choose between Fedora and Windows. To show the GRUB menu always without having to press any key, comment out hiddenmenu from /boot/grub/menu.lst.
Reference: http://apcmag.com/how_to_dual_boot_linux_and_windows_xp_linux_installed_first.htm?page=5
File sharing and mounting
In Fedora, the Windows filesystem should appear under “Places” as 67 GB Filesystem. It mounts when you try to access it (and provide the root password for mounting). This will allow you to transfer files between the two filesystems. Alternatively, you can create a new NTFS partition for storing files you want to access from both operating systems.
To automatically mount the Windows filesystem, instructions can be found at Fedora Unity.

if for some reason your physical extents for your root partition are in the middle, you can create a new logical volume and move data between them and remove the original logical volume and rename the new logical volume to the old one’s name:
lvm lvcreate –size 20G –name LvTmp VolGroup00
dd if=/dev/VolGroup00/LogVol00 of=/dev/VolGroup00/LvTmp bs=4M
lvm lvremove /dev/VolGroup00/LogVol00
lvm lvrename VolGroup00 LvTmp LogVol00
This is tested with similar names and sizes on my machine – do not know how it will turn out yet but it should work. (Fingers crossed)