Posts Tagged ‘linux’
So I finally went out and got a usb pen with more than 2Gb worth of space on it, and I did this really just for one reason: I wanted to try out this thing I’d seen over at hak5 a long time ago. This thing that I wanted to try out is the ultimate hacker tool, the multipass.
It’s time to put our white hats on. Go ahead and make yourself a good cup of coffee to enjoy before reading ahead. It isn’t a very difficult process, but coffee and hacking go well together 🙂
To put it simply, the concept is that you want one usb stick with many different tools on it. Usually, if you want to put a tool like Ubuntu on a usb stick what you do is use unetbootin, or a linux tool like dd, and write the entire disk image to your stick, and that’s it, you’ve got a live usb stick, and you can use it just fine, but it’s really not that versatile, and it’s not a very efficient use of 16Gb of space. If you want to try a different system you have to start all over again, and you lose any customizations you’ve made to your live system. So, hak5 ran this episode where they showed how to get around this using GRUB, the standard linux bootloader. Now, they used legacy GRUB, which is ancient technology, so I opted to try doing it with the newer GRUB2 which is a beautiful modular replacement. Later on I found that on the hak5 forums they’ve got guides for using GRUB2, but most of it is still centered around the old GRUB. This might be because doing it with GRUB2 is really easy, especially if you’re already familiar with GRUB. So how do you do it?
I will assume from this point on that you’re working from a linux environment, but most of this can easily be done from Windows as well, just google it!
- Format your usb stick.
Fire up your favorite partitioning tool, preferably one with support for linux filesystems, though fat32 should work as well. I recommend Gparted. You want to format your usb stick with an MBR table, and one partition formatted to ext4. For good measure you can also add boot to the partition flags. You can have another partition for storing data, but it’s not necessary, you can store that on your primary partition.
- Install GRUB
The first thing you need to do is figure out what your disk identifier is, and mount that disk. After that you will do the actual install of GRUB. This will write to the boot sector of your usb stick and add a boot folder with modules for file systems and graphics, nifty stuff! So, here’s how you do it:
sudo fdisk -l
You’ll get some output showing information about your disks. You’ll probably have a few partitions that start with /dev/sda, and then your usb will be /dev/sdb or /dev/sdc if you have more than one usb connected. Based on the information you will be able to tell which is your multipass. The entries with numbers on the end are partitions, so you want both /dev/sdX and /dev/sdXY where X is the letter and Y is the number. Once you know that you’re ready to move on.
sudo mkdir /mnt/usb sudo mount /dev/sdXY /mnt/usb sudo grub-install /dev/sdX --root-directory=/mnt/usb
And that’s basically it!
- Write grub.cfg
So we’ve got GRUB installed, but we still haven’t got any operating systems on there yet, so go ahead and download your favorite tool. Just for simplicity I’m going to be using ubuntu as an example, but the options are virtually limitless. Once we have our Ubuntu.iso we’re going to make a folder on the usb stick called iso, and copy the iso file into it. Afterwards you go into /mnt/usb/boot/grub and create a new file called grub.cfg. This is where you add boot entries and a lot of other good stuff. For now I’ll show you how to do a basic boot entry, and in a later entry I’ll show you how to theme it to your liking. So about that grub.cfg file:
menuentry "Ubuntu ISO"{ root (hda0,msdos1) loopback loop /iso/Ubuntu.iso linux (loop)/casper/vmlinuz boot=casper iso-scan/filename=/iso/Ubuntu.iso quiet splash initrd (loop)/casper/initrd.lz }
And that’s all there is to it! You’re ready to boot!
The different commands here are:
root (hda0,msdos1):
We’re telling grub to use the first partition on our usb. It’s hda0 now, instead of sdX.
loopback loop /iso/Ubuntu.iso:
Loop is a handy tool familiar to many linux users, it mounts an image as if it were a partition.
linux (loop)/.../vmlinuz:
This is the kernel line, telling grub where the linux kernel is within the mounted (loop) system. Different tools put this in different places, but for all ubuntu based live tools it’s always under casper. The stuff after vmlinuz is options passed to the kernel, and will also be different for different tools.
initrd (loop)/casper/initrd.lz:
The filesystem to be loaded into RAM and passed to the kernel for startup.
The options after the linux kernel line will vary somewhat from tool to tool, but not by a whole lot. Again, the guys over at the hak5 are pretty much the authority on this stuff, so if you’re having trouble getting a specific tool to work, just head over there and someone is likely to have a working config there. If you want to add another tool to your multipass all you have to do is move the iso to your iso directory on the multipass and add a menuentry to grub.cfg. In most linux systems updating grub.cfg is done with automated tools, but for multipass you want to edit it yourself.
Fun fact, this blog was written on a lubuntu live from my multipass. I went back into my primary OS in order to grab this screenshot of my bootloader though. As you can see I’ve kinda messed up the font and hightlights, but you get the gist of what’s possible 🙂
Song of the blog: Write in C
BRB, admin
Hello peeps, what’s up? I know right, two blog posts in the same year, what the hell!? Well, it has been documentet on several occasions that I get very productive during exams, I just don’t direct my energy towards the exams themselves. Hell, this whole blog project was started the day before a final exam back in high school. Anyway, you’re probably wondering what the title has to do with this, which is almost nothing, except that exams are closing in, and I’m doing cool shit that I want to blog about.
I’ve had this magnificent tablet that I’m typing on right now for a year, I think, maybe a year and a half, and it’s pretty rockin’. I’m an android power user, if such a thing exists, starting out on the HTC Hero, and staying there long past its expected lifetime, because I refused to spend money I didn’t really have on a new device, opting instead to flash unofficial ROMs from the lovely people over at the xda forums in order to stay with the times and the new features that came with new versions of android. God, I can’t even imagine the pain I’d experience if I had to go back to running Cupcake (android 1.6) on my Hero again, that’d be a nightmare! Anyway, at one point I lost my phone when I was in Oslo, and I had to purchase a new phone. I was pleased with my Hero, but I took it as an opportunity to make an upgrade, going with the Desire Z, which still to this day has the best qwerty keyboard of any phone on the market. That phone was rooted within an hour after I bought it, and it now runs a recent build of Ice Cream Sandwich (android 4.0). The keyboard is essential, but I’ll get back to that later. My point is that I love android. Any loyal readers will know that I love linux, and would install it on myself if I had a usb port and a network connection, and now I have this tablet thingie, with a keyboard dock that I got last christmas, and I’ve been using it on and off as a productivity device after my netbook’s battery died (fun fact, my netbook is also running a recent version of ICS from the android-x86 project). Now, while this gives me a nerdboner, tablets have limitations. The system isn’t really meant to be a replacement for your desktop OS, and working around these limitations at this point can get tiresome, and if you’ve ever opened up a terminal emulator on android, you’ll know that while it is running linux, it’s pretty barebones stuff. BUT! It is linux, and where there’s linux there’s a way.
I read a blog post a few days ago, I’ll link to it if I ever find it in my history, about a man who’d switched his workflow from a macbook to an ipad, and loved it. Now, this poses some problems for a computer engineer, but none that can’t be overcome with relative ease. I say relative, because you do need to be comfortable with the command line interface. Quick, think, what do you have stored in the cloud? I’m going to make an educated guess, and say you have music somewhere, email, probably some shared documents on Google Drive, and pictures in Picasa or Flickr. But that’s just for storage right? Well, yes, but they’re stored on computers, and if you take those fancy schmancy services away, you’re left with exactly what I need in order to work effectively from my tablet, a linux server with none of the hardware and system limitations of my android tablet. The guy who wrote the blog post was working from an ipad, and he was leasing a server (for pretty damn cheap) system called Linode. Now, I’ve looked at this before, but even if it’s cheap I just don’t feel that I can justify the extra monthly purchase. Luckily, a solution has been there for me all along, I just didn’t think about it much: I have access to the unix servers at the University in Stavanger! I got access way back in my freshman year! These are pretty powerful machines, able to handle the workloads of many students and employees simultaneously, and the internet speeds I can enjoy from them are out of this world. When Google told me syncing the android source tree would take an hour, I farted in their general direction, and then the sync was pretty much done. I’ve lost my train of thought, where was I?
Oh, yes, I have access to powerful machines though ssh, the secure shell protocol. All I needed was an android client, and I should be golden. Of course, this wasn’t exactly the case. The one thing people always bring up as a negative aspect of android is that it’s fragmented. As opposed to iGadgets, which are all produced by the same company, android gadgets are produced by a wide spectrum of companies, and they don’t allways see eye to eye when it comes to how to implement things, so you get things like tons of different keyboard layouts. I mentioned that my phone has the best keyboard out there for phones, but that’s just my (and HTCs) opinion. Samsung probably has a different idea, and Motorola a third, which is reflected in the keyboard dock I have. Now, I had downloaded an ssh client called ConnectBot, a great piece of software, except it doesn’t really support hardware keyboards that well, having been designed for a system that deals primarily with on-screen keyboards. It has a few workarounds for adding modifier keys (such as ctrl, alt, shift), but my keyboard actually has these keys, they just aren’t registered by the software! ARGH! There are even some bugs with this in the operating system itself, but the tablet comes with a software keyboard designed by Samsung that allows everything to work great. Except ConnectBot can’t know this, and can’t be designed to work with every single keyboard program for android, because there are, like, a thousand. Really. So I got frustrated, I needed keyboard shortcuts in order to use the programs that make working in the linux cli (command line interface) awesome and effective, but none of them were working! I downloaded experimental versions, I complained in the irc room, no one answered, and I downloaded more experimental versions and other programs. Nothing worked, and I was starting to feel jealous of the iPad guy, I was in a bad mood. And then I had an idea, why don’t I try to change the software keyboard? Ta-fucking-DAAAAA! Works like a charm. Well, alt key interactions don’t work, because this norwegian dock only has the alt-gr key, and I still have to use an experimental tablet version for it to work, but other than that, all is dandy! So, I bet you’re all wondering, but what can you do with it!?
What I can do with it
- I can connect to a powerful machine from anywhere in the world!
- I can use Gnu screen, a tool that lets me have many terminal windows open at the same time, and switch between them quickly.
Screen is cool for another reason, it keeps all my terminal windows, even when I log out, even if I lose my internet connection, even if I burn my tablet.. Say I’m working on some files, have a blog post open in emacs, and I’m compiling a large project, when my tablet unexpectedly reboots. If I’d have been working locally, that would all most likely be irrevocably lost. Now, I can go make a cup of coffee, run down to the library, open up a portable ssh client, and log into the system again. It’s all there, and hey! The program is done compiling! Screen keeps doing shit while I’m not logged in, and that’s awesome Holy shit that’s a lot of emphasis in one bulletpoint, but Screen is just that good. - I can keep my cool. Serious programmers are likely to have some serious computing power sitting at home, churning away at their programs, and it gets hot, seriously hot. When I’m working from my tablet, it’s not actually doing anything intensive, so while the heavy machinery on campus is running laps around your computer, my battery will last all day. I don’t need more than this single-core ARM processor (over)clocked at 1.4Ghz.
- I can goof around. While Screen is making sure that my shit keeps running on campus, I can disconnect and play some smooth games on my tablet. I can’t stress this enough, my tablet is completely unaffected by what the server is doing!
- I can never buy a normal computer again. I will though, I need to play Diablo III.
- I can compile the linux kernel in less time than it takes me to go to the store and buy donuts.
- I can check the progress on the linux kernel compilation from my phone while I’m going to the store! Yes, my phone can connect via ssh too, android is android, and the keyboard on the DZ is sweet enough that if the compile failed, I can change a few small things around and try again before the cashier can offer me my receipt.
- I can fly! Well, that’s not true, but I can make a server farm output this:
I can do more, but this blog post is already much too long. See ya on the other side!
Song of the blog: Hail to the Geek
Here to stay
Bjørn
Do you have any idea how disheartening it is to write long ass blogposts only to have them disappear, no drafts saved? That happened, many times. I’m done with offline blogging clients, before I even got properly started. Anyway, good to be back!
So today is the 17th of may, the Norwegian equivalent of 4th of July, happy constitution day! I thought I should make a blog post celebrating this, but there really isn’t much to say except I’m glad those people way back made Norway a free country, and laid the foundation for the great country I live in today, woohoo! And since that’s a bit of a short blogpost, even though short posts are ok too, I will throw in my current partition map as well. Hopefully some of you will find it interesting/impressive.
Partition | Type | Filesystem | Label |
1 | Extended | Extended | Extended |
6 | Logical | Ext3 | Tiny Core Linux |
7 | Logical | Swap | SWAP |
8 | Logical | NTFS | Windows 8 |
2 | Primary | Ext4 | Arch Linux |
3 | Primary | Ext4 | DATA |
4 | Primary | NTFS | Windows XP |
It belongs to the story that this is a 500GB hard disk, and that data partition coveres almost 300 of it. I’ve been spending the last two days working on getting Windows XP to install from a USB pen, and I can’t get it to work. If anyone has any suggestions, please feel free to put them in the comments. I’ve tried WinToFlash, didn’t work, and I’ve tried extracting the files to the usb and marking the partition as active from DISKPART, then using BOOTSECT to install the bootmgr that didn’t work either. I tried giving VirtualBox Access to the hard diks, and that installed, but then bluescreened at boot, which I kind of expected. Any tips at all?
Song of the blog: Ja vi elsker
Yours again
Bjørn