[clug] duplicate a file system to a smaller hard disk

Chris Zhang chris.zhang.syd at gmail.com
Mon Aug 10 06:42:25 MDT 2009

Brett, thanks for the detailed guidance.

I'll give it a try.


On 10/08/2009, at 10:35 PM, Brett Worth wrote:

> Chris Zhang wrote:
>> I have been looking for a way to clone a complete working Linux  
>> system
>> on a 250GB (22GB used) hard disk to a smaller hard disk.
> Here's a simple series of steps:
> Boot the system with the target disk as sdb
> List the first drive's partition table: fdisk -l sda
> Use fdisk on /dev/sdb to create the new partions as required setting  
> the "Type" flags to
> match.  Just match the partitions from the first disk with adjusted  
> sizes. Obviously at
> least one of them will be a lot smaller.  Save the fdisk config.
> Make the filesystems using mkfs.  The details will depend on what  
> filesystem types you
> have.  Look at the way your mounts are being done in /etc/fstab.   
> You might need to use
> labels.
> Initialise the swap partition with "mkswap".  Might also need a label.
> Make a mountpoint for the new set of filesystems e.g. mkdir /new
> Mount the new root there: mount /dev/sdbX /new
> Mount the other filesystems: e.g. if you have a separate var:
> 	mkdir /new/var
> 	mount /dev/sdbX /new/var
> Repeat with all the filesystems you've made.
> Now for each filesystem:
> 	rsync -avHx / /new/
> 	rsync -avHx /var/ /new/var/
> 	etc...
> Umount the new disk in reverse order:
> 	umount /new/var
> 	umount /new
> Shutdown.
> Remove sda
> Configure new smaller disk as sda
> Boot a rescue CD
> Run grub from the CD
> If you have a separate /boot partition:
> 	grub> find /grub/stage1
> Else
> 	grub> find /boot/grub/stage1
> Set root to the returned value e.g.:
> 	grub> root (hd0,0)
> 	or
> 	grub> root (hd0,1)
> Write out the MBR:
> 	grub> setup (hd0)
> 	grub> quit
> Remove rescue disk
> Reboot
> Have a lot of fun.
> Don't forget to remove the /new directory.
> I'm sure there's a way to get the MBR on there without booting the  
> CD but that's just the
> way I've always done it.
> Brett

More information about the linux mailing list