-
-
Save kjseefried/cf11583337f852caea63 to your computer and use it in GitHub Desktop.
clone & resize Ubuntu Cloud image from 2GB to 40GB in 2 seconds
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# time ./do-all.sh | |
+ lvcreate -kn -s -n ubunt2 /dev/k2/ubunt | |
Logical volume "ubunt2" created | |
+ lvresize -L 40G /dev/k2/ubunt2 | |
Extending logical volume ubunt2 to 40.00 GiB | |
Logical volume ubunt2 successfully resized | |
+ echo -en 'd\nn\np\n\n\n\n\n\nw\nq\n' | |
+ fdisk /dev/k2/ubunt2 | |
Command (m for help): Selected partition 1 | |
Command (m for help): Partition type: | |
p primary (0 primary, 0 extended, 4 free) | |
e extended | |
Select (default p): Partition number (1-4, default 1): Using default value 1 | |
First sector (2048-83886079, default 2048): Using default value 2048 | |
Last sector, +sectors or +size{K,M,G} (2048-83886079, default 83886079): Using default value 83886079 | |
Command (m for help): Command (m for help): Command (m for help): The partition table has been altered! | |
Calling ioctl() to re-read partition table. | |
WARNING: Re-reading the partition table failed with error 22: Invalid argument. | |
The kernel still uses the old table. The new table will be used at | |
the next reboot or after you run partprobe(8) or kpartx(8) | |
Syncing disks. | |
+ true | |
+ kpartx -a /dev/k2/ubunt2 | |
+ '[' '!' -L /dev/mapper/k2-ubunt2p1 ']' | |
+ sleep 0.1 | |
+ '[' '!' -L /dev/mapper/k2-ubunt2p1 ']' | |
+ sleep 0.1 | |
+ '[' '!' -L /dev/mapper/k2-ubunt2p1 ']' | |
+ resize2fs /dev/mapper/k2-ubunt2p1 | |
resize2fs 1.42.10 (18-May-2014) | |
Resizing the filesystem on /dev/mapper/k2-ubunt2p1 to 10485504 (4k) blocks. | |
The filesystem on /dev/mapper/k2-ubunt2p1 is now 10485504 blocks long. | |
+ kpartx -d /dev/k2/ubunt2 | |
real 0m1.986s |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment