Showing posts with label partition. Show all posts
Showing posts with label partition. Show all posts

Monday, August 9, 2010

Tweaking Lenovo IdeaPad S12

I bought Lenovo IdeaPad S12 for $400. This little laptop has 12.1" display, VIA Nano processor, 1GB memory and 160GB hard drive. It's shipped with Windows XP, but I want to install Windows 7 alongside XP, so as to have a dual-boot system.



Shrinking the Recovery Partition


I booted IdeaPad S12 with my own Linux Live CD. In Xterm, I typed the following command:



fdisk -l -u /dev/sda


I got the following output.



Disk /dev/sda: 160.0 GB, 160041885696 bytes
255 heads, 63 sectors/track, 19457 cylinders, total 312581808 sectors
Units = sectors of 1 * 512 = 512 bytes
Disk identifier: 0xee8a96be

Device Boot Start End Blocks Id System
/dev/sda1 * 2048 217909247 108953600 7 HPFS/NTFS
/dev/sda2 217909248 281638911 31864832 f W95 Ext'd (LBA)
/dev/sda3 281638912 312581807 15471448 12 Compaq diagnostics
/dev/sda5 217911296 281638911 31863808 7 HPFS/NTFS


The last primary partition /dev/sda3 seems to be Lenovo's recovery partition. I was able to boot the recovery partition with the following GRUB commands:



root (hd0,2)
chainloader +1
boot


Once I boot into Lenovo's OneKey Recovery System, I can use OneKey AntiVirus to scan the laptop for virus or use OneKey Recovery to restore the laptop to the factory state. I rebooted the laptop with my Linux Live CD. Then, I used GParted to shrink /dev/sda3 and changed its partition number to /dev/sda4:


  1. Shrink /dev/sda3 to 6 GB.
  2. Duplicate /dev/sda3 to a new primary partition /dev/sda4.
  3. Remove the partition /dev/sda3.
  4. Change the type of the new partition /dev/sda4 to 12.


After that, my partition layout looks like this:



Disk /dev/sda: 160.0 GB, 160041885696 bytes
255 heads, 63 sectors/track, 19457 cylinders, total 312581808 sectors
Units = sectors of 1 * 512 = 512 bytes
Disk identifier: 0xee8a96be

Device Boot Start End Blocks Id System
/dev/sda1 * 2048 217909247 108953600 7 HPFS/NTFS
/dev/sda2 217909248 281638911 31864832 f W95 Ext'd (LBA)
/dev/sda4 299997810 312576704 6289447+ 12 Compaq diagnostics
/dev/sda5 217911296 281638911 31863808 7 HPFS/NTFS


I restarted my laptop. I was able to boot Lenovo's OneKey Recovery System using the following GRUB commands.



root (hd0,3)
chainloader +1
boot


Moving Lenovo's pre-installed Windows XP to a logical partition


To reserve primary partitions for other crucial operating systems, I moved the Windows XP partition to the extended partition. This technique is explained in this post. Roughly speaking:



  1. Shrink the Windows XP partition (/dev/sda1) by half using GParted. Space is created between /dev/sda1 (Windows XP, type 7) and /dev/sda2 (extended, type f).
  2. Enlarge the extended partition (/dev/sda2) to the left. A space is created at the beginning of the extended partition.
  3. Make a copy of Windows XP partition in the space of the extended partition. The new partition will become /dev/sda6.
  4. Fix the partition numbers with fdisk (switching partition numbers of /dev/sda6 and /dev/sda5). Previously, /dev/sda6 came before /dev/sda5.
  5. Fix BOOT.INI of the new XP partition (/dev/sda5).
  6. Boot the new XP partition (/dev/sda5) in safe mode using GRUB or SYSLINUX. Change drive letters in the registry.
  7. Reboot Windows XP (/dev/sda5) normally and remove the old partition (/dev/sda1).


Starting Windows XP with SYSLINUX


Recently, I switched to SYSLINUX. I created a 100MB primary partition (/dev/sda1) formatted with FAT16. Then, in Linux, I installed SYSLINUX.


syslinux /dev/sda1

A new MBR had to be installed, too.


install-mbr /dev/sda -v --drive 0x80 --enable +14

I copied chain.c32 from the SYSLINUX package to the SYSLINUX partition (/dev/sda1). Then, I copied NTLDR, NTDETECT.COM and BOOT.INI to the SYSLINUX partition (/dev/sda1), too.


I created a text file named SYSLINUX.CFG with the following instruction.


TIMEOUT 30
DEFAULT chain.c32 ntldr=NTLDR

This will let you boot Windows XP in a logical partition.



Installing Programs on Windows XP


I removed the following programs from factory-installed Windows XP of Lenovo S12:


  • Symantec Norton Internet Security
  • Diskeeper
  • Veriface

Then, I installed the following software:


  • Avast Anti-virus
  • MyDefrag


Installing Windows 7 Home Premium


I created a new NTFS partition (/dev/sda2) using GParted. I set its bootable flag and hid all other FAT and NTFS partitions. Then, I installed Windows 7 Home Premium.


After that, I moved the Windows 7 partition into the extended partition as /dev/sda6. Then, I removed the original partition (/dev/sda2). I rebooted with Windows 7 installation DVD, clicked the Repair option and opened the Command Prompt. I typed the following commands to make the new Windows 7 partition bootable.


C:
bcdedit /store C:\Boot\BCD /enum
bcdedit /store C:\Boot\BCD /set {bootmgr} device partition=C:
bcdedit /store C:\Boot\BCD /set {default} device partition=C:
bcdedit /store C:\Boot\BCD /set {default} osdevice partition=C:

Then, I added the following entry to SYSLINUX.CFG.


LABEL win7
KERNEL chain.c32
APPEND hd0 6

To make sure that SYSLINUX can boot Windows 7, I typed the following command at the boot: prompt.


chain.c32 hd0 6

Now I am able to boot Windows 7 from a logical partition.



Booting Windows 7 with Software SLIC emulation


There are many ways to emulate SLIC so that Windows 7 can be activated. In my case, I've set up a boot sequence like this.


MBR -> SYSLINUX -> GRUB -> Windows 7

GRUB was patched for the loadslic command which is crucial for Windows activation. The SYSLINUX command to invoke GRUB is like this.


chain.c32 grub=stage2 grubcfg=(hd0,0)/win7.cfg

Then, I created a file WIN7.CFG with the following contents.


hiddenmenu
timeout 0
default 0

title Windows 7 Home Premium
loadslic (hd0,0)/lenovocb-01.bin
chainloader (hd0,5)+1

Monday, July 26, 2010

Linux: Using dd To Back Up Hard Drive Partitions

I am going to use the omnipresent and omnipotent tool called dd to back up a hard drive partition. I am working with the drive /dev/sdb. First, I save a text file that has information on the partition table layout.



fdisk -l /dev/sdb > hdpt.txt
fdisk -l -u /dev/sdb >> hdpt.txt


Then, I choose the compression format to use for the backup archive.


  • gzip
  • bzip2
  • lzma
  • xz


My choice for the compression format is lzma which provides superior compression and faster decompression. The following command backs up a partition at /dev/sdb1 with dd and lzma.



dd if=/dev/sdb1 | lzma -9c > backup01.bin.lzma


To restore this backup later, use the following command:



lzcat backup01.bin.lzma | dd of=/dev/sdb1

Sunday, September 13, 2009

Booting Windows Vista/7 From a Logical Partition

It is possible for Windows Vista and Windows 7 to be installed on logical partitions. Windows Vista and Windows 7 use the new bootmgr bootloader to start themselves as opposed to ntldr used by old NT-based operating systems like Windows XP. Therefore, booting Windows Vista/7 from a logical partition takes a different approach from booting Windows XP from a logical partition.



Installing Windows Vista/7 onto a Logical Partition


Windows Vista/7 can be installed into a logical partition at the time of first installation. However, a new primary NTFS partition will be created. This partition is about 100 MB and only contains essential bootloader files, such as bootmgr and BCD. If you intend to remove this Vista/Win7 boot partition, be sure to copy its contents (especially bootmgr and BCD) to the logical partition containing Windows Vista/7 beforehand.

After that, reboot with Vista/Win7 installer CD, choose “Repair Your Computer” and proceed to invoke the Command Prompt. Type the following commands to enable Vista/Win7 to boot from a logical partition.


C:
bcdedit /enum /store C:\Boot\BCD
bcdedit /store C:\Boot\BCD /set {bootmgr} device partition=C:

Restart your computer. Put a CD into CD-ROM that has GRUB bootloader. Most Linux install CD's use GRUB these days. When you see the Grub boot menu, press C or Esc. You are now on the GRUB command line. To find which partition is your Windows partition, type root (hd0, and then press Tab. Windows partitions are mostly type 7. For example, if your Windows partition is (hd0,5), type the following commands to boot Windows.


root (hd0,5)
chainloader +1
boot

The reason why we want to remove the boot partition is most likely because we want to free a primary partition for use by another OS, such as OpenBSD or OpenSolaris. However, in order to boot Windows from a logical partiton, you need to set up a special bootloader, for example, GRUB.



Copying Windows Vista/7 from Primary to Logical Partition


If you installed Windows Vista/7 on a primary partition and want to move it to a logical parition, we need GParted to manipulate partitions. To get GParted, I recommend you to download one of the following ISO's:



Use GParted to copy Windows Vista/7 from a primary partition to a logical partition. Then, delete the original primary partition containing Windows Vista/7. Grab your Windows Vista/7 install DVD and reboot your PC with it. Click “Repair Your Compure” option and open a Command Prompt. Type the following commands to fix the C:\Boot\BCD file.


C:
bcdedit /enum /store C:\Boot\BCD
bcdedit /store C:\Boot\BCD /set {bootmgr} device partition=C:
bcdedit /store C:\Boot\BCD /set {default} device partition=C:
bcdedit /store C:\Boot\BCD /set {default} osdevice partition=C:

Reboot. Use the following GRUB commands to start Windows Vista/7. In this example, (hd0,5) is the logical partition that has Windows Vista/7.


root (hd0,5)
chainloader +1
boot


Validating the System Restore Drive


After booting Windows Vista/7, open the System Properties dialog and make sure that the Available Disks in System Protection tab are all valid.


System Protection Tab

Related Posts


Saturday, September 12, 2009

My Partitioning Strategy

Synopsis


  • Partitioning shall be done with Partition Magic, Acronis Disk Director or GParted. GParted is the preferred tool. However, compatibility of the partition table is important between different partitioning tools.
  • The current and the past partition layout must be kept on an external media at all time. This layout is produced by the command “fdisk -l -u /dev/[sh]d?” in Linux. The resulting file can be read by a text editor.
  • The MBR shall contain the boot code installed by Debian's mbr package.
  • The first primary partition shall be about 96MB in size, formatted FAT16 and installed with SYSLINUX bootloader and FreeDOS.
  • Another primary partition shall host OpenBSD or Windows XP.
  • One extended partition will be reserved to host any number of logical partitions containing OS, swap and data.
  • The first logical partition inside the extended partition will always be Linux swap for hibernation usage. The second logical partition will be Linux swap exclusively.
  • After Linux swap, the order of logical partitions shall be Linux partitions, Windows partitions and FAT16/FAT32 partitions containing personal data.


Limitation of PC partition table


As I expect to install and explore multiple OS on a single hard drive, I realize the difficulties caused by partitioning limitations. The major limitation is that we can only have up to 4 primary partitions. However, we need a single extended partition so that we can have more than 4 partitions — an extended partition can contain an infinite number of logical partitions in itself. Thus, my final partition layout would have 3 primary partitions and one extended partition.



Recovery Partition


Most manufactured computers have Windows pre-installed. The trend today is that PC vendors (HP, Compaq, Dell, Toshiba etc.) provide a system recovery partition so that users can restore their system back to the factory state in problematic occasions. I don't recommend anyone to remove or erase the System Recovery partition for any reason — even if he actually bought an expensive retail box of Microsoft Windows CD/DVD. Thus, with an intact System Recovery partition (which is a primary partition because it must boot up with a custom Windows installer), we can only have up to 2 primary partitions and one extended partition for our own use.



My Hard Drive Partition Layout

The vendor-provided Recovery partition shall never be removed, but it can contain custom boot codes (for example, GRUB). Assuming that the Recovery partition is formatted as FAT filesystem, you can install GRUB into the Recovery partition so that you can have a nice boot menu for you to choose an OS from when you turn on your PC. If the Recovery partition is formatted as NTFS, GRUB for DOS should be installed instead because the original GRUB cannot natively read NTFS. Alternatively, GRUB can be installed into a logical partition.



There's a way to create a custom Windows XP OEM CD from the System Recovery partition, as explained on howtohaven.com. Once you've created a Windows XP OEM CD, you may remove the Recovery partition at your own peril.



Extended Partition Layout

Allocation of Primary Partitions


Now, we have 2 precious primary partitions to allocate to demanding operating systems after we decided to keep one System Recovery partition and one extended partition. Such demanding OS's include Microsoft Windows and *BSD (i.e. NetBSD, OpenBSD, FreeBSD, etc). Since people using *BSD are very hard to find, I assume you'll use both of the two primary partitions for Windows installations, for example, one for Windows 7 and the other for Windows Vista. In my case, I will reserve one primary partition for OpenBSD and another for Windows Vista Home Premium since I use OpenBSD, though not as often as Linux.



My Partition Table

Space reserved for Vista/Win7 Boot Codes


When Vista is installed on a fresh new hard drive, the first NTFS partition is created starting at the 2048th sector. However, to reserve space for Vista boot codes, I will create the first primary partition beginning at the 96390th sector.



Extended Partition


The extended partition can contain an unlimited number of logical partitions. Therefore, inside the extended partition, I am free to install as many OS's as I wish if there's enough space. I can install Windows XP or a variety of Linux distributions on logical partitions. The first logical partition (/dev/sda5) should be a Linux swap partition because it is the place that should rarely change or move.



To Do


  • Write about shared User data partition for multiple Windows OS's
  • Setting up Read-only Linux partition and Changeable Linux partitions with the help of Unionfs

Installing and Booting Windows XP on a Logical Partition

WARNING: Although this post is about Windows, the instruction involves the use of Linux software, such as GParted partitioning tool and GRUB boot loader. If you are not familiar with these Linux tools, please be careful when following the instructions below. I'll add non-Linux instructions to this post later.


You can download Live CD's containing GParted from the following locations:




Copying Windows XP to a Logical Partition using GParted



It is possible to boot Windows XP from a logical partition. First, install Windows XP to a primary partition. Boot your PC with Parted Magic or SystemRescueCD. Start GParted and copy the Windows XP partition to an empty space in the extended partition. You may have to create an extended partition first and then reserve a space inside the extended partition large enough for the new logical partition.



Fixing BOOT.INI for the Windows XP logical partition


Don't reboot yet. Mount the new logical partition containing a copy of Windows XP. To do so, start an Xterm and type something like:


mount -t ntfs-3g /dev/sda5 /mnt
vim /mnt/boot.ini

The BOOT.INI file should be modified so that it points to the new logical partition. Read this article to learn about its format.


[boot loader]
timeout=0
default=multi(0)disk(0)rdisk(0)partition(5)\WINDOWS
[operating systems]
multi(0)disk(0)rdisk(0)partition(5)\WINDOWS="Microsoft Windows XP Professional" /fastdetect /noexecute=optin

Save the BOOT.INI file and reboot.



Changing the Drive Letters with Windows Registry


Reboot with the Parted Magic or SystemResueCD again. When you're at the GRUB boot menu, press C to exit the menu and manually enter GRUB commands. You need to boot to the XP logical partition:


root (hd0,4)
chainloader +1
boot

Right after entering the boot commands, press and hold the F8 key. You'll be shown the Windows XP boot menu. Choose "Safe Mode" to boot to the Windows safe mode. Once inside the safe mode, change the drive letters with the Windows registry editor (regedt32.exe). Reboot to the XP logical partition using GRUB, this time in the normal mode. Check if Windows XP works normally. You can make sure that you're really using the logical partition by reading the C:\BOOT.INI file.

Saturday, June 6, 2009

To Convert a FAT16 partition to FAT32 in Windows 98/ME

To convert a FAT16 partition to FAT32 in Windows 98/ME, you need to reboot with the emergency book floppy created by Windows. To create a boot floppy:




  1. Open the Start menu, open the Settings submenu and click the Control Panel.
  2. Click Add/Remove Programs.
  3. Select the Boot Disk tab in the pop-up window, and choose Create.
  4. Insert a blank floppy into your floppy drive and let Windows do the job.
  5. Then reboot your PC.


Once you're in DOS, change to C:\Windows\Command. Run CVT.EXE which will convert your FAT16 drive to FAT32.



C:

CD \WINDOWS\COMMAND

CVT C:

Saturday, March 28, 2009

Using GParted To Create Dual-Boot Vista Partitions

Have you ever wished to have multiple Windows installed on your computer? Having a multi-boot system has many applications, such as:



  • Set up one Windows system for your work or school, and set up another Windows system for your family and kids, all in one single computer
  • Use one Windows installation for your sensitive data, and use another installation for gaming and the Internet
  • Set up multiple Windows for different languages, for example one for English and another for Spanish
  • Try different Windows versions, one for Vista, one for XP and another for Windows ME.

In order to set up multiple installations of Windows in a single computer, you need to slice your hard drive into several partitions using a partitioning tool such as GParted. Get a GParted live CD and boot your computer with it.



Partitioning Advices


Here's what you need to know about multiple Windows installation:



  • One primary partition must be set up with Windows Vista or XP and set active. This partition will be used to boot itself and optionally other Windows partitions, primary or logical.
  • If multiple primary partitions have Windows installed, then only one of them should be active and the others should be hidden.


GParted in Action


Once you booted GParted live CD, launch GParted.


GParted first look

In most case, you'll see a Windows partion (type ntfs) as the first primary partition. If you need to resize it to make space available for the second Windows partition, you can use GParted, but I recommend you to use ntfsresize.


Now hide your existing Windows partition by right-clicking it and choosing Manage Flags.


GParted Manage Flags

Clear the boot flag and set the hidden flag. Then click Close.


GParted hide partition

Click the unallocated area and click New on the toolbar. Create new Partition dialog appears on screen. Set the size in the New Size box, create it as a Primary Partition and make it ntfs. Click Add.


GParted Create new Partition dialog

Look at the GParted window and make sure the new hard disk layout is okay. Click Apply on the toolbar.


GParted changed new layout

A confirmation dialog appears. Click Apply.
GParted Apply operations to device

If everything goes well, a dialog appears saying All operations successfully completed. Click Close.


GParted All operations successfully completed.

Right-click the newly created NTFS partition and select Manage Flags from the right-click menu. In the Manage flags window, only set the boot flag and click Close.


GParted Manage Flags

Quit GParted. Put your Windows installation DVD into your CD-ROM and reboot.

About This Blog

KBlog logo This blog is about current events and issues concerning general population. Thanks for visiting the blog and posting your comments.

© Contents by KBlog

© Blogger template by Emporium Digital 2008

Followers

Total Pageviews

icon
Powered By Blogger