Over the past few months, whenever I booted under Windows, it would just freeze and force me to reboot. Then do a very long checkdisk at the next boot. I blamed Windows. Then at some point, while using GNU/Linux, I got a notification on the GNOME desktop that one of my hard drives was failing and was having bad sectors. (By the way, kudos for the team behind the Palimpsest utility that generated such notification). Since it was consistent with the windows freeze and failures, I figured it was time to replace my hard drives. Switch to SSD, maybe? After shopping, I ended up buying a 120GB SSD drive, as well as a 750GB HDD. Which were supposed to replace my two dying 250GB drives (well, only the primary drive was dying, but I was thinking about expanding the storage on my personal laptop anyways…).
Let’s call O1 my old primary hdd, O2 the secondary one, N1 the SSD and N2 the new HDD. O1 contained some data partition, as well as the original Vista partition, and “Splashtop/Rescue partition”. O2 contained more data partitions, and my existing Mageia 2 installation.
Somehow, I’d have to find a way to replicate the system partitions from O1 on the smaller N1, then copy the contents of O2 on N2, and put the rest of the old data partitions from O1 to N2. Any idea how to do that without having to purchase proprietary software?
Well, the answer is in the title. Using a Mageia 2 Live CD (most likely any other GNU/Linux Live CD would have worked as well), I could boot into a fully functioning system that didn’t require any of my hard disks to be mounted. So I carefully plugged O2 and N2, then booted the Live CD. From there, opening a terminal, I made sure both hard drives were not mounted (
mount -a will show you what’s mounted and what isn’t), then I just used
dd to clone O2 onto N2.
dd if=/dev/sda of=/dev/sdb
Warning: pay very very very special attention when using
dd. Many a partition has been wiped inadvertently by a bad use of
ddis simple, it takes whatever you pass as
if, and binary copies it onto
of. I strongly advise you to use
hdparm -i /dev/sdx(with
/dev/sdxthe device name of your hard drive) in order to identify which drive is which.
Running the above command clones O2 onto N2. Nice and clean. Only thing is, it also clones the partition table. So N2, my 750GB drive, now looks like it’s only maxed out at 250GB. In order to fix that, I used
gparted, and simply “extended” the partition table so that it takes the whole 750GB of available space.
dd is cool, but it’s really low-level, and will not be able to cope with faulty drives very well (how surprising… if the data cannot be read, it cannot imagine the bits and pieces magically? )
To take care of the bad NTFS Partitions, I put back O1 in the laptop, left N2 as the secondary drive, and booted in safe mode. (Actually, at this point, I also tried booting the GNU/Linux freshly cloned onto N2, just to make sure everything was fine. And of course it was ). Once in safe mode, I tried to check the drive for bad sectors one last time before the cloning:
After that was done, I rebooted under the LiveCD, and proceeded on the partition cloning. Due to the bad sectors on the drive,
dd would fail me. Instead, I used
ntfsclone, which also allows cloning of partition even when they are in a ‘dirty’ state. The syntax is slightly different from
dd. Again, be very careful and re-read your command seven times before hitting the Enter key. The magic option for “best effort” is the
--rescue option. And with
ntfsclone, the last argument is the input file (called the source on the man page), while the output file/device is specified by the
--overwrite option (when copying to a non-existing partition,
--output works just fine).
ntfsclone --overwrite /dev/sdb5 --rescue /dev/sda1
Here, I basically asked the first partition on
/dev/sda1 to be cloned on the second drive, as the partition called
That went rather smoothly. I continued the process with the remaining partitions, eventually switched hard drives a couple more times, but I think by now, you get the idea.
- Always triple, quadruple check your commands before running any of them. Read the man page for each beforehand. Use
hdparm -i /dev/sdx0in order to identify your disks.
- To clone one hard drive directly onto another one, use a LiveCD of a GNU/Linux distro, and after carefully checking your disk labels, launch the
ddutility to perform a low-level binary copy of everything.
- When cloning onto a larger drive, you may want to use
gpartedafterwards to fix the partition table and make it extend to the full size of your disk.
- To clone an NTFS partition, which has bad sectors, instead of
dd, use the
ntfscloneutility with the
Mageia 2 is out! Updated packages, new versions for pretty much everything! A long time Linux user, from Mandrake to Mandriva, I made the switch to Mageia pretty much as soon as it was made available, on both my personal desktop and laptop.
After upgrading to Mageia 1 on my old desktop, I ran into some problems with the nvidia drivers. (Note: if you run into a problem with GNU/Linux, talk about it. In my case, I sent a bug report. Mageia 1 included Xorg 1.10, which was not yet supported by the legacy nvidia96xx drivers I needed to use for the old GeForce 4 Ti 4200 that was in there. The support from the mageia QAs, developers and packager was great. Since I’m not using my desktop PC so much anymore, I was fine with reverting to the “nv” driver for a while, and as soon as NVIDIA released new proprietary 96xx drivers, they got pushed to the “Updates Testing” repository, and shortly afterwards, to the official Updates repository.
When Mageia 2 came out, I first upgraded my personal laptop using the live update method. It went rather smoothly, and the system seemed pretty stable. I also checked the errata, and didn’t see anything too bad. I figured I could safely update my desktop too, right? But after all this time, I forgot to check the Xorg+nvidia driver compatibility…
And once again, the latest version of Xorg is not compatible with the NVIDIA 96xx drivers. So after the update, I got a “Command prompt surprise” basically indicating that X failed to start.
Checking mageia’s repository, I saw that the nvidia96xx package had been removed. So the QA did know that the driver wouldn’t work. And inspecting the xorg.conf file told me that the distro tried to upgrade me to the nouveau driver, which is also a good approach (without knowing that it is not exactly working with my card, I still have to check whether I should report the issue to the nouveau team or the gnome team…)
So I went back to using the legacy ‘nv’ driver for a while, and I’ll wait for new NVIDIA 96xx drivers to be released (one can only hope…).
But all this could have been easily avoided:
- Knowing I had problems with Mageia 1, I should have thought about checking which X version was included in Mageia 2, and check the NVIDIA proprietary driver’s status.
- Or I could have burned one of the LiveCD images. I would immediately have seen the display issues, warning me not to upgrade yet…