Showing posts with label hard drive. Show all posts
Showing posts with label hard drive. Show all posts

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

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