I've been running my own mail and web server(s) for well over a decade now. Not because I think I can do it better than what's out there. But because I was truly interested in understanding the nitty gritty of what makes the internet run. Historically I had always done this on a single Slackware Linux box. This served it's purpose but did come with a few side affects. I was using my email service as my primary email, my RSS aggregator as my primary source for news, and my CalDav server as my primary calendar.
One big problem I started to run into with my single server setup was that every so often while tinkering with some new software I wanted to learn about I'd inadvertently take down my server for a bit. Which basically meant I was dead out of the water in terms of my email, calendar, and RSS feeds. So I decided to let my curiosity about "The Cloud" turn into working knowledge by setting up my own Xen server.
My initial impression (which still holds true today) is that Xen is awesome. Within just a few hours I was able to get Xen running on my hand built server (16GB RAM, 700GB hard drive, Intel Quad Core i5). Slackware has never let me down so I decided to stick with it for my guest OSs and I setup separate servers for my production services and my tinkering. It's been great.
One problem I ran into while I was trying to find the optimal setup was shrinking a Linux disk that I made too big to start. So I thought I would document the process in case anyone out there was running into the same issue.
- Shutdown your existing Linux Virtual Machine (VM).
- Create and attach a new storage device in XEN.
- Start the Linux VM.
- Create a partition on new drive.
- Create a filesystem on the new partition.
- Create temporary mount point so that you can copy the existing partition over.
- Mount smaller partition you just created.
- Copy the contents of the existing partition that you want to shrink onto new smaller partition.
- After the copy has completed unmount the new smaller partition.
- Shutdown your Linux VM.
- Detach the original larger drive from the VM in XEN
- Restart the Linux VM and verify everything was copied and is working as expected.
- Delete no-longer-needed storage device in XEN.
$ sudo /sbin/fdisk /dev/sd[b,c,etc] (i.e. sdc or sdb or etc)
$ sudo /sbin/mkfs.ext4 /dev/sd[b,c,etc]1
$ sudo mkdir /temp_mount
$ sudo mount /dev/sd[b,c,etc]1 /temp_mount
$ sudo cp -rax /old/drive/* /temp_mount/
$ sudo umount /temp_mount
Post a Comment