I know, I know, a lot of you are asking, "Why on earth would you want to do anything with a machine that's 5 years old?!" The hardware is crap now, and it was crap when the EeePC came out. Well, my friends, that's one of the great things about Linux! It will put new life into old hardware. Granted, the EeePC 701 4G came with Linux on it and all that, but I'm talking about putting something modern on it. Regardless, this guide will hopefully be useful for others who are trying to get Linux installed using LVM that uses something like an SD card as part of the primary volume group.
I've had Arch Linux installed on my EeePC for quite a while, but I only recently began to appreciate the benefits of LVM. The key requirement for this installation was to use LVM partitioning instead of traditional partitioning. I wanted the built-in 4GB SSD and the 8GB SD card to appear as one hard drive to the operating system so I would have that much more space to actually use.
Another key requirement for this installation was that I wanted to do it using a PXE server instead of the usual USB/external CD drive method. I've used PXE servers in the past, but I never really did much with them. I wanted to use this as an excuse to learn a bit more about them.
If you're following along at home, I'm assuming that you have (access to) the following:
- An EeePC 701 4G
- An SD card that will be a permanent fixture in your EeePC
- A router running DD-WRT that serves as the DHCP server for your network (I am running v24-sp2). Alternatively, just use a USB/CD to install.
If you want to save some time and just use a USB/CD to install Arch, go ahead and skip to the Arch Installation section.
For those who are unfamiliar with PXE servers, PXE stands for "Preboot eXecution Environment." It allows you to boot your computer over the network using images stored on a different machine. Since I didn't want to plug in my USB key or external DVD drive, this was a perfect option.
I used my main laptop as the PXE server. All I really did was install atftp from the AUR, copy ipxe.pxe from the Arch Linux Netboot page (from the "Using an iPXE image" section), and put it in /var/tftpboot. After that, it was a matter of running atftpd:
rc.d start atftpd
The next step required tweaking the dnsmasq configuration on my router. Here's what I did:
Login to router
Go to the Services tab
Find the DNSMasq section (mine is already enabled for other purposes, so I assume you will want to make sure yours is enabled)
In the "Additional DNSMasq Options" box, make sure you have something like:
dhcp-boot=ipxe.pxe,[your PXE server's name],[your PXE server's IP]
Apply the changes. I rebooted my router just to be sure.
That's all there really is to the PXE side of things.
You'll want to make sure that booting from the network is enabled in your BIOS. I'll post a list of my BIOS settings later.
Then you should be able to boot your EeePC from the network. If your EeePC isn't configured to boot from the network first, you can simply hit Escape while the BIOS POST screen is still showing and select it from the menu that appears.
If all goes according to plan, your EeePC should receive an IP address and download the boot images from your PXE server. Once you select the appropriate Arch Install option from the menu, it should go out and download the ISO and boot it up. It's pretty neat to see in action. Maybe one day I'll try to tweak this to use an ISO image that's available on the local network instead of downloading it from the Internet every time.
Installing Arch Linux should be fairly simple if you follow the installation guide (which is also available during installation these days at /root/install.txt). The key thing to remember, if you want to use the built-in SSD and a permanent SD card as one hard drive, is to use LVM partitioning.
The Arch Linux LVM guide will likely be an invaluable resource if you're new to LVM. Here I will simply give a short list of commands that I think I used to get my EeePC setup (I did this several days ago, so I might miss something along the way...sorry)
It's important to note that, while it's supposedly possible, I've never had any luck keeping my boot partition in an LVM setup. As such, I first partition my SSD and SD cards using fdisk. There are plenty of resources for fdisk and cfdisk out there, so I'll skip over the specifics of how to use each one and just give you an idea of what needs to be done.
- Wipe all partitions from both /dev/sda (the SSD) and /dev/sdb (the SD card)
- Create a 50-100MB primary partition at the beginning of /dev/sda. Mark it as bootable. Set the partition type to 83 (Linux).
- Create another primary partition on /dev/sda that consumes the remaining disk space. Set the partition type to 8e (Linux LVM).
- Create a primary partition on /dev/sdb that consumes all space on the SD card. Set the partition type to 8e (Linux LVM).
Now that we have some "Linux LVM" partitions to deal with, we can begin using LVM. Each partition we wish to use (both /dev/sda2 and /dev/sdb1) needs to be configured as an LVM "physical volume":
pvcreate /dev/sda2 pvcreate /dev/sdb1
Next, we create an LVM volume group that uses both of our physical volumes:
vgcreate vg0 /dev/sda2 vgextend vg0 /dev/sdb1
Lastly, create the LVM logical volumes. It's up to you how you setup your partitions, but I chose to create a swap partition (since my EeePC only has 512MB RAM) and a root partition. To create a swap partition, you simply do something like this:
lvcreate -C y -l 1G vg0 -n swap
And here's what the arguments mean:
- -C y: make the partition contiguous
- -l 1G: number of logical extents to allocate for the new logical drive
- vg0: the name of the volume group we created earlier
- -n swap: the name of the new logical volume
I created my root partition to fill the remaining space in the volume group as follows:
lvcreate -l +100%FREE vg0 -n root
Then it's just a matter of formatting your partitions. I'm not up-to-date on the debate regarding which FS is ideal for solid state media, so I just chose ext2:
mkfs.ext2 /dev/sda1 mkfs.ext2 /dev/mapper/vg0-root mkswap /dev/mapper/vg0-swap
It's probably worth noting that you now have several ways to reference your newly-created LVM volumes. Here are my favorites:
- /dev/[volume group name]/[volume name]
- /dev/mapper/[volume group name]-[volume name]
I really don't want to duplicate the Arch Linux installation guide, so I'll just leave you to follow along there. Go ahead and mount your new partitions, pacstrap everything you want, and arch-chroot your heart away. But you might want to come back before you exit the chroot, otherwise your EeePC might not boot and you'll have to waste some time trying to figure out why.
Help The EeePC Boot With LVM
Before you reboot, you'll probably want to modify your /etc/mkinitcpio.conf to let your EeePC understand your LVM setup. The two key lines are MODULES and HOOKS. Here's what I have:
MODULES="usb-storage scsi-mod sd-mod libata usbcore uhci-hcd ehci-hcd" HOOKS="base udev autodetect pata scsi sata lvm2 filesystems usbinput fsck"
The key here is to ensure that lvm2 appears before filesystems in your HOOKS list. Also, you want to load some modules to allow the SD card to be detected before the LVM hook attempts to find your partitions. I'm not sure if you need all of those modules, but they worked on the first try for me. To make the changes useful, rebuild your boot images:
mkinitcpio -p linux
To go along with detecting your SD card at boot, you want to give it enough time to settle before LVM tries to use it. In my case, 3 seconds is sufficient, so I added this to my /boot/syslinux/syslinux.cfg:
You should be able to add that to the APPEND lines in your syslinux.cfg or the kernel line in your GRUB configuration file. Or whatever it is with GRUB these days.
Also, while you're editing your bootloader configuration, be sure to change the root partition to /dev/vg0/root (or whatever you chose when you did your LVM partitioning). The default syslinux.cfg includes root=/dev/sda3, so I just changed that to root=/dev/vg0/root. Most bootloaders allow you to modify the boot line before you actually boot into Linux if you forgot this step.
I'll leave you to install and configure the packages that you find useful. I plan on using my EeePC as a jump box into my home network, so it doesn't need a GUI of any sort. Just OpenSSH and some other goodies.
You might also be interested in my previous article about bonding eth0 and wlan0 now that you have Arch on your EeePC though!