Dumping a full disk is a quick way to perform a backup:
# dd if=/dev/sdb of=filename.dsk
But once you have such a dump, you can't directly mount it, you must use kpartx:
# kpartx -av filename.dsk
add map loop0p1 (252:0): 0 7830408 linear /dev/loop0 1144
You can see the partitions with fdisk
# fdisk -l /dev/loop0
Disk /dev/loop0: 4009 MB, 4009754624 bytes
128 heads, 22 sectors/track, 2781 cylinders, total 7831552 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xc3072e18
Device Boot Start End Blocks Id System
/dev/loop0p1 * 1144 7831551 3915204 b W95 FAT32
Now you can mount the partitions that are inside the disk image.
# mount /dev/mapper/loop0p1 /mnt
# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda5 31G 12G 18G 41% /
udev 3.9G 8.0K 3.9G 1% /dev
tmpfs 1.6G 960K 1.6G 1% /run
none 5.0M 0 5.0M 0% /run/lock
none 3.9G 200K 3.9G 1% /run/shm
/dev/sdb5 20G 1.4G 18G 8% /home
/dev/mapper/loop0p1 3.8G 1.1G 2.7G 29% /mnt
Once you've done, you can umount it with
# umount /mnt
# kpartx -dv filename.dsk
del devmap : loop0p1
loop deleted : /dev/loop0
Note:
Ubuntu doesn't have kpartx installed by default:
# sudo apt-get install kpartx
Countless times I've found solutions on the net: I'll try to give back some, by sharing interesting things I'll come across.
Showing posts with label partedmagic. Show all posts
Showing posts with label partedmagic. Show all posts
2012-10-15
2012-05-18
Replacing a mechanical HD with an SSD
My home PC is aging... It's 6 years old now, and while this confirms the goodness of the choices I've made when I built it, this also means that the XP installation has gathered so many stuff that it's now slow as hell.
A full boot takes now as much as 4'20":
30" from startup to the login screen of Windows XP
3'40" to quiesce all disk activities.
At that point, 40 more seconds are necessary from login to complete disk stop. Trying to launch any program before the disk settles out, just results in more thrashing and an even slower startup.
So I've bought a Crucial m4 SSD to see if this upgrade can make a difference.
This was the starting configuration:
I have 2 HDs in my PC, one for the OS and one for the data.
The OS is multiboot, so I have one partition for XP and one for Ubuntu.
The remaining disk space is for Windows program files partition.
On the second unit there are the swap partitions for Windows and Linux, the Documents and Settings partition, the /home filesystem and some spare space for Windows.
The purpose of this layout is to allow concurrent access to OS and swap, OS and user files, applications and user data.
The first step was copying the content of the first disk onto the new ssd.
I connected the new disk to an empty SATA connector and booted into Parted Magic.
Using GParted I initialized the new disk with Device -> Create Partition Table, then it was just a copy/paste work between the old partition on /dev/sda and the new disk seen as /dev/sdc
The Crucial M4 is just 119GiB while my old disk was 153, so I needed to shrink the sda3 partition to make it fit.
After copying the /dev/sda1 partition I needed to set the "boot" flag on it on the new disk to make it bootable.
GParted copied all partitions but left a standard Windows MBR, so grub was gone and linux didn't boot.
To restore the grub MBR I've followed this excellent guide, and linux was back in action.
Windows booted but wasn't in good shape either:
I logged in and the whole desktop froze with only the wallpaper displayed, but no start button, taskbar or icons.
It just hung there forever.
I rebooted in safe mode by pressing F8 and choosing "Safe mode with command prompt".
A popup went up, saying that windows had found new hardware and the drivers had been installed.
One more reboot and Windows was fine with the new disk.
Now a complete boot takes as low as 19 seconds, and no more disk thrashing after loggin on: the Start menu is immediately available and responsive.
The last step was setting noatime in /etc/fstab to reduce writing on the SSD.
So, here it is, by comparison with a traditional 3.5" HD, the little Crucial M4
A full boot takes now as much as 4'20":
30" from startup to the login screen of Windows XP
3'40" to quiesce all disk activities.
At that point, 40 more seconds are necessary from login to complete disk stop. Trying to launch any program before the disk settles out, just results in more thrashing and an even slower startup.
So I've bought a Crucial m4 SSD to see if this upgrade can make a difference.
This was the starting configuration:
I have 2 HDs in my PC, one for the OS and one for the data.
The OS is multiboot, so I have one partition for XP and one for Ubuntu.
The remaining disk space is for Windows program files partition.
On the second unit there are the swap partitions for Windows and Linux, the Documents and Settings partition, the /home filesystem and some spare space for Windows.
The purpose of this layout is to allow concurrent access to OS and swap, OS and user files, applications and user data.
The first step was copying the content of the first disk onto the new ssd.
I connected the new disk to an empty SATA connector and booted into Parted Magic.
Using GParted I initialized the new disk with Device -> Create Partition Table, then it was just a copy/paste work between the old partition on /dev/sda and the new disk seen as /dev/sdc
The Crucial M4 is just 119GiB while my old disk was 153, so I needed to shrink the sda3 partition to make it fit.
After copying the /dev/sda1 partition I needed to set the "boot" flag on it on the new disk to make it bootable.
GParted copied all partitions but left a standard Windows MBR, so grub was gone and linux didn't boot.
To restore the grub MBR I've followed this excellent guide, and linux was back in action.
Windows booted but wasn't in good shape either:
I logged in and the whole desktop froze with only the wallpaper displayed, but no start button, taskbar or icons.
It just hung there forever.
I rebooted in safe mode by pressing F8 and choosing "Safe mode with command prompt".
A popup went up, saying that windows had found new hardware and the drivers had been installed.
One more reboot and Windows was fine with the new disk.
Now a complete boot takes as low as 19 seconds, and no more disk thrashing after loggin on: the Start menu is immediately available and responsive.
The last step was setting noatime in /etc/fstab to reduce writing on the SSD.
So, here it is, by comparison with a traditional 3.5" HD, the little Crucial M4
2011-12-04
Expanding the C drive of a VM
This was tested on Windows 2003 R2
Here's a VM that need its C drive expanded:
Edit VM Setting and set the new VMDK size (this can be done online).
Rescan disks, and you'll see extra free space at the end of the partition.
Now boot into Parted Magic.
Select the first partition, click Resize and set the new size.
You will have to select Apply to actually do the resize.
Reboot into Windows.
CHKDSK will run automatically and finally you will have your expanded C drive.
Here's a VM that need its C drive expanded:
Edit VM Setting and set the new VMDK size (this can be done online).
Rescan disks, and you'll see extra free space at the end of the partition.
Now boot into Parted Magic.
Select the first partition, click Resize and set the new size.
You will have to select Apply to actually do the resize.
Reboot into Windows.
CHKDSK will run automatically and finally you will have your expanded C drive.
Subscribe to:
Posts (Atom)






