forked from shedd/duckpan-vagrant
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmanual-disk-shrink-steps.txt
64 lines (50 loc) · 2.4 KB
/
manual-disk-shrink-steps.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
comment out every ^deb-src line in /etc/apt/sources.list
# /opt/chef/bin is 134MB!
sudo apt-get purge chef
sudo apt-get clean
sudo apt-get autoclean
# Remove the directory
sudo rm -fr /var/lib/apt/lists
# Recreate the necessary directory structure
sudo mkdir -p /var/lib/apt/lists/partial
sudo rm -f /var/cache/apt/pkgcache.bin
sudo rm -f /var/cache/apt/srcpkgcache.bin
sudo apt-get purge apt-xapian-index
# This didn't exist on the 2014-08-27 DuckDuckHack VM for some reason.
sudo rm -r /var/cache/apt-xapian-index
rm -rf ~/.cpanm/work/*
# Chef backs up other files too, but this is the only large one (5.5MB)
sudo rm -f /var/chef/backup/tmp/sublime-text-editor.tar.bz2.chef-*
Then, create a new 8GB .vmdk dynamically expanding hard disk
And boot the from an ubuntu 12.04.x 32-bit live cd.
(Tested with 12.04.1 because that is the last verison to use the 12.04 HWE stack
and the ext4 driver changes with each new major version of the kernel.)
# These steps apply to the current boxes, where there is no LVM setup.
Open Gnome Disk Utility
For the new hard disk, select "Format Drive" and select MBR.
Create a "7.516 GB" ext4 partition (actually 7GB). Name: cloudimg-rootfs. Deselect "Take ownership of filesystem".
Crete a swap partition with the remaining space. Name: swap
# Note: No need to copy the filesystem's UUID because the box's fstab uses the
# LABEL to know which fs to mount.
mount the 2 partitions /mnt/sda1 and /mnt/sdb1
sudo rsync -aAXv /mnt/sda1/* /mnt/sdb1/ --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/mnt/*,/media/*,/lost+found}
Make sure the root of /dev/sdb1 is owned by root:root and mode 755
edit /dev/sdb1/etc/fstab to add the line:
LABEL=swap none swap sw 0 0
shutdown and detach the original hard disk
Boot the the CD again and:
reinstall grub according to the instructions here:
http://howtoubuntu.org/how-to-repair-restore-reinstall-grub-2-with-a-ubuntu-live-cd
Then shutdown and reboot from the new hard disk.
# Using a snapshot ensures that no temp files are created.
# Temp files would take up disk space.
Take a snapshot.
Test booting from the new hard disk.
Revert to the snapshot.
Once tested:
Delete the old hard disk.
# The DVD drive is not really needed. In VMware, its a serious usability issue
# because VMware has a tendency to lock the host drive and not let go.
Remove the DVD Drive
Switch the SATA port that the hard disk is in to "SATA Port 0"
Switch the SATA controller to having only 1 port.