Let’s face it—hard disk-related activities can never be simple, especially when that disk has data on it. In this article, we’ll take a look at some of the tools that can make these activities easier.
A partitioning tool
There have been many operating systems and live CDs that provide partitioning utilities. Often, they turn out to be either proprietary or not able to support all filesystems used for Linux, Solaris, etc. But GParted is one such important partitioning utility that supports many filesystems and comes with a friendly user interface.
GParted (Figure 1) stands for ‘GNOME partition editor’. With it, you can create, modify and delete partitions. Although you can definitely install it on any distribution and run it, I wouldn’t recommend running it on a booted OS as problems might occur with certain mounted partitions. A better solution is to run GParted from a live CD.
GParted itself comes on a separate live CD; boot it and double click on the GParted icon from the UI presented. It is also a part of a live CD called System Rescue CD. To run GParted from here, first start X by issuing the startx command, and then open the GParted application from the X terminal. It can also be run from a bootable USB drive or via a PXE boot.
Once GParted is run, you can use it for the following operations:
- To create a new partition table (by erasing the old one, if one exists). Use this option very carefully. Unlike other operations, Undo is not supported for this.
- A new partition can be created from unallocated/free space. Decide on new partitions as primary, extended or logical, as required.
- To delete an existing partition.
- To resize/move existing partitions (Figure 2). Sizes can be increased only when free space is available on any adjacent side.
- To change flags/labels of a partition.
- To format a partition to any supported filesystem—ext3, reiserfs, etc.
- To check filesystems for errors.
- To view partition information.
All requested operations are added to the pending queue, which is performed in sequence upon clicking the Apply option.
The following filesystems are supported by GParted presently: btrfs, crypt-luks, ext2, ext3, ext4, fat16, fat32, hfs, hfs+,jfs, lvm2 pv, ntfs, reiser4, reiserfs, swap, ufs and xfs. Check GParted.sourceforge.net/features.php for individual support of each filesystem and for updates.
g4u is a disk cloning software. It is helpful in larger organisations like educational institutes where there are several machines of identical configuration. Every system may need multiple operating systems along with some updates and customisation. Repeating these for every system is a tedious task. So cloning is a good technique to avoid such problems by copying many disks from one fully prepared one. Also, when one or more operating systems crash on one system, it can be recovered quickly by copying the OS from an identical system.
This software has a few advantages over other cloning utilities. One is that it’s free. Second, it is independent of partitions, filesystems and operating systems that exist on a disk, as cloning is performed block by block. The only requirement is that the target disk should be larger than the original disk.
g4u comes as live media, in the form of two bootable floppies or a bootable CD. The images for floppies/CD can be downloaded from www.feyrer.de/g4u/#reqs. As of today, the latest stable version of g4u is 2.3.
Disk cloning can be done in two ways — locally, by connecting two or more disks to a system at a time, and remotely, where the image of the original disk is stored on an FTP server, which is used for other disks to be copied using FTP.
So, to perform disk cloning, connect two or more disks for the local copy, or one disk and the network set up if you plan to use FTP, and run g4u from a live CD or bootable floppies. A terminal will be presented to use the following commands:
diskslists all connected disks, and specifies identifiers for each. IDE hard disks are identified by wd0, wd1, etc, whereas SATA disks are identified by sd0, sd1, etc. Here, wd0/sd0 represents the first/primary hard disk.
parts <disk-name>lists the available partitions in a specified disk. For example,
parts wd0lists partitions of disks identified by wd0. See Figure 3.
copydisk <disk1> <disk2>copies all data from disk1 to disk2, block wise (Figure 4). For example,
copydisk wd0 wd1.
copypart <d1p1> <d2p2>copies a partition from one disk to a partition on another disk. For example,
copypart wd0e wd1f, copies the second partition of disk1 to the third partition of disk2. (Here the letters d, e, f, etc, in no way concern the drive letters of any OS. g4u assigns a character for each partition, starting from d for the first partition.)
uploaddiskstores the image of the whole disk on an FTP server:
uploaddisk ftp-address imagename disk-id
ftp-addressis the IP address of the FTP server. By default, the FTP account named ‘install’ is used. Use [email protected] for any other account.
disk-idis the identifier of the hard disk (for example, wd0, wd1, sd0, sd1, etc) whose image needs to be uploaded. It is optional. The absence of
disk-idimplies taking the image of the first hard disk, which is identified by rwd0d. Also, by default, gzip-9 compression is used while saving images with a typical extension like .gz. To use lower levels of gzip compressions (higher levels of compression take a longer time to back up/restore) use the following:
GZIP=1 uploaddisk ftp-address imagename disk-id
uploadpartstores the image of a particular partition on the FTP server:
uploadpart ftp-address imagename disk+part
slurpdiskrestores a disk from the FTP image:
slurpdisk ftp-address imagename
slurppartrestores a partition from the FTP image:
slurppart ftp-address imagename disk+part
It is preferable to run g4u in a DHCP-enabled network if FTP transactions are planned. If DHCP is not available, the network needs to be set up manually.