0
dd if=/dev/sda of=/dev/sdb

I want to create a clone a bootable USB stick.

lets say sda is 2GB sdb is 32GB.

The above line will create a replica but the usable size will be 2GB. How can I use the remaining 30GB? (resize partition or modify the command so that it will maximize the usable space)

Cocoa Dev
  • 185
  • 2
  • 3
  • 9

2 Answers2

4

UPDATE: When you copy the drive instead of the partition, the partition-table gets overwritten and it might not be possible to make the partion bigger afterwards because the partition-table says that the disksize is only 2GB. On the other hand, if you copy only the data of the partition, the bootloader will break. You might want to have a different filesystem (e.g. ext3 instead of fat32), then dd won't work and you have to use cp.

ArchLinux wiki has an excellent tutorial for this.

Now you have to reinstall grub2 bootloader to your disks mbr (not the partition): tutorial

If you're still having problems, this might help: link

3

If you're using dd to make and apply your disk image, you will then need to use a partition management tool like gparted to expand the partition after it has been applied to the larger destination disk.

Wesley
  • 32,690
  • 9
  • 82
  • 117
  • thats what I thought but I was hoping for a linux trick that would do both in 1 step. Thanks – Cocoa Dev Apr 19 '12 at 19:30
  • dd doesn't know anything about filesystems and partitions. You'll need a tool that knows something about those things to manipulate them. – cjc Apr 19 '12 at 19:33
  • @CocoaDev IF you write zeros to empty space before cloning with `dd`, you can then compress the dd file rather nicely. – Wesley Apr 19 '12 at 19:33
  • You could use gparted to close the disk and resize, and skip the dd step. – Zoredache Apr 19 '12 at 19:46
  • If you want to do this all from a script, you can - but you'll need to know what filesystem is on sda. Then you can use the right tool - extresize, ntfsresize, etc. – NathanG Apr 19 '12 at 19:51
  • The filesystem I am using is FAT16 – Cocoa Dev Apr 19 '12 at 20:12
  • @CocoaDev FAT16 has an [architectural filesystem size limit of 2 GB](http://support.microsoft.com/kb/118335/en-us). So no luck with resizing then. – the-wabbit Apr 19 '12 at 21:05
  • After cloning, you can always convert the FileSystem to NTFS using the convert command in Windows – Cocoa Dev Apr 23 '12 at 14:41
  • Does gparted ship with Ubuntu 11.1? – Cocoa Dev Apr 23 '12 at 14:41