How to create NTFS partition in Linux to install Windows 7 from USB?

16
2013-10
  • Michal Stefanow

    I messed up with my computer and need help.

    Generally: install Windows 7 from USB.

    Problem: "setup was unable to create a new system partition"

    When first attempt to install Windows 7 failed I tried Linux live USB, installed distro to HDD, and erased all the existing partitions. Current state (fdisk -l): [writing from other computer so no copy and paste]

    /dev/sda1   305GB   Linux
    /dev/sda2   7GB Extended
    /dev/sda5   7GB Linux Swam / Solaris
    

    To create a new, NTFS partition:

    fdisk /dev/sda
    n (for new)
    p (for primary)
    3 (for partintion number)
    "No free sectors available"
    

    All the HDD was formatted couple of minutes before so there is a lot of free space but how to resize a parition?

    I cannot find an option for resizing in man fdisk. Some people say I should use gparted but my distro doesn't not contain this package. And my distro doesn't support wireless drivers so I have serious problems with downloading stuff.

    I tried also using cfdisk but any command results in:

    "cfdisk bad primary partition 1 partition ends in the final partial cylinder"
    

    I tried also removing partition 1 and then creating a new one (so there is no "no free sectors"). I'm receiving a warning:

    "Re-reading the partition table failed with error 16: Device or resource busy.
    The kernel still uses the old table. The new table will be used at the next reboot."
    

    After restarting: grub rescue, no known filesystem

    It may indicate that some changes have been made BUT when running Windows 7 installed some another error: Windows cannot be installed to Disk 0 Partition 1

    More detailed: Windows cannot be installed to this hard disk space. Windows must be installed to a partition formatted as NTFS.

    So formatting drive using Windows 7 installer

    BUT this time yet another error: "Setup was unable to create a new system partition or locate an existing system partition. See the setup log files for more information"

    Apparently I cannot access logs (how?) and I am back to drawing board with my live USB (this time showing partition as HPFS/NTFS).

    Any suggestions how to install Windows 7? Should I reinstall Linux to HDD, erase existing partitions once again, and use Parted rather than gparted (parted is included in the distro). Or maybe should I create another bootable USB such as PartedMagic to painlessly create partitions?

    I just want to install Windows 7 from USB, my laptop is semi-operational and I am ready to receive some help regarding fdisk and creating NTFS partitions.

    UPDATE: I did as suggested (removed all the partitions) and tried to install in unallocated space. Tried to create a new partition and format it. Same error: "setup was unable to create a new system partition"

    Came to the conclusion it may have something to do with TrueCrypt I have recently installed. Right now trying to FIX MBR (as I haven't got possibility to create rescue disc without optical drive)

  • Answers
  • Malachi

    @kobaltz kind of hinted at this, but I am going to say it anyway:

    1. Save all the important data from the computer on removable disks
    2. Then format and install Windows 7
    3. After you have installed Windows 7 install Linux, it will make a partition for itself

    I have never tried to install Windows on a Linux machine; I have installed Linux on a Windows machine though. You can set up the boot loader to automatically boot into one or the other or let you pick each time you boot up.

    Addition

    when Windows 7 is the only thing on the computer, Windows 7 doesn't give you a very big "window" to change the boot order. you have to stop the boot loader from booting straight into Windows. on startup I had to hold a key at a certain point so that I could get it to check a USB or CD for the install of Ubuntu. it will most likely be specific to your computer, which key you have to hold and when you have to press it. other than that it is a pretty easy process. I would Google some things about the different linux partitions and partition formats. as I did when I installed Ubuntu. I would give more info on it but it was over 2 years ago that I did this. now I have a dedicated Linux machine and on my Windows machine I am trying to uninstall Linux and return it to a Windows dedicated machine.

  • kobaltz

    Is there a reason why you can't use Linux to delete all of the partitions. Boot Win 7 Installation from USB Drive, and then install normally? With no partitions, the Win 7 installer will allow you to create a new partition and automatically format it to NTFS plus a 100MB System Partition.


  • Related Question

    linux - How to create device driver for nested partitions?
  • NVRAM

    I'm running MSWindows virtualized with /dev/sda2 as it's primary drive. Consequently, there is a partition table on that partition, shown as:

    # fdisk -l /dev/sda2
    
    Disk /dev/sda2: 137.4 GB, 137436203520 bytes
    255 heads, 63 sectors/track, 16709 cylinders
    Units = cylinders of 16065 * 512 = 8225280 bytes
    
         Device Boot      Start         End      Blocks   Id  System
    /dev/sda2p1   *           1       16708   134206978+   7  HPFS/NTFS
    

    So my question is simply: What are the major/minor numbers to create /dev/sda2p1? What about sda2p2 and sda3p1?


  • Related Answers
  • larsks

    Assuming this is a straight disk image (e.g., your virtualization solution is not adding some extra metadata to things), this document (also here) offers some suggestions for accessing your partitions on /dev/sda2 (summary: use the -o offset option to losetup to create a new block device referencing the appropriate offset into sda2).

    You can also use the Network Block Device (NBD) to create a partitioned block device from /dev/sda2, see this LWN article which described the process in detail. And hey, I just learned something new.