Google now allows you specify the size of your boot disk larger than 10GB when you create your instance. In any case, if you need to resize your boot disk for any reason, these are the steps I followed.
Here I’ve attached a 250GB blank disk to the instance:
Disk /dev/sda: 10.7 GB, 10737418240 bytes 4 heads, 32 sectors/track, 163840 cylinders, total 20971520 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 4096 bytes I/O size (minimum/optimal): 4096 bytes / 4096 bytes Disk identifier: 0x000ca37e Device Boot Start End Blocks Id System /dev/sda1 * 2048 20971519 10484736 83 Linux Disk /dev/sdb: 268.4 GB, 268435456000 bytes 255 heads, 63 sectors/track, 32635 cylinders, total 524288000 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 4096 bytes I/O size (minimum/optimal): 4096 bytes / 4096 bytes Disk identifier: 0x00000000 Disk /dev/sdb doesn't contain a valid partition table
sudo apt-get install pv dd if=/dev/sda bs=64K | pv | dd of=/dev/sdb bs=64K
“pv” gives you a progress of the “dd” command. This will take some time. Once it’s finished:
10GB 0:03:43 [45.7MB/s] [ <=> ] 163840+0 records in 163840+0 records out 10737418240 bytes (11 GB) copied, 223.898 s, 48.0 MB/s 163840+0 records in 163840+0 records out 10737418240 bytes (11 GB) copied, 227.444 s, 47.2 MB/s
Now we re-partition the disk:
sudo fdisk /dev/sdb hit "p" to list the partition. hit "d" to delete the partition. hit "n" for new partition. hit "p" for primary hit "1" for partition number. enter the first section ("Start" from the "p" command above). In this case it was "2048" For last sector, just press enter to max it out. Select partition number "1" hit "w" for write.
Now you could run:
e2fsck -f /dev/sdb1 resize2fs /dev/sdb1
- Detach the disk,
- Clone the instance and choose this disk as the root disk.
- SSH and make sure everything looks good.
Disk /dev/sda: 268.4 GB, 268435456000 bytes 4 heads, 32 sectors/track, 4096000 cylinders, total 524288000 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 4096 bytes I/O size (minimum/optimal): 4096 bytes / 4096 bytes Disk identifier: 0x000ca37e Device Boot Start End Blocks Id System /dev/sda1 * 2048 524287999 262142976 83 Linux df -h Filesystem Size Used Avail Use% Mounted on /dev/sda1 247G 9.1G 225G 4% / none 4.0K 0 4.0K 0% /sys/fs/cgroup udev 1.8G 8.0K 1.8G 1% /dev tmpfs 371M 332K 370M 1% /run none 5.0M 0 5.0M 0% /run/lock none 1.9G 0 1.9G 0% /run/shm none 100M 0 100M 0% /run/user
- Once it looks good, you could delete the original instance and create a new instance with this disk.
Recent Comments